Skip to content
Meem Payment

Build reliably

Idempotency and correlation

Networks fail after a request is sent. Send an Idempotency-Key on every money movement so a retry returns the first result instead of charging, capturing or refunding twice.

Using the header

  • Supported on POST /api/v1/payments (authorize and purchase), /{id}/capture, /{id}/void and /{id}/refund. It's a header only; there's no body field.
  • Use a fresh random value (a UUID v4 is ideal) per logical operation, and reuse it only when retrying that same operation.
  • Keys are scoped per merchant and per endpoint, and are kept for at least 24 hours.
  • Leading and trailing spaces are trimmed; an empty header means no idempotency.
curl -X POST "https://api.sandbox.meem-dev.example/api/v1/payments" \
  -H "Authorization: Bearer $MEEM_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "X-Correlation-Id: $(uuidgen)" \
  -d '{
    "amount": 150,
    "currency": "SAR",
    "cardToken": "4000001111112223",
    "cvv": "123",
    "customerCountry": "SA",
    "metadata": {
      "orderRef": "ORDER-1001"
    }
  }'

What happens on a repeat

SituationResponse
First request with the keyProcessed normally.
Same key, same body, first request finishedThe original response (status and body) is returned; nothing is sent to the PSP again.
Same key while the first request is still running409 with code IDEMPOTENCY_IN_PROGRESS. Wait and retry with the same key.
Same key, different body422 with code IDEMPOTENCY_KEY_REUSED. Use a new key for a new request.
{
  "title": "One or more validation errors occurred.",
  "status": 422,
  "detail": "This Idempotency-Key was already used with a different request body. Use a new key for a new request.",
  "code": "IDEMPOTENCY_KEY_REUSED",
  "errors": {}
}

"Same body" is judged on the fields that define the operation. For an authorization: amount, currency, card token, brand, BIN, country, payment method and metadata (the CVV is excluded and never stored). For capture and refund: the payment and the amount. For void: the payment. Reusing a capture key on a different payment is therefore a 422.

Failures and safe retries

  • If a request fails before anything is sent to a PSP, the key is released and you can retry with the same key.
  • If it fails after dispatch, the key stays claimed until the outcome is reconciled, so a retry can never create a second charge.
  • A payment interrupted before it reached any provider reports PROCESSING_INTERRUPTED: no charge was made, and you can retry with a new key.
  • On a timeout, retry with the same key, or read the payment with GET /api/v1/payments/{id} if you already have its id.

Correlation ids

Send X-Correlation-Id with any value you can search for (a UUID works well). Meem echoes it in the X-Correlation-Id response header and in correlationId, passes it to gateway calls, and includes it in webhooks as correlation_id. If you omit it, Meem generates one. Quote it when you contact support.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
X-Correlation-Id: 0b8e5f8a-2f4c-4d6e-8a1b-3c9d7e6f5a21

Documentation reflects the platform as verified on 3 December 2026. Placeholder hosts and credentials are used throughout; your real sandbox host and keys are provided at onboarding.