Capturia measures its ads and site traffic with the Meta pixel and Google Analytics. You can decline at any time. Learn more

FR

Purchases

2 endpoints

post/v1/purchases

Record a purchase made outside Capturia

A store, a course platform or a backend sends a purchase made on its side. Capturia resolves the buyer the same way as an event (external_id → phone → email, contact created if needed), records the purchase on the contact (customer of this offer since the purchase date), files the purchase in its offer's deal and moves the card of the current deal to the won stage. The purchase also starts the "Payment received" automations, the "Purchase completed" gateway of your systems and the "Custom event" automations listening to the purchase event, recorded on the contact.

Idempotency

A purchase is unique by its external_id: sent again with the same offer, amount and currency, the response returns the purchase already recorded (200, created: false) without restarting anything; sent with another offer, amount or currency, it is rejected (409 purchase_conflict). The Idempotency-Key header remains available for retries.

Availability

Online sales must be open for the account, otherwise 403 feature_not_available. An archived contact rejects the purchase (422 contact_archived): restore it, then send the purchase again.

Past purchases

A purchase dated (purchased_at) more than two days ago, for example when importing a sales history, is recorded on the contact and in its offer's deal, and the purchase event is recorded; but it is not a sale of the day: neither the "Payment received" automations, nor the "Purchase completed" gateway, nor the "New sale" bell start for it.

The purchased offer

offer.id identifies a Capturia offer by its identifier (copied in API keys, "Your offer identifiers" section): the purchase reaches this offer and its after-purchase program. offer.key identifies the offer by its key in the source system: on the first purchase with this key, an offer is created under it, named by offer.name.

sms_consent carries the box the buyer checked on the order. true records it as express consent on their contact, with the proof of this request: if the offer has an after-purchase program, its text agent can write first, even without a conversation with the buyer. Without it, the program writes to them by email. The key attests this consent: it then also carries the leads:capture scope and up-to-date API terms.

Body of a GoHighLevel workflow

The Webhook action of a GoHighLevel workflow can send the purchase as is: its "Custom Data" pairs (in customData) carry the purchase, and the contact data it sends on its own identifies the buyer (ExternalPurchaseConnectorPayload). The response then names in ignored_fields the pairs the purchase didn't read.

Required scopes: events:ingest

Headers

NameTypeRequiredDescription
Idempotency-KeystringoptionalIdempotency key: 16 to 128 [A-Za-z0-9_-] characters (a UUID v4 or a ULID works). A key of any other shape is refused with 400 invalid_request (details.field: idempotency-key); an empty header counts as a request without a key. A second request with the same key and the same payload returns the original response, with the Idempotency-Replayed: true header, without repeating the operation; the same key with a different payload is refused with 409 idempotency_conflict. Stored for 24 h. Optional but recommended.

Request body

No description.

Responses

StatusDescription
200

Purchase already received under this external_id, returned as is.

201

Purchase recorded.

400

Invalid request. code tells apart the refusals the operation returns under this status, and each example shows one.

