Skip to main content
PUT
/
instances
/
{instanceId}
/
token
/
{token}
/
update-proxy-webhook
Proxy Failure Webhook
curl --request PUT \
  --url https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook \
  --header 'Client-Token: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "value": "<string>"
}
'
import requests

url = "https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook"

payload = { "value": "<string>" }
headers = {
    "Client-Token": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({value: '<string>'})
};

fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'value' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Client-Token: <api-key>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook"

	payload := strings.NewReader("{\n  \"value\": \"<string>\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Client-Token", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook")
  .header("Client-Token", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"value\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/update-proxy-webhook")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"value\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body

Overview

Method used to update the webhook URL where proxy connection failure callbacks will be received.

Parameters

instanceId
string
required
Your instance ID. Available in the Z-API panel under Instances.
token
string
required
Your Z-API instance token.

Attributes

value
string
required
Webhook URL that will receive the failure callbacks.

Request Body

{
  "value": "http://localhost:3001/api/webhook"
}

Callback Behavior

If an error occurs while connecting using the configured proxy, 3 retry attempts will be made. If the connection fails on the third attempt, the instance is connected without using any proxy, and a webhook is triggered to the URL configured at this endpoint, with the following payload:
{
  "type": "ProxyCallback",
  "instanceId": "3F2XXXXXXXXXXXXXXXXXXXA2FF",
  "error": "The instance was connected without proxy, the configured proxy (socks5://user:senha123@localhost:1080) failed 3 times to connect."
}

Response

200

{
  "value": true
}

405

In this case, make sure you are sending the correct method specification, i.e., check whether you sent the PUT request as specified at the beginning of this topic.

415

If you receive a 415 error, make sure to add the “Content-Type” header of the object you are sending in the request, in most cases “application/json”.