Deleting an instance
curl --request DELETE \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete \
--header 'Authorization: <authorization>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete', 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}/integrator/on-demand/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyPartners
Deleting an instance
Deletes an instance linked to your integrator partner account
DELETE
/
instances
/
{instanceId}
/
token
/
{token}
/
integrator
/
on-demand
/
delete
Deleting an instance
curl --request DELETE \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete \
--header 'Authorization: <authorization>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete', 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}/integrator/on-demand/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyOverview
Method used to delete an instance linked to your account. To delete several at once, use Deleting instances in bulk.To use Partner endpoints, provide the Partner Token in the Authorization field using the following format:
Bearer <Partner-Token>It is not necessary to send the Client-Token in these requests.Deletion is permanent and cannot be undone.
Eligibility rules
An instance is only deleted when it meets all of the conditions below:- It is disconnected from WhatsApp and from the phone.
- Its subscription is canceled. Paid instances, pending ones, ones with a pending bank slip, ones in the cancellation process, or ones in payment retry are not eligible.
- It is not in trial. A trial must expire naturally or be canceled first.
- The 40-day grace period counted from the subscription cancellation date has already passed.
Attributes
Header
string
required
Partner token in the
Bearer <Partner-Token> formatPath
string
required
Your instance ID. Available in the Z-API panel under Instances.
string
required
Your Z-API instance token.
Response
204
The instance was deleted. The response has no body.400
The instance does not meet the eligibility rules. Themessage field states the reason.
{
"message": "Cannot delete instance because it is still in the grace period of 40 days after cancellation"
}
| Message | When it happens |
|---|---|
Cannot delete instance because it is still connected to WhatsApp or phone | The instance is still connected. |
Cannot delete a trial instance. Trials must expire naturally or be canceled first | The instance is in trial. |
Cannot delete instance because it is still active | The subscription is still active. |
Cannot delete instance because payment status is not canceled | The subscription is not canceled. |
Cannot delete instance because it is still in the grace period of 40 days after cancellation | The instance was canceled less than 40 days ago. |
Cannot delete instance because payment status is unknown | The payment status could not be determined. |
401
The Authorization header was not sent or the Partner Token is invalid.{
"message": "Authorization token is empty"
}
404
No instance exists for the giveninstanceId and token pair.
{
"message": "Instance not found"
}