Crear sesión embebida
Crea un token de sesión de embed de corta duración (JWT) para montar el microfrontend de chat (surface: "chat") o de conexión (surface: "connect") en tu propio sitio mediante el SDK @pilot-status/embed. allowedOrigins (1–20 orígenes exactos http(s)://host[:port]) restringe dónde puede ejecutarse el iframe; brandingOverride aplica branding por sesión; ttlSeconds controla la validez (por defecto 900 para chat, 1800 para connect; máx. 3600). Los campos que el esquema no conoce se ignoran. Renueva con POST /api/public/embed/refresh.
Credenciales: una clave de workspace, una clave de número (solo chat: solo puede embeber su propio número), una clave de cuenta con x-workspace-id o un token OAuth. chat necesita un usuario AGENT o superior (messages:send); connect necesita una credencial con alcance de tenant (403 NUMBER_SCOPE_NOT_ALLOWED) y un usuario ADMIN o superior (numbers:connect).
curl --request POST \
--url https://pilotstatus.com.br/v1/embed/sessions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"surface": "chat",
"allowedOrigins": [
"https://app.tenant.com"
],
"whatsappNumberIds": [
"num_01HZX..."
],
"brandingOverride": {},
"ttlSeconds": 900
}
'import requests
url = "https://pilotstatus.com.br/v1/embed/sessions"
payload = {
"surface": "chat",
"allowedOrigins": ["https://app.tenant.com"],
"whatsappNumberIds": ["num_01HZX..."],
"brandingOverride": {},
"ttlSeconds": 900
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
surface: 'chat',
allowedOrigins: ['https://app.tenant.com'],
whatsappNumberIds: ['num_01HZX...'],
brandingOverride: {},
ttlSeconds: 900
})
};
fetch('https://pilotstatus.com.br/v1/embed/sessions', 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://pilotstatus.com.br/v1/embed/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'surface' => 'chat',
'allowedOrigins' => [
'https://app.tenant.com'
],
'whatsappNumberIds' => [
'num_01HZX...'
],
'brandingOverride' => [
],
'ttlSeconds' => 900
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pilotstatus.com.br/v1/embed/sessions"
payload := strings.NewReader("{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.post("https://pilotstatus.com.br/v1/embed/sessions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/embed/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}"
response = http.request(request)
puts response.read_body{
"token": "eyJhbGciOiJIUzI1NiJ9.<claims>.<sig>",
"surface": "chat",
"whatsappNumberIds": [
"num_01HZX..."
],
"allowedOrigins": [
"https://app.tenant.com"
],
"expiresAt": "2026-06-26T15:15:00.000Z"
}Cuerpo
Respuesta
Crear sesión de chat
¿Esta página le ayudó?
curl --request POST \
--url https://pilotstatus.com.br/v1/embed/sessions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"surface": "chat",
"allowedOrigins": [
"https://app.tenant.com"
],
"whatsappNumberIds": [
"num_01HZX..."
],
"brandingOverride": {},
"ttlSeconds": 900
}
'import requests
url = "https://pilotstatus.com.br/v1/embed/sessions"
payload = {
"surface": "chat",
"allowedOrigins": ["https://app.tenant.com"],
"whatsappNumberIds": ["num_01HZX..."],
"brandingOverride": {},
"ttlSeconds": 900
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
surface: 'chat',
allowedOrigins: ['https://app.tenant.com'],
whatsappNumberIds: ['num_01HZX...'],
brandingOverride: {},
ttlSeconds: 900
})
};
fetch('https://pilotstatus.com.br/v1/embed/sessions', 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://pilotstatus.com.br/v1/embed/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'surface' => 'chat',
'allowedOrigins' => [
'https://app.tenant.com'
],
'whatsappNumberIds' => [
'num_01HZX...'
],
'brandingOverride' => [
],
'ttlSeconds' => 900
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pilotstatus.com.br/v1/embed/sessions"
payload := strings.NewReader("{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.post("https://pilotstatus.com.br/v1/embed/sessions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pilotstatus.com.br/v1/embed/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"surface\": \"chat\",\n \"allowedOrigins\": [\n \"https://app.tenant.com\"\n ],\n \"whatsappNumberIds\": [\n \"num_01HZX...\"\n ],\n \"brandingOverride\": {},\n \"ttlSeconds\": 900\n}"
response = http.request(request)
puts response.read_body{
"token": "eyJhbGciOiJIUzI1NiJ9.<claims>.<sig>",
"surface": "chat",
"whatsappNumberIds": [
"num_01HZX..."
],
"allowedOrigins": [
"https://app.tenant.com"
],
"expiresAt": "2026-06-26T15:15:00.000Z"
}