Skip to content
FlatCryptoPay

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

HTTP
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

MethodPathDescription
POST/api/v1/invoicesCreate an invoice
GET/api/v1/invoicesList invoices
GET/api/v1/invoices/{id}Retrieve an invoice
POST/api/v1/invoices/{id}/cancelCancel an open invoice
POST/api/v1/payment_linksCreate a payment link
GET/api/v1/payment_linksList payment links

The Invoice object

FieldTypeNotes
idstringe.g. inv_8fK2mQ9xLr3TzW1bN0aYc4
objectstring
livemodeboolean
statusstringopen, processing, paid, expired, canceled
amountstringDecimal string, 2 decimals.
currencystringUSD, EUR, GBP, CAD, AUD
descriptionstring | null
order_idstring | nullYour reference, max 128 characters.
customer_emailstring | null
metadataobject
hosted_urlstringSend the customer here to pay.
redirect_urlstring | null
cancel_urlstring | null
expires_atstring
paid_atstring | null
paymentobject | null
created_atstring

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 before expires_at. A late payment that arrives within 6 hours of the quote still moves it to paid and fires invoice.paid.
  • canceled: canceled by you via the API or dashboard.

Create an invoice

POST /api/v1/invoices

ParameterRequiredDescription
amountyesDecimal string with up to 2 decimals, e.g. "49.00". Max 1,000,000.
currencynoUSD (default), EUR, GBP, CAD or AUD. Stablecoin amounts are converted at the market rate.
descriptionnoShown to the customer. Max 500 characters.
order_idnoYour reference. Max 128 characters.
customer_emailnoPre-fills the card checkout receipt email.
redirect_urlnoPublic https URL. The customer is sent here when the invoice is paid.
cancel_urlnoPublic https URL for a "Back to store" link.
metadatanoUp to 20 keys; values stored as strings (max 500 characters). Returned in webhooks.
expires_innoMinutes until expiry: 15 to 10080 (7 days). Default 1440.
Node.js
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);
PHP
$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']);
Python
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
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
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.

Start free: no fees, no documents