Skip to content

Apeluri outbound ​

Un endpoint. Fiecare cale de mai jos este relativă la URL-ul de bază al API-ului și include deja prefixul /api/v1 — vezi convențiile pentru autentificare, paginare, erori și idempotență.

Endpoint
POST/telephony/callsOriginate an outbound call directly through the carrier after policy, routing, caller-ID and concurrency checks

Endpoint-uri ​

Originate an outbound call directly through the carrier after policy, routing, caller-ID and concurrency checks ​

POST/telephony/calls
  • Handler-ul nu impune niciun scope — orice cheie validă îl poate apela.
  • Request body is camelCase (assistantId, phoneNumberId, callerId, answeringMachineDetection, idempotencyKey); the response is snake_case. Also returns 429 on concurrency limit

Corpul cererii

CâmpTipObligatoriuNote
assistantIdstring | null—max 32 chars
squadIdstring | null—max 32 chars
phoneNumberIdstring | null—
phoneNumberstring | null—max 32 chars
sipTrunkIdstring | null—
customerIdstring | null—max 32 chars
campaignIdstring | null—max 32 chars
customerobject—
customer.numberstring | null—max 64 chars
customer.namestring | null—max 255 chars
tostring | null—max 64 chars
callerIdstring | null—max 32 chars
variablesstring[] | null—
metadatastring[] | null—
assistantOverridesstring[] | null—
customSipHeadersstring[] | null—
answeringMachineDetectionboolean | null—
recordingModedisabled · mono · dual_channel · inherit · null | null—
timeoutSecondsinteger | null—min 5. max 600
scheduledAtstring | null—date-time
idempotencyKeystring | null—max 128 chars
bash
curl -X POST "$CALLAGENT_API_URL/telephony/calls" \
  -H "Authorization: Bearer $CALLAGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
       "phoneNumberId": "+40712345678",
       "phoneNumber": "+40712345678",
       "customer": {
         "number": "+40712345678",
         "name": "Support Line"
       },
       "to": "+40712345678",
       "answeringMachineDetection": true,
       "recordingMode": "disabled",
       "timeoutSeconds": 30
     }'
js
const response = await fetch(`${process.env.CALLAGENT_API_URL}/telephony/calls`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CALLAGENT_API_KEY}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "phoneNumberId": "+40712345678",
    "phoneNumber": "+40712345678",
    "customer": {
      "number": "+40712345678",
      "name": "Support Line"
    },
    "to": "+40712345678",
    "answeringMachineDetection": true,
    "recordingMode": "disabled",
    "timeoutSeconds": 30
  }),
});

if (!response.ok) {
  const { error } = await response.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const { data } = await response.json();
php
<?php

$handle = curl_init(getenv('CALLAGENT_API_URL') . '/telephony/calls');

curl_setopt_array($handle, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('CALLAGENT_API_KEY'),
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
    'phoneNumberId' => '+40712345678',
    'phoneNumber' => '+40712345678',
    'customer' => [
        'number' => '+40712345678',
        'name' => 'Support Line',
    ],
    'to' => '+40712345678',
    'answeringMachineDetection' => true,
    'recordingMode' => 'disabled',
    'timeoutSeconds' => 30,
]),
]);

$body = json_decode(curl_exec($handle), true);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);

if ($status >= 400) {
    throw new RuntimeException("{$body['error']['type']}: {$body['error']['message']}");
}

$data = $body['data'];
python
import os, requests

response = requests.post(
    f"{os.environ['CALLAGENT_API_URL']}/telephony/calls",
    headers={"Authorization": f"Bearer {os.environ['CALLAGENT_API_KEY']}"},
    json={
      "phoneNumberId": "+40712345678",
      "phoneNumber": "+40712345678",
      "customer": {
        "number": "+40712345678",
        "name": "Support Line"
      },
      "to": "+40712345678",
      "answeringMachineDetection": True,
      "recordingMode": "disabled",
      "timeoutSeconds": 30
    },
    timeout=30,
)
response.raise_for_status()
data = response.json()["data"]

Răspunsuri

StatusCorp
200JSON object
201data-wrapped object

Erori

StatusCând apare
403Destination policy or an outbound route blocks it, or the caller ID is not owned
404The given phoneNumberId or sipTrunkId does not exist in this organization
422Validation failed, no destination was given, or nothing routes to the destination
501The resolved telephony provider has no outbound-call implementation
502The carrier rejected or failed the origination request

Exemplu de răspuns, generat din schemă:

json
"string"

Scrisă după cod. Ce nu este încă implementat este marcat ca atare, niciodată descris ca funcțional.