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 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.