LettrLabs API
API ReferenceOrders

Execute an order checkout

Submits an order for production with the supplied postage type, production speed, and optional hold-until date, and accepts it for payment. Payment settles asynchronously, so a 200 means the checkout was ACCEPTED, not that the order has been charged: the response reports the order's resulting status in "orderStatus", when to start polling in "pollAfterSeconds", and when settlement is expected to have reached a terminal state in "settlementExpectedWithinSeconds" — size your polling from those rather than a bound of your own. On acceptance the order moves to "Payment Needed" immediately and stops being editable: recipient changes, order deletion, and further checkouts return 400 while payment settles. The order then reads "Paid" once settlement completes, or returns to "Draft" if payment fails (retry by checking out again). Never retry a checkout that returned 200 — the charge is already in flight, and a second checkout charges again.

POST
/v1/order/{id}/checkout

Submits an order for production with the supplied postage type, production speed, and optional hold-until date, and accepts it for payment. Payment settles asynchronously, so a 200 means the checkout was ACCEPTED, not that the order has been charged: the response reports the order's resulting status in "orderStatus", when to start polling in "pollAfterSeconds", and when settlement is expected to have reached a terminal state in "settlementExpectedWithinSeconds" — size your polling from those rather than a bound of your own. On acceptance the order moves to "Payment Needed" immediately and stops being editable: recipient changes, order deletion, and further checkouts return 400 while payment settles. The order then reads "Paid" once settlement completes, or returns to "Draft" if payment fails (retry by checking out again). Never retry a checkout that returned 200 — the charge is already in flight, and a second checkout charges again.

X-API-KEY<token>

In: header

Path Parameters

id*integer

The Id of the order to execute checkout and finalize the transaction.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

postageType*string

Postage class for the order. Standard is bundled into the base price; FirstClass adds a per-piece surcharge. These two are the only accepted values — HailTrace appears on storm-order responses but is not accepted here.

productionSpeed*string

How fast the order goes through production. Expedited speeds cost more; the surcharge appears on the checkout quote. These three are the only accepted values — HailTrace is an internal storm-order priority that parses but is then rejected here.

holdUntilDate?|

Optional date to hold the order until before it enters production, as a date-time. Must be later than the estimated production completion date returned by the checkout preview. Omit or send null to submit for production immediately.

autoBill?boolean

Controls whether checkout may charge the account's default payment method for any amount not covered by the available account balance. true (the default) applies any available balance first, then charges the default payment method for the remaining shortfall. false requires the available balance to cover the order in full: if it does not, the checkout is rejected with HTTP 402 Payment Required and error code INSUFFICIENT_BALANCE, and no charge is made and no balance is deducted. Omitting the field is equivalent to true.

Response Body

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/order/0/checkout" \  -H "Content-Type: application/json" \  -d '{    "postageType": "FirstClass",    "productionSpeed": "Normal"  }'
{  "profile": {    "id": 0,    "aadId": "1cbad290-069a-4527-be23-a0c144b5302d",    "email": "string",    "firstName": "string",    "lastName": "string",    "company": "string",    "created": "2019-08-24T14:15:22Z",    "shouldProcessQrCodes": true  },  "payload": {    "orderId": 0,    "status": "Success",    "orderStatus": "Payment Needed",    "pollAfterSeconds": 60,    "settlementExpectedWithinSeconds": 240  },  "errorCode": "UNAUTHENTICATED",  "errors": [    "string"  ],  "hasErrors": true,  "warnings": [    "string"  ],  "hasWarnings": true,  "errorDetails": [    null  ],  "metadata": {    "property1": null,    "property2": null  }}
{  "profile": {    "id": 0,    "aadId": "1cbad290-069a-4527-be23-a0c144b5302d",    "email": "string",    "firstName": "string",    "lastName": "string",    "company": "string",    "created": "2019-08-24T14:15:22Z",    "shouldProcessQrCodes": true  },  "payload": {    "orderId": 0,    "status": "Success",    "orderStatus": "Payment Needed",    "pollAfterSeconds": 60,    "settlementExpectedWithinSeconds": 240  },  "errorCode": "UNAUTHENTICATED",  "errors": [    "string"  ],  "hasErrors": true,  "warnings": [    "string"  ],  "hasWarnings": true,  "errorDetails": [    null  ],  "metadata": {    "property1": null,    "property2": null  }}
{  "profile": {    "id": 0,    "aadId": "1cbad290-069a-4527-be23-a0c144b5302d",    "email": "string",    "firstName": "string",    "lastName": "string",    "company": "string",    "created": "2019-08-24T14:15:22Z",    "shouldProcessQrCodes": true  },  "payload": {    "orderId": 0,    "status": "Success",    "orderStatus": "Payment Needed",    "pollAfterSeconds": 60,    "settlementExpectedWithinSeconds": 240  },  "errorCode": "UNAUTHENTICATED",  "errors": [    "string"  ],  "hasErrors": true,  "warnings": [    "string"  ],  "hasWarnings": true,  "errorDetails": [    null  ],  "metadata": {    "property1": null,    "property2": null  }}
{  "profile": {    "id": 0,    "aadId": "1cbad290-069a-4527-be23-a0c144b5302d",    "email": "string",    "firstName": "string",    "lastName": "string",    "company": "string",    "created": "2019-08-24T14:15:22Z",    "shouldProcessQrCodes": true  },  "payload": {    "orderId": 0,    "status": "Success",    "orderStatus": "Payment Needed",    "pollAfterSeconds": 60,    "settlementExpectedWithinSeconds": 240  },  "errorCode": "UNAUTHENTICATED",  "errors": [    "string"  ],  "hasErrors": true,  "warnings": [    "string"  ],  "hasWarnings": true,  "errorDetails": [    null  ],  "metadata": {    "property1": null,    "property2": null  }}
Empty
{  "profile": {    "id": 0,    "aadId": "1cbad290-069a-4527-be23-a0c144b5302d",    "email": "string",    "firstName": "string",    "lastName": "string",    "company": "string",    "created": "2019-08-24T14:15:22Z",    "shouldProcessQrCodes": true  },  "payload": {    "orderId": 0,    "status": "Success",    "orderStatus": "Payment Needed",    "pollAfterSeconds": 60,    "settlementExpectedWithinSeconds": 240  },  "errorCode": "UNAUTHENTICATED",  "errors": [    "string"  ],  "hasErrors": true,  "warnings": [    "string"  ],  "hasWarnings": true,  "errorDetails": [    null  ],  "metadata": {    "property1": null,    "property2": null  }}