Each contact must have an invoice attached before triggering AI calls. A dummy invoice can be created for testing purposes.
Call to Number
This flow initiates an AI phone call to any phone number using thenumberToCall parameter. The call will be made to the specified number instead of the contact’s registered phone number.
Flow Diagram
Key Difference
ThenumberToCall parameter overrides the contact’s registered phone number. This allows you to:
- Test call interactions without calling the actual contact
- Demo AI features to any number
- Impersonate calls for testing and QA
Step-by-Step
1
Create Contact
Create a contact and get the Response:Response:Response:Save the
uuid from the response.- cURL
- Python
- JavaScript
CreateContact.sh
Copy
#!/bin/bash
create_contact() {
local access_token=$1
curl --request POST \
--url https://api.dev.uselevers.com/api-service/v1/contact \
--header "Authorization: Bearer $access_token" \
--header 'Content-Type: application/json' \
--data '{
"name": "John Doe",
"phoneNumber": "+96612341234",
"email": "[email protected]",
"role": "PRIMARY"
}'
}
# Usage
create_contact "<access_token>"
Copy
{
"uuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524",
"name": "John Doe",
"phoneNumber": "+96612341234"
}
create_contact.py
Copy
import requests
def create_contact(access_token: str) -> dict:
"""Create a contact and return the response."""
response = requests.post(
"https://api.dev.uselevers.com/api-service/v1/contact",
json={
"name": "John Doe",
"phoneNumber": "+96612341234",
"email": "[email protected]",
"role": "PRIMARY"
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
# Usage
result = create_contact("<access_token>")
print(f"Contact UUID: {result['uuid']}")
Copy
{
"uuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524",
"name": "John Doe",
"phoneNumber": "+96612341234"
}
create-contact.js
Copy
const axios = require('axios');
async function createContact(accessToken) {
const response = await axios.post(
'https://api.dev.uselevers.com/api-service/v1/contact',
{
name: 'John Doe',
phoneNumber: '+96612341234',
email: '[email protected]',
role: 'PRIMARY'
},
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
return response.data;
}
// Usage
createContact('<access_token>').then(result => {
console.log('Contact UUID:', result.uuid);
});
Copy
{
"uuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524",
"name": "John Doe",
"phoneNumber": "+96612341234"
}
uuid - you’ll need it to create the invoice and trigger the call.2
Create Invoice
This step will be removed soon. In the future, you’ll only need to create a contact to trigger AI calls.
contactUuid.The invoice date must be in the past or current date in
YYYY-MM-DD format (e.g., 2025-01-01).- cURL
- Python
- JavaScript
CreateInvoice.sh
Copy
#!/bin/bash
create_invoice() {
local access_token=$1
local contact_uuid=$2
curl --request POST \
--url https://api.dev.uselevers.com/api-service/v1/invoice \
--header "Authorization: Bearer $access_token" \
--header 'Content-Type: application/json' \
--data "{
\"number\": \"1\",
\"date\": \"2025-01-01\",
\"dueDate\": \"2025-01-15\",
\"total\": 100.0,
\"contactUuid\": \"$contact_uuid\"
}"
}
# Usage
create_invoice "<access_token>" "9bfa828a-3c2d-430c-bdc7-f74d90334524"
Copy
{
"uuid": "inv-uuid-here",
"number": "1",
"total": 100.0,
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
create_invoice.py
Copy
import requests
def create_invoice(access_token: str, contact_uuid: str) -> dict:
"""Create a dummy invoice attached to the contact."""
response = requests.post(
"https://api.dev.uselevers.com/api-service/v1/invoice",
json={
"number": "1",
"date": "2025-01-01",
"dueDate": "2025-01-15",
"total": 100.0,
"contactUuid": contact_uuid
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
# Usage
result = create_invoice("<access_token>", "9bfa828a-3c2d-430c-bdc7-f74d90334524")
print(f"Invoice UUID: {result['uuid']}")
Copy
{
"uuid": "inv-uuid-here",
"number": "1",
"total": 100.0,
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
create-invoice.js
Copy
const axios = require('axios');
async function createInvoice(accessToken, contactUuid) {
const response = await axios.post(
'https://api.dev.uselevers.com/api-service/v1/invoice',
{
number: '1',
date: '2025-01-01',
dueDate: '2025-01-15',
total: 100.0,
contactUuid
},
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
return response.data;
}
// Usage
createInvoice('<access_token>', '9bfa828a-3c2d-430c-bdc7-f74d90334524')
.then(result => console.log('Invoice UUID:', result.uuid));
Copy
{
"uuid": "inv-uuid-here",
"number": "1",
"total": 100.0,
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
contactUuid field links this invoice to your contact.3
Trigger AI Call
Initiate the AI call to a custom number using Response:Response:Response:The AI will call
contactUuid and numberToCall.- cURL
- Python
- JavaScript
TriggerCall.sh
Copy
#!/bin/bash
trigger_call_to_number() {
local access_token=$1
local contact_uuid=$2
local number_to_call=$3
curl --request POST \
--url https://api.dev.uselevers.com/api-service/v1/ai/phone-calls/action/call \
--header "Authorization: Bearer $access_token" \
--header 'Content-Type: application/json' \
--data "{
\"contactUuid\": \"$contact_uuid\",
\"numberToCall\": \"$number_to_call\"
}"
}
# Usage
trigger_call_to_number "<access_token>" "9bfa828a-3c2d-430c-bdc7-f74d90334524" "+1234567890"
Copy
{
"callId": "call-abc123",
"status": "initiated",
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
trigger_call.py
Copy
import requests
def trigger_call_to_number(access_token: str, contact_uuid: str, number_to_call: str) -> dict:
"""Trigger AI call to a custom number."""
response = requests.post(
"https://api.dev.uselevers.com/api-service/v1/ai/phone-calls/action/call",
json={
"contactUuid": contact_uuid,
"numberToCall": number_to_call
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
# Usage
result = trigger_call_to_number("<access_token>", "9bfa828a-3c2d-430c-bdc7-f74d90334524", "+1234567890")
print(f"Call initiated: {result['callId']}")
Copy
{
"callId": "call-abc123",
"status": "initiated",
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
trigger-call.js
Copy
const axios = require('axios');
async function triggerCallToNumber(accessToken, contactUuid, numberToCall) {
const response = await axios.post(
'https://api.dev.uselevers.com/api-service/v1/ai/phone-calls/action/call',
{
contactUuid,
numberToCall
},
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
return response.data;
}
// Usage
triggerCallToNumber('<access_token>', '9bfa828a-3c2d-430c-bdc7-f74d90334524', '+1234567890')
.then(result => console.log('Call initiated:', result.callId));
Copy
{
"callId": "call-abc123",
"status": "initiated",
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
+1234567890 instead of the contact’s registered number.Complete Example
Copy
import requests
BASE_URL = "https://api.dev.uselevers.com"
def create_contact(access_token: str) -> dict:
"""Create a contact and return the response."""
response = requests.post(
f"{BASE_URL}/api-service/v1/contact",
json={
"name": "John Doe",
"phoneNumber": "+96612341234",
"email": "[email protected]",
"role": "PRIMARY"
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
def create_invoice(access_token: str, contact_uuid: str) -> dict:
"""Create a dummy invoice attached to the contact."""
response = requests.post(
f"{BASE_URL}/api-service/v1/invoice",
json={
"number": "1",
"date": "2025-01-01",
"dueDate": "2025-01-15",
"total": 100.0,
"contactUuid": contact_uuid
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
def trigger_call_to_number(access_token: str, contact_uuid: str, number_to_call: str) -> dict:
"""Trigger AI call to a custom number."""
response = requests.post(
f"{BASE_URL}/api-service/v1/ai/phone-calls/action/call",
json={
"contactUuid": contact_uuid,
"numberToCall": number_to_call
},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
# Usage
access_token = "YOUR_ACCESS_TOKEN"
# Step 1: Create contact
contact_result = create_contact(access_token)
contact_uuid = contact_result["uuid"]
print(f"Contact created: {contact_uuid}")
# Step 2: Create invoice
invoice_result = create_invoice(access_token, contact_uuid)
print(f"Invoice created: {invoice_result['uuid']}")
# Step 3: Trigger call to custom number
test_number = "+1234567890"
result = trigger_call_to_number(access_token, contact_uuid, test_number)
print(f"Call initiated to {test_number}: {result}")

