L402 API
Pay with Bitcoin, get AI results. Copy-paste the commands below.
Choose a service:
Before You Start
Want to try this without a terminal? Use AI Phone Call on the web — pay with any Lightning wallet, no setup needed.
Using the L402 Automated Phone Call API
Place automated phone calls to any number worldwide. The call delivers a spoken message (text-to-speech) or plays an audio file you provide. Ideal for alerts, reminders, and notifications.
API Endpoint: https://sats4ai.com/api/l402/place-call
Step 1: Initial Request (to get Macaroon and Invoice)
Send a POST request with the destination phone number and either a text message or audio URL. This returns a 402 Payment Required with L402 headers (macaroon + Lightning invoice).
Example A — Text-to-speech:
curl -X POST https://sats4ai.com/api/l402/place-call \
-H "Content-Type: application/json" \
-d '{"phone_number":"+1234567890","message":"Hello, this is your appointment reminder for tomorrow at 3 PM."}' \
-iExample B — Audio file (include duration_minutes):
curl -X POST https://sats4ai.com/api/l402/place-call \
-H "Content-Type: application/json" \
-d '{"phone_number":"+1234567890","audio_url":"https://example.com/my-audio-message.mp3","duration_minutes":2}' \
-iStep 2: Pay the Lightning Invoice
Pay the Lightning invoice from the www-authenticate header using any Lightning wallet. Save the preimage (proof of payment) for Step 3.
Step 3: Final Request (to Place the Call)
Repeat the same request with an Authorization header containing the macaroon and preimage.
Important: The JSON body must be identical to Step 1.
Example A — TTS:
curl -X POST https://sats4ai.com/api/l402/place-call \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{"phone_number":"+1234567890","message":"Hello, this is your appointment reminder for tomorrow at 3 PM."}'Example B — Audio file:
curl -X POST https://sats4ai.com/api/l402/place-call \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{"phone_number":"+1234567890","audio_url":"https://example.com/my-audio-message.mp3","duration_minutes":2}'Success Response:
{
"success": true,
"sid": "CA1234567890abcdef",
"status": "queued",
"to": "+1234567890"
}Request Body Parameters
Option A: Text-to-Speech
{
"phone_number": "+1234567890",
"message": "Hello, this is your appointment reminder for tomorrow at 3 PM."
}Option B: Play Audio File
{
"phone_number": "+1234567890",
"audio_url": "https://example.com/my-audio-message.mp3",
"duration_minutes": 2
}phone_number: string (required)
The destination phone number in E.164 format. Example: "+1234567890"
message: string (optional)
Text to speak via TTS when the call is answered. Maximum 500 characters. Provide this OR audio_url.
audio_url: string (optional)
Public URL to an audio file (MP3, WAV) to play when the call is answered. Provide this OR message. If both are given, audio_url takes priority.
Tip: You can generate the audio file using Sats4AI's own Text-to-Speech service first, then pass the resulting URL here for full control over the voice and language.
duration_minutes: number (required for audio_url)
How many minutes of audio to play. Required when using audio_url. Must be between 1 and 30. Pricing scales with duration and destination.
For text-to-speech messages, this is always 1 minute (TTS messages are short) and does not need to be specified.
Using the L402 AI Voice Agent Call API
Send an AI voice agent to call any phone number and carry out a task on your behalf. The agent speaks naturally, follows your instructions, and returns a full transcript when the call ends. Ideal for making reservations, gathering information, scheduling appointments, or any task that requires a live phone conversation.
Smart features: The API validates your task before calling — if critical details are missing (e.g., booking without a date), it returns clarification questions you can answer before the call proceeds. Calls automatically retry up to 3 times on voicemail or busy signal (included in payment). On task failure, the full transcript is returned so you can adjust and try again with a new payment.
API Endpoint: https://sats4ai.com/api/l402/ai-call
Step 0: Discovery (Optional)
Send a GET request to see accepted parameters, pricing details, and supported options.
curl -X GET https://sats4ai.com/api/l402/ai-callStep 1: Initial Request (to get Macaroon and Invoice)
Send a POST request with the destination phone number and the task you want the AI agent to perform. This returns a 402 Payment Required response with L402 headers (macaroon + Lightning invoice).
curl -X POST https://sats4ai.com/api/l402/ai-call \
-H "Content-Type: application/json" \
-d '{"phone_number":"+1234567890","task":"Call the restaurant and make a reservation for 2 people at 7 PM tonight under the name Smith.","duration_minutes":3,"language":"en","begin_message":"Hi, I'd like to make a reservation please."}' \
-iStep 2: Pay the Lightning Invoice
Pay the Lightning invoice from the www-authenticate header using any Lightning wallet. Save the preimage (proof of payment) for Step 3.
Step 3: Final Request (to Start the AI Call)
Repeat the same request with an Authorization header containing the macaroon and preimage.
Important: The JSON body must be identical to Step 1.
curl -X POST https://sats4ai.com/api/l402/ai-call \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{"phone_number":"+1234567890","task":"Call the restaurant and make a reservation for 2 people at 7 PM tonight under the name Smith.","duration_minutes":3,"language":"en","begin_message":"Hi, I'd like to make a reservation please."}'Success Response (call initiated):
{
"success": true,
"state": "calling",
"call_id": "call_abc123def456",
"session_id": "uuid-...",
"status": "initiated",
"poll_url": "https://sats4ai.com/api/l402/ai-call?call_id=call_abc123def456",
"message": "Call initiated. Poll the poll_url for transcript and results."
}Push-back Response (missing details):
If your task is missing critical info (e.g., a booking without date or time), the API returns clarification questions instead of starting the call. Answer them with a confirm request.
{
"success": true,
"state": "pending_confirm",
"session_id": "uuid-...",
"questions": [
"What date should the booking be for?",
"What time would you prefer?",
"How many people will be dining?"
],
"message": "Task is missing some details. POST with action='confirm' to proceed."
}Confirm Request (after push-back):
curl -X POST https://sats4ai.com/api/l402/ai-call \
-H "Content-Type: application/json" \
-d '{
"action": "confirm",
"session_id": "uuid-...",
"answers": {
"What date should the booking be for?": "This Saturday",
"What time would you prefer?": "7pm",
"How many people will be dining?": "4"
}
}'Step 4: Poll for Transcript & Results
The AI call runs asynchronously. Use the call_id from the response to poll for the transcript and call status. No authentication is required for polling.
curl -X GET "https://sats4ai.com/api/l402/ai-call?call_id=<CALL_ID_FROM_RESPONSE>"Polling Response (in progress):
{
"status": "in_progress",
"call_id": "call_abc123def456",
"message": "Call in progress. Poll again for results."
}Polling Response (auto-retrying):
{
"status": "in_progress",
"call_id": "call_abc123def456",
"attempt": 2,
"max_attempts": 3,
"retry_reason": "voicemail_reached",
"message": "Auto-retrying (attempt 2/3, reason: voicemail_reached). Poll again."
}Polling Response (completed - task succeeded):
{
"status": "ended",
"call_id": "call_abc123def456",
"task_completed": true,
"transcript": "Agent: Hi, I'd like to make a reservation...\nHost: Of course...",
"call_analysis": { "call_summary": "Reserved a table for 4 at 7 PM Saturday." },
"recording_url": "https://..."
}Polling Response (completed - task failed):
{
"status": "ended",
"call_id": "call_abc123def456",
"task_completed": false,
"transcript": "Agent: Hi, I'd like to book...\nHost: Sorry, we're fully booked...",
"call_analysis": { "call_summary": "Restaurant fully booked for Saturday." },
"disconnection_reason": "agent_hangup",
"message": "Task was not completed. Review the transcript to understand what happened. You can retry with a new payment."
}AI Call Request Body Parameters
{
"phone_number": "+1234567890",
"task": "Call the restaurant and make a reservation for 2 people at 7 PM tonight under the name Smith.",
"duration_minutes": 3,
"language": "en",
"begin_message": "Hi, I'd like to make a reservation please."
}phone_number: string (required)
The destination phone number in E.164 format. Example: "+1234567890"
task: string (required)
Instructions for the AI agent describing what to accomplish on the call. Maximum 2000 characters. Be specific about the goal, any details to convey, and what information to gather.
duration_minutes: number (optional)
Maximum duration for the call in minutes. Must be between 1 and 10. Defaults to 3. Pricing scales with duration and destination.
language: string (optional)
Language for the AI agent to speak. Defaults to English if not specified. Use standard language codes (e.g., "en", "es", "fr", "de", "ja").
begin_message: string (optional)
The first message the AI agent says when the call is answered. If not provided, the agent will generate an appropriate greeting based on the task.