Skip to content
StiffProof

Developers

The StiffProof API

Let your own website make invoices, estimates and quotes in your StiffProof account, send your customer the link, and find out when they’ve paid.

What it’s for

Your website’s server creates an invoice, estimate or quote in your StiffProof account. Your customer gets the StiffProof link to view it, accept it, or pay it, and your server reads the document back to see where it stands. Everything the API makes is an ordinary document in your account, there for you in the app too.

The API is part of the paid plan.

Get a key

On your account page, open Developer access and choose Create key. Creating a key needs a sign-in from the last 24 hours. The key is shown once; copy it then. We email you whenever a key is added to your account.

A key has scopes: read (GET requests), write (creating and changing documents and clients) and refund (refunds, which also need write). An account can have up to 10 keys; revoke one at any time and it stops working on its next request.

Keep the key on your server. A request that carries an Origin header, which is any request from a web browser, is refused with browser_not_allowed. Keys start sp_live_ on stiffproof.com; sp_test_ keys work only on a test deployment.

Your first request

Check the key works:

curl https://stiffproof.com/api/v1/me \
  -H "Authorization: Bearer sp_live_..."

The answer names the business, the key’s name and scopes, whether online payments are ready (payments.online), and how many emails your account has sent today. Then create an invoice:

curl https://stiffproof.com/api/v1/documents \
  -H "Authorization: Bearer sp_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-invoice" \
  -d '{
    "type": "invoice",
    "client": { "email": "jo@example.com", "name": "Jo Rivera" },
    "due_date": "2026-11-30",
    "tax_rates": [{ "key": "tx", "name": "Texas sales tax", "rate": "8.25" }],
    "line_items": [
      { "description": "Walnut side table", "quantity": "1",
        "unit_price_minor": 42000, "tax_rates": ["tx"] }
    ],
    "external_reference": "order-1042",
    "expected_total_minor": 45465
  }'

The answer is the document (shortened here):

{
  "object": "document",
  "id": "invoice_0a4ed2b0-…",
  "type": "invoice",
  "number": "INV-0042",
  "status": "sent",
  "payment_status": "unpaid",
  "currency": "USD",
  "totals": { "subtotal_minor": 42000, "tax_minor": 3465,
              "total_minor": 45465, "paid_minor": 0, "balance_minor": 45465, … },
  "external_reference": "order-1042",
  "public_url": "https://stiffproof.com/v/…",
  "pay_url": "https://stiffproof.com/v/…/pay",
  "payable": true,
  "timeline": [ … ],
  "email": { "status": "sent", "to": "jo@example.com" }
}

public_url is the link to give your customer: they view the document there and, when it’s payable, pay it. pay_url goes straight to payment.

Conventions

  • Every endpoint is under https://stiffproof.com/api/v1. Bodies are JSON (Content-Type: application/json, at most 64 KB), field names are snake_case, and a field we don’t know is an error, never ignored.
  • Money is an integer number of cents in fields ending _minor: 2599 is $25.99. A number with a decimal point there is refused.
  • Quantities and percentages are decimal strings, up to 6 decimal places: "2.5", "8.25". Dates are YYYY-MM-DD.
  • Every answer carries a Request-Id header. Quote it if you ask us about a request.

Idempotency-Key

Every POST needs an Idempotency-Key header, up to 255 characters. Make it from your own order id and the action, like order-1042-invoice. We keep it for 7 days. If your request times out, send it again with the same key and the same body: you get the first answer back, with Idempotent-Replayed: true, and nothing is made twice. The same key with a different body is 422 idempotency_key_reused; while the first request is still running it’s 409 idempotency_in_progress, so wait a moment and retry.

Errors

A refusal has an HTTP status and a body like this. param names the field at fault, when there is one.

