Skip to main content

Endpoint

POST https://{yourserver}/webhooks/call
Content-Type: application/json
This webhook is sent when a new call is created on the platform. It is configured at the application level. Reference: Call Hook (POST)

Request

The request body contains call information as JSON (see CallHook schema below).

Response

Return a 200 with a JSON payload consisting of an array of verbs to control the call.

CallHook schema

PropertyTypeDescription
call_sidstringUnique identifier for the call
call_idstringCall ID on the server
application_sidstringUnique identifier for the Graine application controlling this call
account_sidstringUnique identifier for the Graine account
directionstringinbound — call originated outside Graine; outbound — call originated by Graine
fromstringCalling party number
tostringCalled party number
caller_namestringCaller name, if known
sip_statusnumberMost recent SIP status code for the call
sip_reasonstringDescription of the last SIP status
call_statusstringOne of: trying, ringing, early-media, in-progress, completed, failed, busy, no-answer
sbc_callidstringOriginal call ID when the call arrived at Graine
originating_sip_ipstringIP address that sent the call to Graine
originating_sip_trunk_namestringName of the carrier in Graine that received the call
local_sip_addressstringInternal address of the Feature Server handling the call
service_provider_sidstringID of the service provider the account belongs to
sipobjectThe SIP request for the call (raw, headers, body, method, version, uri, payload)
env_varsobjectApplication environment variables

Authentication

Authorization: Basic authentication (required)

Example request

import requests

url = "https://{yourserver}/webhooks/call"

payload = {
    "call_sid": "d2515c3b-b79a-41a2-971a-445e769c823c",
    "call_id": "d2515c3b-b79a-41a2-971a-445e769c823c",
    "application_sid": "72c5c38f-9bba-40ce-aa83-aaa6be55e1b5",
    "account_sid": "bad98250-b34d-459d-9e90-f97dfb9bc519",
    "direction": "inbound",
    "from": "+12125551212",
    "to": "+14155551234",
    "caller_name": "John Doe",
    "sip_status": 100,
    "sip_reason": "Trying",
    "call_status": "trying"
}
headers = {
    "Authorization": "Basic <username>:<password>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = 'https://{yourserver}/webhooks/call';
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Basic <username>:<password>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    call_sid: 'd2515c3b-b79a-41a2-971a-445e769c823c',
    call_id: 'd2515c3b-b79a-41a2-971a-445e769c823c',
    application_sid: '72c5c38f-9bba-40ce-aa83-aaa6be55e1b5',
    account_sid: 'bad98250-b34d-459d-9e90-f97dfb9bc519',
    direction: 'inbound',
    from: '+12125551212',
    to: '+14155551234',
    caller_name: 'John Doe',
    sip_status: 100,
    sip_reason: 'Trying',
    call_status: 'trying'
  })
};

const response = await fetch(url, options);
const data = await response.json();
console.log(data);