CartirraAPI
Get API keys

Core concepts

Idempotency

Retry creates and refunds safely. The same Idempotency-Key always gets the same response, and the action happens once.

Networks fail. If a request to create something times out, you can't tell whether Cartirra received it. An idempotency key makes the retry safe: Cartirra runs the request once and returns the first response to every retry.

curl -X POST https://api.cartirra.com/v1/orders/ord_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b/refunds \
  -H "Authorization: Bearer $CARTIRRA_SECRET_KEY" \
  -H "Idempotency-Key: 6f1c2b7e-1d5a-4c55-9a0e-7d6f3f1b9a10" \
  -H "Content-Type: application/json" \
  -d '{ "amount": { "amount": "2000.00", "currency": "NGN" }, "reason": "Missing item" }'

Which endpoints take one

EndpointIdempotency-Key
POST /v1/orders/{id}/refundsRequired. Refunds move money.
POST /v1/checkout-sessionsRecommended
POST /v1/promotionsRecommended
POST /v1/gift-cardsRecommended

Each endpoint's reference page says whether it takes a key. Reads (GET) don't need one.

Rules

  • A key is 8–255 characters of A–Z a–z 0–9 . _ : -. A UUID v4 is a good choice.
  • Make one key per action, not per attempt: generate it before the first try and reuse it for every retry of that action.
  • Keys are kept for 24 hours and belong to your business and mode.
  • A replay returns the first status and body, with the header Idempotency-Replayed: true.

What you may see

StatusCodeMeaning
400idempotency_key_requiredThis endpoint needs a key and none was sent
400validation_failedThe key isn't 8–255 allowed characters
409idempotency_request_in_progressThe first request with this key is still running. Wait a moment and retry
422idempotency_key_reusedThe key was already used for a different request. Use a new key for a new action

Errors are remembered too: if the first request failed validation, the retry gets the same error. A 5xx is not remembered, so retrying the same key after a server error runs the request again, safely.