Consultar orígenes del SDK
curl --request GET \
--url https://api.omni.z-api.io/instances/{channelId}/sdk-info \
--header 'Authorization: <api-key>'import requests
url = "https://api.omni.z-api.io/instances/{channelId}/sdk-info"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.omni.z-api.io/instances/{channelId}/sdk-info', 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.omni.z-api.io/instances/{channelId}/sdk-info",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <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.omni.z-api.io/instances/{channelId}/sdk-info"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<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.omni.z-api.io/instances/{channelId}/sdk-info")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.omni.z-api.io/instances/{channelId}/sdk-info")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"allowOrigins": [
"https://app.suempresa.com",
"http://localhost:3000"
]
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Canales
Orígenes del SDK
Autoriza los dominios que pueden llamar al SDK de conexión y diagnostica fallos silenciosos
GET
/
instances
/
{channelId}
/
sdk-info
Consultar orígenes del SDK
curl --request GET \
--url https://api.omni.z-api.io/instances/{channelId}/sdk-info \
--header 'Authorization: <api-key>'import requests
url = "https://api.omni.z-api.io/instances/{channelId}/sdk-info"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.omni.z-api.io/instances/{channelId}/sdk-info', 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.omni.z-api.io/instances/{channelId}/sdk-info",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <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.omni.z-api.io/instances/{channelId}/sdk-info"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<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.omni.z-api.io/instances/{channelId}/sdk-info")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.omni.z-api.io/instances/{channelId}/sdk-info")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"allowOrigins": [
"https://app.suempresa.com",
"http://localhost:3000"
]
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Conceptos
El SDK de conexión resuelve{ success: false } sin decir el motivo. En la práctica falla por dos caminos muy distintos, y este endpoint resuelve el primero.
Fallo 1 — origen no autorizado
El SDK solo funciona desde dominios registrados enallowOrigins. Si el origen del navegador no está en la lista, aborta con:
[Omni Z-API SDK] Origin "https://app.suempresa.com" is not in the allowed origins list.
const info = await fetch(
`https://api.omni.z-api.io/instances/${channelId}/sdk-info`,
{ headers: { Authorization: SU_PUBLIC_KEY } },
).then((r) => r.json());
const permitido = info.allowOrigins.includes(window.location.origin);
El dominio del panel de Omni Z-API se acepta siempre, aunque no figure en
allowOrigins. Solo tienes que registrar tus dominios, incluido http://localhost:3000 para desarrollo.El registro de orígenes se hace en el panel, en Seguridad. No hay endpoint público para eso.
Fallo 2 — popup bloqueado
El SDK abre una ventana conwindow.open. Si llamas a client.connect() después de un await, el gesto del usuario ya se perdió y el navegador bloquea el popup: el SDK también devuelve { success: false }.
// Mal: el await consume el gesto del clic
async function onClick() {
const datos = await cargarAlgo();
await client.connect({ channelId }); // popup bloqueado
}
// Bien: connect() es lo primero después del clic
async function onClick() {
const promesa = client.connect({ channelId });
const datos = await cargarAlgo();
await promesa;
}
Autenticación
Este es el único endpoint que acepta la Public Key, y va en crudo en el header, sinBearer:
curl https://api.omni.z-api.io/instances/ID_DEL_CANAL/sdk-info \
-H "Authorization: SU_PUBLIC_KEY"