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 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 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 phone call using the contactUuid.
TriggerCall.sh
#!/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"
Response:
{
  "callId": "call-abc123",
  "status": "initiated",
  "contactUuid": "9bfa828a-3c2d-430c-bdc7-f74d90334524"
}
The AI will call the contact’s phone number to discuss the invoice.

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

API References