How do I make my first API call?
Replace $FLAXXA_KEY with a key from your workspace. The first call returns a real id you can use for the next ones.
curl -X POST https://flaxxa.com/api/v1/mails/send \
-H "Authorization: Bearer flx_live_YOUR_KEY" \
-H "Accept: application/json" -H "Content-Type: application/json" \
-d '{
"account_id": 12,
"to": [{ "email": "[email protected]", "name": "Asha Verma" }],
"subject": "Your proposal is ready",
"body_html": "<p>Hi Asha, the proposal is attached.</p>",
"attachments": [{ "filename": "Proposal.pdf", "mime": "application/pdf", "size_bytes": 48211,
"storage_disk": "r2", "storage_key": "mails/…/outbound/…-Proposal.pdf" }]
}'$h = Http::withToken(env('FLAXXA_MAILS_KEY'))->acceptJson();
// 1. upload the attachment (multipart), 2. send from the connected account
$file = $h->attach('file', file_get_contents($pdfPath), 'Proposal.pdf')
->post('https://flaxxa.com/api/v1/mails/attachments')->throw()->json('data');
$sent = $h->post('https://flaxxa.com/api/v1/mails/send', [
'account_id' => 12,
'to' => [['email' => $customer->email, 'name' => $customer->name]],
'subject' => "Proposal #{$proposal->id}",
'body_html' => view('mail.proposal', compact('proposal'))->render(),
'attachments' => [$file],
])->throw()->json('data'); // $sent['id'], $sent['status'] === 'pending' (undo window), then 'sent'const res = await fetch("https://flaxxa.com/api/v1/mails/send", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.FLAXXA_MAILS_KEY}`, Accept: "application/json", "Content-Type": "application/json" },
body: JSON.stringify({
account_id: 12,
to: [{ email: "[email protected]" }],
subject: "Your proposal is ready",
body_text: "Hi Asha, the proposal is attached.",
scheduled_for: "2026-11-01T09:00:00+05:30", // optional: send later
}),
});
const { data } = await res.json(); // data.id, data.statusimport requests
r = requests.post("https://flaxxa.com/api/v1/mails/send",
headers={"Authorization": f"Bearer {KEY}", "Accept": "application/json"},
json={"account_id": 12, "to": [{"email": "[email protected]"}],
"subject": "Your proposal is ready", "body_html": "<p>Hi Asha…</p>"})
r.raise_for_status()
queued = r.json()["data"] # id, status, undo_window_secondsPOST /api/v1/mails/send HTTP/1.1
Host: flaxxa.com
Authorization: Bearer flx_live_·············
Content-Type: application/json
Idempotency-Key: proposal-42-mail
{
"account_id": 12,
"to": [{ "email": "[email protected]", "name": "Asha Verma" }],
"cc": [{ "email": "[email protected]" }],
"subject": "Your proposal is ready",
"body_html": "<p>Hi Asha, the proposal is attached.</p>",
"attachments": [{ "filename": "Proposal.pdf", "mime": "application/pdf", "size_bytes": 48211,
"storage_disk": "r2", "storage_key": "mails/…/outbound/…-Proposal.pdf" }]
}HTTP/1.1 201 Created
Content-Type: application/json
{
"data": {
"id": 9041,
"status": "pending",
"account_id": 12,
"subject": "Your proposal is ready",
"to": [{ "email": "[email protected]", "name": "Asha Verma" }],
"scheduled_for": null,
"undo_window_seconds": 10
}
}
