Skip to content
cresvaDevelopers

Complete the session and get a link for the buyer to pay

POST/api/storefront/{brandId}/checkout/sessions/{sessionId}/complete
Secret keySend an sk_live_ key. Server side only.300 requests a minute

Creates a draft order on the merchant's own store and returns `payment.invoice_url`. HAND THAT URL TO THE SHOPPER AND NEVER FETCH IT SERVER SIDE: opening it on the shopper's behalf is the step that turns an assistant into a purchaser. Cresva never follows it either. A null invoice_url is a real answer, not a missing field: no payable link was issued, so nothing was ordered and there is nothing to retry.

Parameters

brandIdstring · pathrequiredThe storefront's brand id. There is no public endpoint that maps a domain to a brand id; ask the merchant for their storefront URL, the id is in it.
sessionIdstring · pathrequiredThe session id.

Request

bash
BRAND_ID=cmqmr1f6j0003la04nu93f4k4
curl -X POST "https://cresva.ai/api/storefront/$BRAND_ID/checkout/sessions/{sessionId}/complete" \
  -H "Authorization: Bearer $CRESVA_SECRET_KEY"

Response

No captured response. This operation needs a key. A captured response would mean either printing a real merchant's credential or printing a redacted command nobody can run.

The response schema below is the contract. It comes from the same document the router is checked against, so it is what the endpoint returns even though nobody has printed one here.

Response codes

200The order had already been placed. Same body, `alreadyPlaced: true`.

No body.

201The order was placed on the merchant's store.
orderobject
shopifyOrderIdstring or null
draftOrderIdstring
namestring
financialStatusstringRead back from the merchant's store rather than asserted. It is `pending` here and should be: reporting `paid` would be a lie a merchant would find when they tried to fulfil.
alreadyPlacedboolean
paymentobject
takenboolean, one of falsePermanently false. It answers whether CRESVA took payment.
methodstring, one of merchant_checkout
invoice_urlstring or null, uri
notestring
status_urlstring
401The key does not match any active key.
erroranyTwo shapes exist across this API and that is deliberate rather than untidy. Each route kept the error shape it already used, so an existing client's error handling keeps working. See x-cresva-error-shapes.
403Either the key belongs to a different brand, or this store is not accepting this verb. Lever refusal message: "This store is not accepting agent checkout." Machine-readable code where the route carries one: "levers_not_enabled" A refusal here is about the MERCHANT'S configuration, not about our pricing, and there is more than one reason for it. See x-cresva-refusal-reasons.
erroranyTwo shapes exist across this API and that is deliberate rather than untidy. Each route kept the error shape it already used, so an existing client's error handling keeps working. See x-cresva-error-shapes.
404No such brand.
erroranyTwo shapes exist across this API and that is deliberate rather than untidy. Each route kept the error shape it already used, so an existing client's error handling keeps working. See x-cresva-error-shapes.
429Over the rate limit.
erroranyTwo shapes exist across this API and that is deliberate rather than untidy. Each route kept the error shape it already used, so an existing client's error handling keeps working. See x-cresva-error-shapes.
503The rate limiter could not be reached, so the request was refused rather than served unmetered. Deliberately not a 429: the caller has done nothing wrong and the fault is ours.
erroranyTwo shapes exist across this API and that is deliberate rather than untidy. Each route kept the error shape it already used, so an existing client's error handling keeps working. See x-cresva-error-shapes.

Generated from the storefront OpenAPI document at growthagents 269d7898b, sha256 047fe4d301258100. Nothing on this page was typed by hand.