{
  "error": {
    "type": "invalid_request",
    "code": "invalid_amount",
    "message": "line_items[0].unit_price_minor must be an integer number of cents.",
    "param": "line_items[0].unit_price_minor"
  },
  "request_id": "req_…"
}
Error statuses, types and codes
Statustypecodes
400invalid_requestinvalid_json, unknown_parameter, missing_parameter, invalid_parameter, invalid_amount, invalid_quantity, invalid_percentage, invalid_date, invalid_email, invalid_currency, invalid_url, too_many_lines, invalid_limit, unknown_event
401authenticationmissing_api_key, invalid_api_key, api_key_revoked, wrong_environment
403permissionbrowser_not_allowed, plan_required, insufficient_scope
404not_founddocument_not_found, payment_not_found, client_not_found
409conflictidempotency_in_progress, duplicate_external_reference, invalid_state, has_payments
413 / 415invalid_requestbody_too_large, unsupported_media_type
422invalid_requestidempotency_key_reused, total_mismatch, no_business_profile, checkout_needs_invoice, return_origin_not_allowed, refund_exceeds_payment
429rate_limitedrate_limited (with Retry-After)
503unavailablerate_limiter_unavailable, numbering_busy, payments_unavailable, refunds_unavailable (with Retry-After)
500api_errorinternal

Rate limits

Rate limits
Counted forLimit
Each key120 requests a minute
Each account, all keys600 writes (POSTs) an hour
Each account300 documents created a day
Each account20 refunds an hour
Each account30 webhook resends and test events an hour, on the account page
Each IP address20 failed authentications in 10 minutes

Past a limit you get 429 rate_limited with a Retry-After header in seconds. A request refused this way stores nothing under its Idempotency-Key, so retry it unchanged.

Versioning

The version is in the path. New endpoints, fields, error codes and optional request fields can appear in /api/v1 at any time, so ignore fields you don’t know. A change that would break a working site becomes /api/v2, and /api/v1 keeps working for at least 12 months after it arrives.

Clients

POST /api/v1/clients with email and name (and optional phone, address, notes) finds the saved client with that email, whatever its capitals, or creates one. A client you already saved keeps the name and details you gave it. The answer is a client object with its id and created: true if it was new.

You rarely need this call: a document’s client field does the same find-or-create by email.

Documents

  • POST /api/v1/documents creates and issues an invoice, estimate or quote.
  • GET /api/v1/documents/{id} reads one back.
  • GET /api/v1/documents?external_reference=order-1042 finds yours by your own order id.
  • POST /api/v1/documents/{id}/invoice turns an estimate or quote that is issued or accepted into an invoice, once. Optional: due_date, send_email.
  • POST /api/v1/documents/{id}/void voids a document that has no payment recorded. Optional: reason, kept for you and never shown to your customer.

The API reads and changes only documents the API made, never ones made in the app.

Fields for POST /api/v1/documents
FieldWhat it is
typeRequired. "invoice", "estimate" or "quote".
clientRequired. { "id": "cli_…" } for a saved client, or { "email", "name" } plus optional phone, address and notes to find or create one by email.
currencyA three-letter code. Default "USD".
issue_date, due_dateYYYY-MM-DD. The issue date defaults to today.
tax_ratesUp to 10 of { "key", "name", "rate", "registration"?, "compound"? }. A line names the keys that apply to it.
line_itemsRequired, 1–200 lines of { "description", "quantity"?, "unit"?, "unit_price_minor", "code"?, "discount"?, "tax_rates"? }. Quantity defaults to "1".
shipping{ "description"?, "amount_minor", "tax_rates"? }
discount{ "kind": "percentage", "value": "10" } or { "kind": "fixed", "amount_minor": 500 }, either with an optional description. Lines take the same shape.
notes, terms, payment_termsText: up to 2,000, 4,000 and 100 characters.
custom_fieldsUp to 10 of { "label", "value" }.
external_referenceYour own order id, up to 100 characters. One document of each type per reference.
metadataUp to 20 string values, for your own use. Shown back to you, never to your customer.
send_emailtrue (the default) emails your customer the link from StiffProof; false marks it sent and leaves delivery to you.
expected_total_minorThe total your site worked out. If ours differs, nothing is created and you get 422 total_mismatch with our figures.
look_from_document_idAn issued document whose business details and look to copy. Default: your latest issued document.
presentation, return_urlFor checkout pages, coming soon (see below).

