Each contact must have an invoice attached before triggering AI calls. A dummy invoice can be created for testing purposes.
Call to Contact
This flow initiates an AI phone call to a contact that already exists in your Levers system.Flow Diagram
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 phone call using the Response:Response:Response:The AI will call the contact’s phone number to discuss the invoice.
contactUuid.- cURL
- Python
- JavaScript
TriggerCall.sh
Copy
#!/bin/bash
trigger_call() {
local access_token=$1
local contact_uuid=$2
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\"}"
}
# Usage
trigger_call "<access_token>" "9bfa828a-3c2d-430c-bdc7-f74d90334524"
Copy
{
"callId": "call-abc123",
"status": "initiated",
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
trigger_call.py
Copy
import requests
def trigger_call(access_token: str, contact_uuid: str) -> dict:
"""Trigger AI call to the contact."""
response = requests.post(
"https://api.dev.uselevers.com/api-service/v1/ai/phone-calls/action/call",
json={"contactUuid": contact_uuid},
headers={"Authorization": f"Bearer {access_token}"}
)
return response.json()
# Usage
result = trigger_call("<access_token>", "9bfa828a-3c2d-430c-bdc7-f74d90334524")
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 triggerCall(accessToken, contactUuid) {
const response = await axios.post(
'https://api.dev.uselevers.com/api-service/v1/ai/phone-calls/action/call',
{ contactUuid },
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
return response.data;
}
// Usage
triggerCall('<access_token>", "9bfa828a-3c2d-430c-bdc7-f74d90334524")
.then(result => console.log('Call initiated:', result.callId));
Copy
{
"callId": "call-abc123",
"status": "initiated",
"contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
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(access_token: str, contact_uuid: str) -> dict:
"""Trigger AI call to the contact."""
response = requests.post(
f"{BASE_URL}/api-service/v1/ai/phone-calls/action/call",
json={"contactUuid": contact_uuid},
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
result = trigger_call(access_token, contact_uuid)
print(f"Call initiated: {result}")

