API ReferenceEndpointsPublic API (v1)Complete checkout and create order

Complete checkout and create order

Requires Idempotency-Key header, because this is the most critical endpoint to retry safely. Without an idempotency key, a network timeout during card capture can produce two orders. See /docs/api/idempotency.

POST
/v1/checkout/{checkoutId}/complete
AuthorizationBearer <token>

Admin API key (server-to-server). Issue via the dashboard at Settings → API keys. Plain-text key is shown once — store in a secret manager. Format: Authorization: Bearer brainerce_xxxxxxxxx.

In: header

Path Parameters

checkoutIdstring

Checkout ID

Header Parameters

Idempotency-Keystring

REQUIRED on this endpoint — it moves money, so an omitted key is refused with a 400 rather than risking a double charge on retry.

Because the key is mandatory here, this endpoint also fails closed: if the once-only lock cannot be taken (the lock store is unreachable) the request is refused with 503 Service Unavailable and code: "IDEMPOTENCY_LOCK_UNAVAILABLE", and nothing is processed — no order, no charge. Retry with the same key after a short backoff; do NOT generate a new one, and do not confuse this with IDEMPOTENCY_KEY_REUSED, which is a 409 telling you the opposite.

Client-supplied key (a UUID v4 is the recommended form, max 255 characters) that makes this mutation safe to retry.

  • Replay window: 24 hours. The first response for a key is cached; a retry inside the window with the same request body returns the original status and body without re-running the handler.
  • Reusing a key with a different body returns 409 Conflict with code: "IDEMPOTENCY_KEY_REUSED". The request fingerprint (method + path + body hash) is compared against the stored one; a mismatch is refused rather than served the old response.
  • Keys are scoped to the calling credential and store — two API keys may safely use the same key value.
  • Error responses are cached too, so a retry of a request that failed validation returns the same 400 immediately.
  • Sending this header on a GET returns 400 with code: "IDEMPOTENCY_KEY_NOT_SUPPORTED" — GETs are already idempotent.
  • Support is per-route and this parameter is the authoritative signal: a key sent to a route that does not declare it is accepted and silently ignored.

See /docs/api/idempotency.

Lengthlength <= 255
curl -X POST "https://api.brainerce.com/api/v1/checkout/string/complete" \  -H "Idempotency-Key: string"
{
  "orderId": "clx1a2b3c4d5e6f7g8h9",
  "orderNumber": "ORD-20260115-0042",
  "status": "PENDING",
  "total": "46.96",
  "message": "Order created"
}

{
  "statusCode": 400,
  "code": "VALIDATION_FAILED",
  "message": "name should not be empty, price must be a positive number",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}

{
  "statusCode": 401,
  "code": "UNAUTHORIZED",
  "message": "Invalid or expired credential",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}

{
  "statusCode": 403,
  "code": "INSUFFICIENT_SCOPE",
  "message": "API key does not have the required scope: products:write",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}

{
  "statusCode": 404,
  "code": "RESOURCE_NOT_FOUND",
  "message": "Resource not found",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}

{
  "statusCode": 409,
  "code": "CONFLICT",
  "message": "The request conflicts with the current state of the resource",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}

{
  "statusCode": 429,
  "code": "RATE_LIMITED",
  "message": "Too many requests",
  "details": {
    "retryAfterSeconds": 12
  },
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/store"
}

{
  "statusCode": 503,
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error",
  "timestamp": "2026-08-23T10:15:00.000Z",
  "path": "/api/v1/checkout/{checkoutId}/complete"
}