A document answer has id, type, number, status, payment_status, currency, the dates, client, line_items, totals, external_reference, metadata, public_url, pay_url, payable, converted_to / converted_from, payments and a timeline of what has happened to it. Creating one also answers email: whether the link was sent, and if not, why.

What the API can’t do: make drafts, edit a document once it’s issued, or make a receipt. A receipt is made for you, automatically, when an invoice is paid.

Checkout pagesComing

A checkout layout for invoices, built to look like the last step of your own site’s order, with a link back to it, is on its way. Until then every document uses the standard StiffProof page.

Payments and refunds

Your customer pays by card or from their bank account through Stripe, straight into your own Stripe account. The fees are Stripe’s rate plus ours, set out on Get paid. A document is marked paid only when Stripe confirms the payment; its payments list and totals.paid_minor show it.

POST /api/v1/payments/{id}/refunds refunds an online payment on a document the API made, using the payment’s id from that list. It needs the refund scope. Send amount_minor for part of it, or nothing for everything still refundable, and optionally a reason: requested_by_customer, duplicate or fraudulent.

We ask Stripe for the refund at once and answer with a refund object. The document shows the refund only once Stripe confirms it, usually within seconds, and our fee on the refunded part is refunded to you then. Up to 20 refunds an hour per account.

Webhooks

A webhook is a request we send to your server when something happens to a document the API made, so your site hears about it without asking. Each one is signed, so your site can check it came from us (see the next section).

Add an endpoint

On your account page, open Webhooks, type your server’s address and choose Add endpoint. Adding one needs a sign-in from the last 24 hours, and we email you when one is added. The address must be https:// on the standard port, with a domain name rather than an IP address; addresses inside a private network are refused. Pick all events or only some. An account can have up to 5 endpoints.

When you add it we send a ping event at once and show whether your server answered. The endpoint is saved either way; fix your server and use Send test event. A ping is never stored and never appears in GET /api/v1/events.

Events

Webhook event types
typeWhen
document.viewedYour customer opened the document’s link.
document.acceptedThe estimate or quote was accepted. data.by is "client" (your customer) or "issuer" (you, in the app).
document.declinedThe estimate or quote was declined. data.by as above.
document.voidedThe document was voided.
payment.succeededStripe confirmed an online payment. A bank (ACH) payment counts once it has settled, a few days after your customer pays. data.payment is the payment.
payment.refundedStripe confirmed a refund. data.refund has its id, amount_minor and payment_id; data.payment shows the payment after it.

A payment event is sent only after Stripe has confirmed the payment to us, never because a customer reached a “thank you” page. Only documents the API made send events.

Every event is a POST with a JSON body like this. data.document is the document as GET /api/v1/documents/{id} showed it when the event was recorded, without its timeline. If the event would be bigger than 64 KB, its line items are left out (line_items: null, line_items_omitted: true); the totals stay.

{
  "id": "evt_3f1c…",
  "type": "payment.succeeded",
  "created_at": "2026-11-02T15:04:05.000Z",
  "api_version": "v1",
  "data": {
    "document": { "object": "document", "id": "invoice_0a4ed2b0-…",
                  "payment_status": "paid", "external_reference": "order-1042", … },
    "payment": { "id": "pay_pi_…", "amount_minor": 45465, "method": "card",
                 "status": "succeeded", "refunded_minor": 0 }
  }
}

Answering, retries and dead letters

  • Answer with any 2xx status within 10 seconds. Anything else counts as a failure: another status, a timeout, a refused connection, or a redirect, which we never follow.
  • A failed event is tried again after about 1, 2, 4, 8, 16, 24 and 24 hours: 8 attempts over about 3 days. After the eighth it is a dead letter: we stop, and email you once a day at most.
  • If an endpoint has accepted nothing for 3 days and has failed at least 10 times, we turn it off and email you. Turning an endpoint off, by us or by you, cancels its pending retries.
  • Recent deliveries on the account page lists the last 30 days of attempts: when, the HTTP status, and the start of your server’s answer. Resend sends one again (a dead letter too), and Resend all failed sends every failed one and every dead letter again.