invalid_request
{
  "error": {
    "type": "validation_error",
    "code": "invalid_request",
    "message": "Request format is invalid.",
    "hint": "Check that headers, body and JSON encoding match the API contract documented in the API Reference.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_request",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_encoding
{
  "error": {
    "type": "validation_error",
    "code": "invalid_encoding",
    "message": "Request encoding must be UTF-8.",
    "hint": "Use Content-Type: application/json; charset=utf-8.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#encoding",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_payload
{
  "error": {
    "type": "validation_error",
    "code": "invalid_payload",
    "message": "The request content is invalid.",
    "hint": "With `details`, each refused field is named with its reason. Without `details`, the body could not be parsed as JSON.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_payload",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_requestidempotency-key · invalid_format
{
  "error": {
    "type": "validation_error",
    "code": "invalid_request",
    "message": "Request format is invalid.",
    "hint": "Check that headers, body and JSON encoding match the API contract documented in the API Reference.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_request",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "field": "idempotency-key",
      "reason": "invalid_format"
    }
  }
}
401

The API key is missing, unknown or expired. code tells the three causes apart: missing_api_key (no Authorization: Bearer header), invalid_api_key (unknown or revoked key, or invalid format) and expired_api_key (expiration date has passed).

missing_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "missing_api_key",
    "message": "No API key was provided.",
    "hint": "Add an Authorization header in the form: Bearer cap_live_<your_key>",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#missing_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "API key is invalid or has been revoked.",
    "hint": "Verify the key in your dashboard or generate a new one.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#invalid_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
expired_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "expired_api_key",
    "message": "API key has expired.",
    "hint": "Roll the key from the dashboard to generate a new valid one.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#expired_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
403

Authorization refused. code tells apart the refusals the operation returns under this status, and each example shows one. feature_not_available comes from the account, not the key: details.feature is public_api when the plan doesn't include the API, online_sales when online sales aren't open for the account yet. With sms_consent set to true, the key attests the consent: without the leads:capture scope, insufficient_scope; with API terms not accepted or outdated, terms_acceptance_required. Nothing is recorded.

browser_not_allowed
{
  "error": {
    "type": "authorization_error",
    "code": "browser_not_allowed",
    "message": "API keys must be used from a server, never from a browser.",
    "hint": "The request carries an `Origin` header: call the API from your server, where the key stays secret.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#browser_not_allowed",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
account_suspended
{
  "error": {
    "type": "authorization_error",
    "code": "account_suspended",
    "message": "Access to this account is suspended by the Capturia team.",
    "hint": "The refusal comes from the account, not the key. While the suspension lasts, no request is accepted: contact the Capturia team.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#account_suspended",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
feature_not_availablepublic_api
{
  "error": {
    "type": "authorization_error",
    "code": "feature_not_available",
    "message": "This feature is not included in your plan.",
    "hint": "The rejection comes from the account's plan, not the key. Contact your Capturia advisor to talk it over.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#plan",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "feature": "public_api"
    }
  }
}
insufficient_scope1
{
  "error": {
    "type": "authorization_error",
    "code": "insufficient_scope",
    "message": "This API key does not contain the required scope for this endpoint.",
    "hint": "This key is missing the `events:ingest` scope. Create a new key with the \"Read + write\" preset or add the scope via the dashboard.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#scopes",
    "dashboard_url": "https://capturia.io/platform/dashboard/admin/integrations/api-keys/6f1e2d3c-4b5a-4c6d-8e7f-9a0b1c2d3e4f?tab=permissions",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "required_scope": "events:ingest",
      "current_scopes": [
        "leads:capture"
      ],
      "suggested_preset": "read_write"
    }
  }
}
insufficient_scope2
{
  "error": {
    "type": "authorization_error",
    "code": "insufficient_scope",
    "message": "This API key does not contain the required scope for this endpoint.",
    "hint": "This key is missing the `leads:capture` scope. Create a new key with the \"Read + write\" preset or add the scope via the dashboard.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#scopes",
    "dashboard_url": "https://capturia.io/platform/dashboard/admin/integrations/api-keys/6f1e2d3c-4b5a-4c6d-8e7f-9a0b1c2d3e4f?tab=permissions",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "required_scope": "leads:capture",
      "current_scopes": [
        "events:ingest"
      ],
      "suggested_preset": "read_write"
    }
  }
}
terms_acceptance_required
{
  "error": {
    "type": "authorization_error",
    "code": "terms_acceptance_required",
    "message": "API terms of service have not been accepted, or your accepted version is outdated.",
    "hint": "Open this key in Capturia, Permissions tab, and check the API terms attestation: the key keeps its secret, nothing to change in your integration.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#terms",
    "dashboard_url": "https://capturia.io/platform/dashboard/admin/integrations/api-keys/6f1e2d3c-4b5a-4c6d-8e7f-9a0b1c2d3e4f?tab=permissions",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
feature_not_availableonline_sales
{
  "error": {
    "type": "authorization_error",
    "code": "feature_not_available",
    "message": "This feature isn't open for this account yet.",
    "hint": "Capturia opens it account by account before its launch; the rejection comes from the account, not the key. `details.feature` names it. Contact your Capturia advisor to have it opened.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#plan",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "feature": "online_sales"
    }
  }
}
404

Resource not found. code tells apart the refusals the operation returns under this status, and each example shows one.

contact_not_found
{
  "error": {
    "type": "not_found_error",
    "code": "contact_not_found",
    "message": "No contact matches the provided identifiers. Nothing was recorded.",
    "hint": "Check the identifiers sent, or remove `create_if_missing: false` so Capturia creates the contact.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#contact_not_found",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
offer_not_found
{
  "error": {
    "type": "not_found_error",
    "code": "offer_not_found",
    "message": "No offer of the account has this ID (`offer.id`). Nothing was recorded.",
    "hint": "Copy the offer's identifier in Capturia (Administration, API keys, \"Your offer identifiers\" section), or send `offer.key`, the offer's key in your sales system.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#offer_not_found",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
409

Conflict. purchase_conflict: this external_id already identifies a purchase of another offer, amount or currency; nothing is recorded, and sending the same body again won't change that. idempotency_conflict: the same Idempotency-Key was used for another body (details.reason: payload_mismatch), or the first request under this key is still in progress (in_flight, retry after Retry-After).

purchase_conflict
{
  "error": {
    "type": "conflict_error",
    "code": "purchase_conflict",
    "message": "A purchase with this `external_id` was already recorded with a different offer, amount or currency.",
    "hint": "One `external_id` identifies one purchase: reuse its original values, or send a new `external_id` for another purchase.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#purchase_conflict",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
idempotency_conflictpayload_mismatch
{
  "error": {
    "type": "idempotency_error",
    "code": "idempotency_conflict",
    "message": "Idempotency key conflict.",
    "hint": "Either the same Idempotency-Key was used with a different payload, or a request with this key is still in progress. Use a fresh Idempotency-Key per logical request.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#idempotency",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "reason": "payload_mismatch"
    }
  }
}
idempotency_conflictin_flight
{
  "error": {
    "type": "idempotency_error",
    "code": "idempotency_conflict",
    "message": "Idempotency key conflict.",
    "hint": "Either the same Idempotency-Key was used with a different payload, or a request with this key is still in progress. Use a fresh Idempotency-Key per logical request.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#idempotency",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "reason": "in_flight"
    }
  }
}
413

The request body exceeds 1 MB (1,048,576 bytes). details.max_bytes gives the limit, and details.received_bytes the size announced by Content-Length when the request declares it.

payload_too_large
{
  "error": {
    "type": "validation_error",
    "code": "payload_too_large",
    "message": "Request body exceeds the 1 MB limit.",
    "hint": "Split your request into smaller batches.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#body-size",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "max_bytes": 1048576,
      "received_bytes": 1572864
    }
  }
}
415

The Content-Type header is missing, or isn't application/json.

invalid_content_type
{
  "error": {
    "type": "validation_error",
    "code": "invalid_content_type",
    "message": "Unsupported Content-Type.",
    "hint": "Send Content-Type: application/json on POST/PUT/PATCH requests.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#content-type",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
422

Request refused. code tells apart the refusals the operation returns under this status, and each example shows one.

validation_erroroffer.key · required
{
  "error": {
    "type": "validation_error",
    "code": "validation_error",
    "message": "Request validation failed.",
    "hint": "`details` names each field to fix and the reason it was refused.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#validation_error",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": [
      {
        "field": "offer.key",
        "reason": "required"
      },
      {
        "field": "contact.email",
        "reason": "invalid_format"
      }
    ]
  }
}
validation_errorsms_consent · invalid_type
{
  "error": {
    "type": "validation_error",
    "code": "validation_error",
    "message": "Request validation failed.",
    "hint": "`details` names each field to fix and the reason it was refused.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#validation_error",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": [
      {
        "field": "sms_consent",
        "reason": "invalid_type"
      },
      {
        "field": "amount",
        "reason": "invalid_amount"
      }
    ]
  }
}
contact_archived
{
  "error": {
    "type": "business_rule_error",
    "code": "contact_archived",
    "message": "The matching contact is archived. Nothing was recorded.",
    "hint": "Restore the contact in Capturia, then send the purchase again.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#contact_archived",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
429

Rate limit reached. rate_limit_exceeded: the key's hourly quota is used up. too_many_attempts: too many invalid keys presented from this IP address. rate_limited_ip: more than 120 requests per minute from this IP address on this endpoint, whatever the key; the X-RateLimit-Scope header is then ip. Retry-After gives the delay in seconds.

rate_limit_exceeded
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded.",
    "hint": "Retry after the number of seconds in retry_after_seconds, and consider implementing exponential backoff.",
    "doc_url": "https://capturia.io/en/developers/api/v1/rate-limits",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit": 100,
      "count": 100,
      "limit_type": "per_key",
      "retry_after_seconds": 42
    }
  }
}
too_many_attempts
{
  "error": {
    "type": "rate_limit_error",
    "code": "too_many_attempts",
    "message": "Too many invalid authentication attempts from this IP.",
    "hint": "Wait the period indicated by retry_after_seconds before trying again.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#brute-force",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit_type": "brute_force",
      "retry_after_seconds": 300
    }
  }
}
rate_limited_ip
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limited_ip",
    "message": "IP rate limit reached.",
    "hint": "`details` gives the limit and the window in seconds. Wait for the `Retry-After` header's delay before retrying.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#rate_limited_ip",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit": 120,
      "window_seconds": 60
    }
  }
}
500

Unexpected server error. Always include the request_id when contacting support.

internal_error
{
  "error": {
    "type": "server_error",
    "code": "internal_error",
    "message": "Server error. The Capturia team has been notified.",
    "hint": "If this persists, contact support and include the request_id from this response.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#internal_error",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
501

Test keys (cap_test_) aren't served yet: only cap_live_ keys are accepted.

not_implemented
{
  "error": {
    "type": "server_error",
    "code": "not_implemented",
    "message": "This feature is not yet implemented.",
    "hint": "Check the API documentation for available features and the changelog for upcoming releases.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#not_implemented",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
503

A service the request depends on didn't respond (reading the key, the account or the plan). The same request will go through once it's back: retry after the Retry-After delay.

service_unavailable
{
  "error": {
    "type": "server_error",
    "code": "service_unavailable",
    "message": "Service temporarily unavailable.",
    "hint": "Retry after the period indicated by Retry-After.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#service_unavailable",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}

Example request

curl -X POST 'https://api.capturia.io/v1/purchases' \
  -H 'Authorization: Bearer cap_live_<your-key>' \
  -H 'Content-Type: application/json' \
  -d '{
  "external_id": "commande-10482",
  "offer": {
    "key": "formation-vente-avancee",
    "name": "Formation vente avancée"
  },
  "amount_cents": 49700,
  "currency": "CAD",
  "purchased_at": "2026-10-18T14:32:00-04:00",
  "contact": {
    "email": "[email protected]",
    "phone": "+15145551234",
    "first_name": "Alex"
  },
  "source_label": "Boutique en ligne",
  "sms_consent": true
}'
post/v1/purchases/refunds

Record a purchase refund

Sets the total amount refunded for a purchase received through POST /v1/purchases (the running total, not the latest refund). Once fully refunded, the purchase becomes refunded and the contact is no longer a customer of this offer; a lower total, after a cancelled refund, makes the contact a customer again. Sending the same total again changes nothing. A $0 purchase cannot be refunded. A total greater than the purchase amount is rejected (422 refund_exceeds_amount) and nothing changes. An unknown purchase returns 404 purchase_not_found.

Required scopes: events:ingest

Headers

NameTypeRequiredDescription
Idempotency-KeystringoptionalIdempotency key: 16 to 128 [A-Za-z0-9_-] characters (a UUID v4 or a ULID works). A key of any other shape is refused with 400 invalid_request (details.field: idempotency-key); an empty header counts as a request without a key. A second request with the same key and the same payload returns the original response, with the Idempotency-Replayed: true header, without repeating the operation; the same key with a different payload is refused with 409 idempotency_conflict. Stored for 24 h. Optional but recommended.

Request body

PropertyTypeRequiredDescription
external_idstringrequiredThe external_id of the refunded purchase.
refunded_centsintegerrequiredTotal amount refunded for this purchase, in cents (the running total, not the latest refund). At most the purchase amount: above it, the refund is rejected (422 refund_exceeds_amount).

Responses

StatusDescription
200

Refund recorded.

400

Invalid request. code tells apart the refusals the operation returns under this status, and each example shows one.

invalid_request
{
  "error": {
    "type": "validation_error",
    "code": "invalid_request",
    "message": "Request format is invalid.",
    "hint": "Check that headers, body and JSON encoding match the API contract documented in the API Reference.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_request",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_encoding
{
  "error": {
    "type": "validation_error",
    "code": "invalid_encoding",
    "message": "Request encoding must be UTF-8.",
    "hint": "Use Content-Type: application/json; charset=utf-8.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#encoding",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_payload
{
  "error": {
    "type": "validation_error",
    "code": "invalid_payload",
    "message": "The request content is invalid.",
    "hint": "With `details`, each refused field is named with its reason. Without `details`, the body could not be parsed as JSON.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_payload",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_requestidempotency-key · invalid_format
{
  "error": {
    "type": "validation_error",
    "code": "invalid_request",
    "message": "Request format is invalid.",
    "hint": "Check that headers, body and JSON encoding match the API contract documented in the API Reference.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#invalid_request",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "field": "idempotency-key",
      "reason": "invalid_format"
    }
  }
}
401

The API key is missing, unknown or expired. code tells the three causes apart: missing_api_key (no Authorization: Bearer header), invalid_api_key (unknown or revoked key, or invalid format) and expired_api_key (expiration date has passed).

missing_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "missing_api_key",
    "message": "No API key was provided.",
    "hint": "Add an Authorization header in the form: Bearer cap_live_<your_key>",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#missing_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
invalid_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "API key is invalid or has been revoked.",
    "hint": "Verify the key in your dashboard or generate a new one.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#invalid_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
expired_api_key
{
  "error": {
    "type": "authentication_error",
    "code": "expired_api_key",
    "message": "API key has expired.",
    "hint": "Roll the key from the dashboard to generate a new valid one.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#expired_api_key",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
403

Authorization refused. code tells apart the refusals the operation returns under this status, and each example shows one. feature_not_available comes from the account, not the key: details.feature is public_api when the plan doesn't include the API, online_sales when online sales aren't open for the account yet.

browser_not_allowed
{
  "error": {
    "type": "authorization_error",
    "code": "browser_not_allowed",
    "message": "API keys must be used from a server, never from a browser.",
    "hint": "The request carries an `Origin` header: call the API from your server, where the key stays secret.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#browser_not_allowed",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
account_suspended
{
  "error": {
    "type": "authorization_error",
    "code": "account_suspended",
    "message": "Access to this account is suspended by the Capturia team.",
    "hint": "The refusal comes from the account, not the key. While the suspension lasts, no request is accepted: contact the Capturia team.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#account_suspended",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
feature_not_availablepublic_api
{
  "error": {
    "type": "authorization_error",
    "code": "feature_not_available",
    "message": "This feature is not included in your plan.",
    "hint": "The rejection comes from the account's plan, not the key. Contact your Capturia advisor to talk it over.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#plan",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "feature": "public_api"
    }
  }
}
insufficient_scope
{
  "error": {
    "type": "authorization_error",
    "code": "insufficient_scope",
    "message": "This API key does not contain the required scope for this endpoint.",
    "hint": "This key is missing the `events:ingest` scope. Create a new key with the \"Read + write\" preset or add the scope via the dashboard.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#scopes",
    "dashboard_url": "https://capturia.io/platform/dashboard/admin/integrations/api-keys/6f1e2d3c-4b5a-4c6d-8e7f-9a0b1c2d3e4f?tab=permissions",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "required_scope": "events:ingest",
      "current_scopes": [
        "leads:capture"
      ],
      "suggested_preset": "read_write"
    }
  }
}
feature_not_availableonline_sales
{
  "error": {
    "type": "authorization_error",
    "code": "feature_not_available",
    "message": "This feature isn't open for this account yet.",
    "hint": "Capturia opens it account by account before its launch; the rejection comes from the account, not the key. `details.feature` names it. Contact your Capturia advisor to have it opened.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#plan",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "feature": "online_sales"
    }
  }
}
404

Resource not found. code tells apart the refusals the operation returns under this status, and each example shows one.

purchase_not_found
{
  "error": {
    "type": "not_found_error",
    "code": "purchase_not_found",
    "message": "No purchase was recorded with this `external_id`.",
    "hint": "Send the refund with the `external_id` of the purchase already recorded.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#purchase_not_found",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
409

Idempotency key conflict. The same Idempotency-Key was used for another body (details.reason: payload_mismatch), or the first request under this key is still in progress (in_flight, retry after Retry-After).

idempotency_conflictpayload_mismatch
{
  "error": {
    "type": "idempotency_error",
    "code": "idempotency_conflict",
    "message": "Idempotency key conflict.",
    "hint": "Either the same Idempotency-Key was used with a different payload, or a request with this key is still in progress. Use a fresh Idempotency-Key per logical request.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#idempotency",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "reason": "payload_mismatch"
    }
  }
}
idempotency_conflictin_flight
{
  "error": {
    "type": "idempotency_error",
    "code": "idempotency_conflict",
    "message": "Idempotency key conflict.",
    "hint": "Either the same Idempotency-Key was used with a different payload, or a request with this key is still in progress. Use a fresh Idempotency-Key per logical request.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#idempotency",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "reason": "in_flight"
    }
  }
}
413

The request body exceeds 1 MB (1,048,576 bytes). details.max_bytes gives the limit, and details.received_bytes the size announced by Content-Length when the request declares it.

payload_too_large
{
  "error": {
    "type": "validation_error",
    "code": "payload_too_large",
    "message": "Request body exceeds the 1 MB limit.",
    "hint": "Split your request into smaller batches.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#body-size",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "max_bytes": 1048576,
      "received_bytes": 1572864
    }
  }
}
415

The Content-Type header is missing, or isn't application/json.

invalid_content_type
{
  "error": {
    "type": "validation_error",
    "code": "invalid_content_type",
    "message": "Unsupported Content-Type.",
    "hint": "Send Content-Type: application/json on POST/PUT/PATCH requests.",
    "doc_url": "https://capturia.io/en/developers/api/v1/conventions#content-type",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
422

Request refused. code tells apart the refusals the operation returns under this status, and each example shows one.

validation_error
{
  "error": {
    "type": "validation_error",
    "code": "validation_error",
    "message": "Request validation failed.",
    "hint": "`details` names each field to fix and the reason it was refused.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#validation_error",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": [
      {
        "field": "refunded_cents",
        "reason": "below_min"
      }
    ]
  }
}
refund_exceeds_amount
{
  "error": {
    "type": "business_rule_error",
    "code": "refund_exceeds_amount",
    "message": "The refunded amount exceeds the purchase amount. Nothing was recorded.",
    "hint": "Send in `refunded_cents` the total refunded so far, in cents, without exceeding the purchase amount.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#refund_exceeds_amount",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
429

Rate limit reached. rate_limit_exceeded: the key's hourly quota is used up. too_many_attempts: too many invalid keys presented from this IP address. rate_limited_ip: more than 120 requests per minute from this IP address on this endpoint, whatever the key; the X-RateLimit-Scope header is then ip. Retry-After gives the delay in seconds.

rate_limit_exceeded
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded.",
    "hint": "Retry after the number of seconds in retry_after_seconds, and consider implementing exponential backoff.",
    "doc_url": "https://capturia.io/en/developers/api/v1/rate-limits",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit": 100,
      "count": 100,
      "limit_type": "per_key",
      "retry_after_seconds": 42
    }
  }
}
too_many_attempts
{
  "error": {
    "type": "rate_limit_error",
    "code": "too_many_attempts",
    "message": "Too many invalid authentication attempts from this IP.",
    "hint": "Wait the period indicated by retry_after_seconds before trying again.",
    "doc_url": "https://capturia.io/en/developers/api/v1/authentication#brute-force",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit_type": "brute_force",
      "retry_after_seconds": 300
    }
  }
}
rate_limited_ip
{
  "error": {
    "type": "rate_limit_error",
    "code": "rate_limited_ip",
    "message": "IP rate limit reached.",
    "hint": "`details` gives the limit and the window in seconds. Wait for the `Retry-After` header's delay before retrying.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#rate_limited_ip",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7",
    "details": {
      "limit": 120,
      "window_seconds": 60
    }
  }
}
500

Unexpected server error. Always include the request_id when contacting support.

internal_error
{
  "error": {
    "type": "server_error",
    "code": "internal_error",
    "message": "Server error. The Capturia team has been notified.",
    "hint": "If this persists, contact support and include the request_id from this response.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#internal_error",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
501

Test keys (cap_test_) aren't served yet: only cap_live_ keys are accepted.

not_implemented
{
  "error": {
    "type": "server_error",
    "code": "not_implemented",
    "message": "This feature is not yet implemented.",
    "hint": "Check the API documentation for available features and the changelog for upcoming releases.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#not_implemented",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}
503

A service the request depends on didn't respond (reading the key, the account or the plan). The same request will go through once it's back: retry after the Retry-After delay.

service_unavailable
{
  "error": {
    "type": "server_error",
    "code": "service_unavailable",
    "message": "Service temporarily unavailable.",
    "hint": "Retry after the period indicated by Retry-After.",
    "doc_url": "https://capturia.io/en/developers/api/v1/errors#service_unavailable",
    "request_id": "req_01J9X8Z3F4K2M5N7P9Q1R3S5T7"
  }
}

Example request

curl -X POST 'https://api.capturia.io/v1/purchases/refunds' \
  -H 'Authorization: Bearer cap_live_<your-key>' \
  -H 'Content-Type: application/json' \
  -d '{
  "external_id": "commande-10482",
  "refunded_cents": 49700
}'