API reference
Authentication, the Invoice and Payment Link objects, every endpoint with request and response examples, pagination and idempotency.
The FlatCryptoPay API is a small JSON REST API. Every request uses HTTPS and a Bearer API key. The machine-readable spec is at /openapi.json (OpenAPI 3.1).
Base URL and authentication
https://flatcryptopay.com/api/v1
Authorization: Bearer fcp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Keys are created in the dashboard and shown once. We store only a salted SHA-256 hash, so a lost key cannot be recovered: revoke it and create a new one. Keys must stay on your server; the API is not meant to be called from browsers with a secret key.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/v1/invoices | Create an invoice |
GET | /api/v1/invoices | List invoices |
GET | /api/v1/invoices/{id} | Retrieve an invoice |
POST | /api/v1/invoices/{id}/cancel | Cancel an open invoice |
POST | /api/v1/payment_links | Create a payment link |
GET | /api/v1/payment_links | List payment links |
The Invoice object
| Field | Type | Notes |
|---|---|---|
id | string | e.g. inv_8fK2mQ9xLr3TzW1bN0aYc4 |
object | string | |
livemode | boolean | |
status | string | open, processing, paid, expired, canceled |
amount | string | Decimal string, 2 decimals. |
currency | string | USD, EUR, GBP, CAD, AUD |
description | string | null | |
order_id | string | null | Your reference, max 128 characters. |
customer_email | string | null | |
metadata | object | |
hosted_url | string | Send the customer here to pay. |
redirect_url | string | null | |
cancel_url | string | null | |
expires_at | string | |
paid_at | string | null | |
payment | object | null | |
created_at | string |
Invoice statuses
open: waiting for payment.processing: a matching transaction was seen and is waiting for confirmations. Do not ship yet.paid: confirmed. Fulfil the order.expired: no payment beforeexpires_at. A late payment that arrives within 6 hours of the quote still moves it topaidand firesinvoice.paid.canceled: canceled by you via the API or dashboard.
Create an invoice
POST /api/v1/invoices
| Parameter | Required | Description |
|---|---|---|
amount | yes | Decimal string with up to 2 decimals, e.g. "49.00". Max 1,000,000. |
currency | no | USD (default), EUR, GBP, CAD or AUD. Stablecoin amounts are converted at the market rate. |
description | no | Shown to the customer. Max 500 characters. |
order_id | no | Your reference. Max 128 characters. |
customer_email | no | Pre-fills the card checkout receipt email. |
redirect_url | no | Public https URL. The customer is sent here when the invoice is paid. |
cancel_url | no | Public https URL for a "Back to store" link. |
metadata | no | Up to 20 keys; values stored as strings (max 500 characters). Returned in webhooks. |
expires_in | no | Minutes until expiry: 15 to 10080 (7 days). Default 1440. |
const res = await fetch('https://flatcryptopay.com/api/v1/invoices', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.FCP_KEY,
'Content-Type': 'application/json',
'Idempotency-Key': 'order-' + order.id,
},
body: JSON.stringify({ amount: '49.00', currency: 'USD', order_id: String(order.id),
redirect_url: 'https://shop.example/thanks', metadata: { cart: 'c_42' } }),
});
const invoice = await res.json();
redirect(invoice.hosted_url); $ch = curl_init('https://flatcryptopay.com/api/v1/invoices');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('FCP_KEY'),
'Content-Type: application/json',
'Idempotency-Key: order-1001',
],
CURLOPT_POSTFIELDS => json_encode(['amount' => '49.00', 'currency' => 'EUR', 'order_id' => '1001']),
]);
$invoice = json_decode(curl_exec($ch), true);
header('Location: ' . $invoice['hosted_url']); import os, requests
r = requests.post("https://flatcryptopay.com/api/v1/invoices",
headers={"Authorization": f"Bearer {os.environ['FCP_KEY']}", "Idempotency-Key": "order-1001"},
json={"amount": "49.00", "currency": "GBP", "order_id": "1001"}, timeout=20)
r.raise_for_status()
print(r.json()["hosted_url"]) Idempotency
Send an Idempotency-Key header (1 to 128 characters, [A-Za-z0-9._:-]) when creating invoices. If a request with the same key was already processed for your account, the original invoice is returned instead of creating a duplicate. Use your order id or a UUID per checkout attempt.
Retrieve, list and cancel
curl https://flatcryptopay.com/api/v1/invoices/inv_8fK2mQ9xLr3TzW1bN0aYc4 -H "Authorization: Bearer $FCP_KEY"
curl "https://flatcryptopay.com/api/v1/invoices?status=paid&limit=50" -H "Authorization: Bearer $FCP_KEY"
# => { "object": "list", "data": [ ... ], "has_more": true }
# next page: &starting_after=<last id>
curl -X POST https://flatcryptopay.com/api/v1/invoices/inv_8fK2mQ9xLr3TzW1bN0aYc4/cancel -H "Authorization: Bearer $FCP_KEY" Payment links
curl https://flatcryptopay.com/api/v1/payment_links \
-H "Authorization: Bearer $FCP_KEY" -H "Content-Type: application/json" \
-d '{"title":"Consulting hour","amount":"150.00","currency":"USD"}'
# => { "id": "pl_...", "object": "payment_link", "url": "https://flatcryptopay.com/pay/l/consulting-hour-x7k2qa/", ... } Omit amount to let the customer type the amount (donations, tips, custom quotes). See Payment links.
Rate limits
The API allows about 300 requests per minute per key. Exceeding it returns HTTP 429 with a rate_limit_error. See Errors.