Skip to main content

L402 API

Pay with Bitcoin, get AI results. Copy-paste the commands below.

Before You Start

Lightning Wallet

Phoenix, Muun, Wallet of Satoshi, Alby, or any LN wallet

Terminal or Tool

A command line, Postman, or lnget (recommended)

Private & No Signup

No account, no subscription, no personal data. Pay only when you use it

Send Email via L402

Send a single email to any address without creating an account, setting up a domain, or configuring an SMTP server. Flat rate: 200 sats/email. Plain text only. A footer noting the email was relayed via Sats4AI.com is appended.

Ideal for agents that need to send occasional transactional emails, notifications, or alerts without the overhead of setting up an email service account.

API Endpoint: https://sats4ai.com/api/l402/email

Constraints

  • One email per payment — each invoice covers exactly one send
  • Plain text body only (no HTML)
  • Subject: max 200 characters
  • Body: max 10,000 characters
  • Sent from our relay address — include replyTo for replies to reach you
  • Footer appended: "Sent via Sats4AI.com — Anonymous email powered by Bitcoin Lightning."

Step 1: Initial Request (get Invoice)

Send the request with your email parameters. You will receive a 402 Payment Required response with a Lightning invoice for 200 sats.

Request body:

{
  "to": "recipient@example.com",
  "subject": "Your order has shipped",
  "body": "Hi,\n\nYour order #12345 has shipped and will arrive in 3-5 business days.\n\nThank you.",
  "replyTo": "support@yourapp.com"
}

Example curl command:

curl -X POST https://sats4ai.com/api/l402/email \
-H "Content-Type: application/json" \
-d '{"to":"recipient@example.com","subject":"Your order has shipped","body":"Hi, your order has shipped.","replyTo":"support@yourapp.com"}' \
-i

Expected response headers:

www-authenticate: L402 macaroon="<YOUR_MACAROON>", invoice="<LIGHTNING_INVOICE>"

Step 2: Pay the Lightning Invoice

Pay the 300-sat invoice with any Lightning wallet (Phoenix, Muun, Alby, Wallet of Satoshi, etc.). Save the preimage your wallet provides after payment.

Step 3: Re-send with Payment Proof

Send the exact same request again with the Authorization header.

The JSON payload must be identical to Step 1.

curl -X POST https://sats4ai.com/api/l402/email \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON>:<YOUR_PREIMAGE>" \
-d '{"to":"recipient@example.com","subject":"Your order has shipped","body":"Hi, your order has shipped.","replyTo":"support@yourapp.com"}'

Successful response: {"success": true, "message": "Email sent successfully"}

Easier: Use lnget

lnget POST https://sats4ai.com/api/l402/email \
  --json '{"to":"recipient@example.com","subject":"Hello","body":"Message body here"}'

Python Example

import requests

# Step 1 — get invoice
r = requests.post("https://sats4ai.com/api/l402/email",
    json={"to": "recipient@example.com", "subject": "Hello", "body": "Message body"},
    headers={"Content-Type": "application/json"})
# r.status_code == 402
# Parse macaroon and invoice from r.headers["www-authenticate"]

# Step 2 — pay invoice with your Lightning wallet, get preimage

# Step 3 — re-send with auth
r2 = requests.post("https://sats4ai.com/api/l402/email",
    json={"to": "recipient@example.com", "subject": "Hello", "body": "Message body"},
    headers={
        "Content-Type": "application/json",
        "Authorization": "L402 <macaroon>:<preimage>"
    })
print(r2.json())  # {"success": true, "message": "Email sent successfully"}

Request Parameters

to: string required

Recipient email address. Must be a valid email format.

subject: string required

Email subject line. Max 200 characters.

body: string required

Plain text email body. Max 10,000 characters. A footer is automatically appended. HTML is not supported — plain text only.

replyTo: string (optional)

Reply-to email address. If the recipient replies, their response goes to this address. Since the email is sent from our relay address, include this field if you want to receive replies.

Use Cases

  • Agent sends a notification email without setting up an email provider account
  • Server alert when your monitoring script detects an issue — no SendGrid account needed
  • One-time contact form submission to an email address
  • Test email delivery without provisioning an SMTP account
  • Occasional transactional email from a script or prototype