Generate call token
curl --request GET \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/call-token \
--header 'Client-Token: <api-key>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/call-token"
headers = {"Client-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'Client-Token': '<api-key>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/call-token', 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}/call-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>"
],
]);
$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}/call-token"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Client-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.z-api.io/instances/{instanceId}/token/{token}/call-token")
.header("Client-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/call-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Client-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"token": "<string>"
}Calls
Generate call token
Generate an ephemeral token for call SDK authentication
GET
/
instances
/
{instanceId}
/
token
/
{token}
/
call-token
Generate call token
curl --request GET \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/call-token \
--header 'Client-Token: <api-key>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/call-token"
headers = {"Client-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'Client-Token': '<api-key>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/call-token', 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}/call-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>"
],
]);
$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}/call-token"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Client-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.z-api.io/instances/{instanceId}/token/{token}/call-token")
.header("Client-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/call-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Client-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"token": "<string>"
}Overview
This method generates an ephemeral token for call SDK authentication.The token is temporary and valid for a single connection. If the application restarts, a new token must be generated. It must be called from the backend, never from the frontend, to prevent credential exposure.
SDK Integration
This endpoint is designed to be used with the official call SDK: https://www.npmjs.com/package/@z-api/call For a practical example of generating and using the token in a backend environment, see the “Node.js Backend Example” section in the SDK documentation.Attributes
Header
string
required
Your instance ID. Available in the Z-API panel under Instances.
string
required
Your Z-API instance token.
Response
200
string
Ephemeral token for call SDK authentication
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}