Twice, or out of order

We send each event at least once, so the same event can arrive twice: the webhook-id header and the event’s id stay the same every time, so skip an id you have already handled. Events usually arrive in the order they happened, but a retry can land after a newer event; when the order matters, compare data.document with what you have, or read the document fresh.

Catching up: GET /api/v1/events

GET /api/v1/events (the read scope) lists your account’s events from the last 30 days, oldest first, as { "object": "list", "data": [ … ], "has_more": … }; each item is exactly the body we send. limit is 1 to 100 (default 50). Pass the last id you have as after to get the ones after it; an id we don’t have answers 400 unknown_event, so start again without after. This works with or without an endpoint, so a site that was down can catch up.

Verifying signatures

Every webhook carries three headers, following the Standard Webhooks scheme:

  • webhook-id: the event’s id.
  • webhook-timestamp: when this attempt was sent, in Unix seconds.
  • webhook-signature: v1, followed by the base64 HMAC-SHA256, keyed with your endpoint’s secret, of id.timestamp.body. During a secret rotation there are two, separated by a space.

The secret starts whsec_; the rest is the base64 key. See it with Reveal secret on the account page (a sign-in from the last 24 hours needed) and keep it on your server. Rotate secret makes a new one; for the next 24 hours we sign with both, so switch your server over within that day.

Check the signature against the raw body before you parse it, refuse a timestamp more than 5 minutes from now, and compare in constant time. In a Next.js route handler:

// app/api/stiffproof-webhook/route.ts
import { createHmac, timingSafeEqual } from 'node:crypto';

// The secret from your StiffProof account page, kept in an environment variable.
const SECRET = Buffer.from(process.env.STIFFPROOF_WEBHOOK_SECRET!.replace(/^whsec_/, ''), 'base64');
const TOLERANCE_SECONDS = 5 * 60;

export async function POST(request: Request) {
  const id = request.headers.get('webhook-id');
  const timestamp = request.headers.get('webhook-timestamp');
  const signatures = request.headers.get('webhook-signature');
  const body = await request.text(); // the raw body: parse it only after the check
  if (!id || !timestamp || !signatures) return new Response('missing headers', { status: 400 });

  const age = Math.abs(Date.now() / 1000 - Number(timestamp));
  if (!Number.isFinite(age) || age > TOLERANCE_SECONDS) {
    return new Response('stale', { status: 400 });
  }

  const expected = createHmac('sha256', SECRET).update(`${id}.${timestamp}.${body}`).digest();
  const valid = signatures.split(' ').some((part) => {
    const [version, value] = part.split(',');
    if (version !== 'v1' || !value) return false;
    const given = Buffer.from(value, 'base64');
    return given.length === expected.length && timingSafeEqual(given, expected);
  });
  if (!valid) return new Response('bad signature', { status: 400 });

  const event = JSON.parse(body);
  // Already handled this event id? Answer 200 and stop: we may send it twice.
  // Otherwise record it, then answer quickly; do slow work afterwards.
  if (event.type === 'payment.succeeded') {
    // e.g. mark order event.data.document.external_reference as paid
  }
  return new Response(null, { status: 204 });
}

Answer 2xx quickly, then do slow work: a request still running after 10 seconds counts as a failure and is sent again.

A full example

A workshop that sells made-to-order furniture from its own website:

  1. A customer asks for a dining table. The shop’s server creates a quote for them: POST /api/v1/documents with "type": "quote" and "external_reference": "order-1042". StiffProof emails the customer the link.
  2. The customer opens the link and accepts the quote.
  3. The shop’s server sees it accepted (GET /api/v1/documents?external_reference=order-1042) and turns it into an invoice: POST /api/v1/documents/{id}/invoice.
  4. The customer pays the invoice on its StiffProof page.
  5. The shop’s server reads the invoice (GET /api/v1/documents/{id}), sees payment_status is paid, and starts building the table.

Changelog

2026-11 — Webhooks, signed, with retries and dead letters, and GET /api/v1/events.

2026-10-30 — /api/v1 first released: keys, clients, documents and refunds.