InterfacesAPI SpecSections
API Spec Designed
Base address: https://01scale.com/api/payment/v1. Open an endpoint for its inputs, constraints, errors and samples.
POST/ordersCreate an order and a checkout page
An app's server asks for payment for something it sells, acting for the user who will pay. Payment records an order and returns the address of Stripe's checkout page. Only a delegated token is accepted (an app acting for a user, with `act`), so a browser session can never set a price. Service
Scope: payment:write, on a delegated token only
Inputs
Authorizationheaderstringrequired- The user who will pay is the token's
sub; the app is itsappclaim. Bearer <delegated token>withpayment:writeandact.referencebodystringrequired- What is being paid for, in the app's own terms. DocFlow sends
docflow:{document_id}. - 1 to 200 characters; unique per app while an order is open or paid.
descriptionbodystringrequired- What the person sees on the checkout page and the receipt.
- 1 to 200 characters.
amountbodyintegerrequired- The price, set by the app's server. $0.50 is Stripe's smallest charge in USD.
- 50 to 100,000 minor units (cents), so $0.50 to $1,000.
currencybodystringrequired- The currency, as an ISO 4217 code.
- In version 1,
USD. success_url, cancel_urlbodystringrequired- Where Stripe sends the person afterwards.
{ORDER_ID}in the address is replaced with the order's ID. - HTTPS addresses on 01scale.com (or localhost in development).
What it does
- If the app already has a
paidorder for this reference, refuses with409 already_paid. - If it has a
pendingorder whose checkout page is still open, returns that order with200: no second order, no second page. - Otherwise records an order as
pendingand creates a Stripe Checkout session in test mode with the order's ID asclient_reference_idand inmetadata.order_id, using the order's ID as Stripe's idempotency key. - The checkout page stays open for 1 hour, then Stripe expires it.
- Records
order.createdin the audit log.
Responses
- 201A new order was created.
orderandcheckout_url. - 200An open order for this reference already existed. That
orderand itscheckout_url. - 409
already_paidThis reference is already paid;order_idnames the paid order. - 422
validation_failedAn input is missing or out of range;errors[]lists each. - 403
service_onlyThe token is not a delegated token: a browser session, an API key or a service acting as itself. - 503
stripe_unavailableStripe could not be reached. Nothing was charged; safe to retry.
Sample request
POST /api/payment/v1/orders HTTP/1.1
Authorization: Bearer <delegated token: the user, act service:docflow>
Content-Type: application/json
{
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"description": "Invoice extraction: acme-invoice-0042.pdf",
"amount": 500,
"currency": "USD",
"success_url": "https://01scale.com/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/success?order={ORDER_ID}",
"cancel_url": "https://01scale.com/documents/0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c/pay?cancelled=1"
}Sample response
{
"order": {
"id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"app": "docflow",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"description": "Invoice extraction: acme-invoice-0042.pdf",
"amount": 500,
"currency": "USD",
"status": "pending",
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4e5F6g7H8i9J0exampleSession#fidkdWxOYHwnPyd1blpxYHZxWjA0example",
"checkout_expires_at": "2026-11-17T10:16:10Z",
"paid_at": null,
"created_at": "2026-11-17T09:16:10Z"
},
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4e5F6g7H8i9J0exampleSession#fidkdWxOYHwnPyd1blpxYHZxWjA0example"
}POST/webhooks/stripeReceive Stripe's events
Stripe tells Payment what happened on its checkout page. This, not the browser, is what marks an order paid. Service
Scope: None: Stripe signature
Inputs
Stripe-Signatureheaderstringrequired- Proves the event came from Stripe and is not a replay.
- Verified against the raw body with the webhook signing secret, rejecting timestamps older than 5 minutes.
(body)bodyStripe eventrequired- The event.
- Read as raw bytes for the signature check, then parsed.
What it does
- Records the event's ID first; if it was already recorded, answers
200and changes nothing. checkout.session.completedwithpayment_status: paid: the order becomespaidwithpaid_at; recordsorder.paid; announcespayment.order.paid.checkout.session.expired: apendingorder becomesexpired; announcespayment.order.expired.checkout.session.async_payment_failed: the order becomesfailed; announcespayment.order.failed.- Any other event type is recorded and ignored.
- An order that is already
paidnever goes back to another status.
Responses
- 200Accepted, including a repeat or an ignored type. No body.
- 400
invalid_stripe_signatureStripe's signature is missing, wrong or too old.
Sample request
POST /api/payment/v1/webhooks/stripe HTTP/1.1
Stripe-Signature: t=1794826622,v1=5257a869e7ec...
Content-Type: application/json
{
"id": "evt_test_1Q2w3E4r5T6y",
"type": "checkout.session.completed",
"data": {
"object": {
"id": "cs_test_a1B2c3D4e5F6g7H8i9J0exampleSession",
"client_reference_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"payment_status": "paid",
"metadata": {
"order_id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f"
}
}
}
}Sample response
HTTP/1.1 200 OKGET/orders/{orderId}Get one order
An order and its status. The success page polls it until the payment is confirmed. Signed in
Scope: payment:read
Inputs
orderIdpathuuidrequired- The order.
- A UUID.
What it does
- Read only.
checkout_urlis included only while the order ispendingand its page is open.
Responses
- 200The order is the caller's.
order:id,app,reference,description,amount,currency,status(pending,paid,expired,failed),checkout_url,checkout_expires_at,paid_at,created_at. - 404
order_not_foundNo such order, or it belongs to another user. The same answer in both cases. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/payment/v1/orders/0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"order": {
"id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"app": "docflow",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"description": "Invoice extraction: acme-invoice-0042.pdf",
"amount": 500,
"currency": "USD",
"status": "paid",
"checkout_url": null,
"checkout_expires_at": "2026-11-17T10:16:10Z",
"paid_at": "2026-11-17T09:17:02Z",
"created_at": "2026-11-17T09:16:10Z"
}
}GET/ordersList my orders
The caller's orders, newest first. Used on the account page and to find an order by its reference. Signed in
Scope: payment:read
Inputs
referencequerystringoptional- Only orders for this reference.
- Exact match.
statusquerystringoptional- Only orders with this status.
pending,paid,expiredorfailed.cursor, limitquerystring, integeroptional- Paging.
limit1 to 100, default 20.
What it does
- Read only.
Responses
- 200Always, even when empty.
data[]of orders andnext_cursor. - 422
validation_failedA filter is not valid. - 401
not_authenticatedNo valid access token.
Sample request
GET /api/payment/v1/orders?reference=docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c HTTP/1.1
Host: 01scale.com
Authorization: Bearer <access token>Sample response
{
"data": [
{
"id": "0193b120-5a6b-7c7d-8e8f-9a0b1c2d3e4f",
"app": "docflow",
"reference": "docflow:0193b0c4-91aa-7b33-8c44-5d6e7f8a9b0c",
"description": "Invoice extraction: acme-invoice-0042.pdf",
"amount": 500,
"currency": "USD",
"status": "paid",
"checkout_url": null,
"checkout_expires_at": "2026-11-17T10:16:10Z",
"paid_at": "2026-11-17T09:17:02Z",
"created_at": "2026-11-17T09:16:10Z"
}
],
"next_cursor": null
}POST/eventsReceive platform events
Where other services' signed events arrive. In version 1 Payment acts on one: a user's account was deleted. Service
Scope: None: HMAC signature
Inputs
X-01scale-Signatureheaderstringrequired- Proves the event came from the platform.
- HMAC-SHA256 of the raw body, compared in constant time.
event_id, type, databodyuuid, string, objectrequired- The event.
- Processed once per
event_id; acts onidentity.user.deletedwith{user_id}.
What it does
- Keeps the user's orders as payment records (
IDENTITY-V1-E1-05: orders are kept, anonymized) but removes the link to the person:owner_idbecomes empty.
Responses
- 200Accepted, including a repeat or an ignored type. No body.
- 401
invalid_signatureThe signature is missing or wrong.
Sample request
POST /api/payment/v1/events HTTP/1.1
X-01scale-Signature: sha256=8c1f...
Content-Type: application/json
{
"event_id": "0193b2aa-6f01-7c2d-9e3f-4a5b6c7d8e9f",
"type": "identity.user.deleted",
"occurred_at": "2026-11-17T10:00:00Z",
"data": {
"user_id": "0193a5b2-7c1e-7a3f-9b2d-4e6f8a1c2d3e"
}
}Sample response
HTTP/1.1 200 OKErrors
Every error has the same shape and a stable code to branch on.
{
"type": "https://01scale.com/errors/already_paid",
"title": "Already paid",
"status": 409,
"detail": "This item is already paid for.",
"code": "already_paid",
"request_id": "req_0193a61f9c2e"
}Handled without an endpoint
- Events Payment announces
payment.order.paid,payment.order.expiredandpayment.order.failed, with{order_id, app, reference, amount, currency}, signed and delivered with retries from the outbox to the app that created the order.- The checkout page (PAYMENT-V1-E6-01)
- Stripe's hosted page. 01scale never receives card details.
- DocFlow's checkout endpoint
POST /api/docflow/v1/documents/{documentId}/checkoutbelongs to the DocFlow app, which sets the $5.00 price and callsPOST /ordersfrom its server. Designed with the DocFlow app shell (DOCFLOW-V1-E0-09).- AI agents
- Each read endpoint is a tool on Payment's MCP server,
POST /api/payment/mcp. An agent can receive a checkout address to hand to the person, but can never complete a payment itself. - Health and contract
GET /healthandGET /openapi.jsonfrom the service template (SERVICEKIT-V1-E0-05).
Constraints at the API level
- Only an app's server can create an order; the price is never taken from a browser.
- Amount 50 to 100,000 minor units, in USD; return addresses on 01scale.com only.
- One open or paid order per app and reference: asking again returns the open one or refuses with
already_paid. - Stripe events must carry a valid signature no older than 5 minutes, and are processed once per event ID.
- Another user's order answers
404 order_not_found. - Only test-mode Stripe keys are accepted in version 1.