Skip to main content
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 the numberToCall parameter. The call will be made to the specified number instead of the contact’s registered phone number.

Flow Diagram

Key Difference

The numberToCall 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 uuid from the response.
CreateContact.sh
#!/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>"
Response:
{
  "uuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524",
  "name": "John Doe",
  "phoneNumber": "+96612341234"
}
Save the 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.
Create a dummy invoice attached to the contact using the contactUuid.
The invoice date must be in the past or current date in YYYY-MM-DD format (e.g., 2025-01-01).
CreateInvoice.sh
#!/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"
Response:
{
  "uuid": "inv-uuid-here",
  "number": "1",
  "total": 100.0,
  "contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
The contactUuid field links this invoice to your contact.
3

Trigger AI Call

Initiate the AI call to a custom number using contactUuid and numberToCall.
TriggerCall.sh
#!/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"
Response:
{
  "callId": "call-abc123",
  "status": "initiated",
  "contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
The AI will call +1234567890 instead of the contact’s registered number.

Complete Example

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}")

API References