Skip to main content
POST
To access the platform, you must first have an access token. Through this URL, you can obtain one — but be careful! The access token expires after 1 hour. After this period, you will need to re-authenticate.

Overview

POST /auth/token exchanges your business credentials (client_id and client_key) for a short-lived Bearer access token. Every other Cartevo endpoint requires this token in the Authorization header. There is no refresh-token endpoint — when a token expires, call this endpoint again.

When to use it

  • Once at the start of any worker, cron job, or HTTP request that needs to call Cartevo.
  • Whenever a previous token is about to expire (recommended: refresh ~5 minutes before expires_in runs out).
  • After a 401 Unauthorized response from any other endpoint — refresh and retry once.

Prerequisites

  • An active Cartevo company account.
  • A client_id / client_key pair, available from the dashboard at Settings → API Keys.

Request

Headers

No Authorization header is required for this endpoint.

Body

Response

200 — Success

Note: This endpoint returns the raw response shown above — it is not wrapped in the standard { success, statusCode, message, data } envelope used elsewhere. See API Conventions → Response envelope.

Error responses

Token scope and lifetime

  • Scope: Each token is bound to one company in one mode (preproduction or production). It cannot operate on another company’s data, and it cannot cross modes.
  • Lifetime: Determined by the deployment configuration. Treat expires_in as the only authoritative value. The current production default is short-lived (typically 1 hour); preproduction may differ.
  • Revocation: There is no per-token revocation endpoint. Rotating the underlying client_key immediately invalidates all tokens minted from it.

Code examples

cURL
Node.js (axios)
Python (requests)
PHP (Guzzle)

Best practices

  • Cache the token in your server for expires_in - 300 seconds and reuse it across requests — do not mint a new token per call.
  • Refresh preemptively. Schedule a refresh ~5 minutes before expiry so in-flight requests never hit a 401.
  • Never expose client_key or the access_token to browsers, mobile apps, or any client-side code. Always proxy through your server.
  • Rotate client_key immediately if you suspect compromise. Existing tokens minted from it remain valid until expiry — there is no per-token revocation.
  • Use separate credentials per environment (preproduction vs. production) so a leaked test key cannot touch live money.

Webhooks fired

None. This endpoint is purely synchronous.

Body

application/json
client_id
string
required
client_key
string
required

Response

Authentication successful

access_token
string
required

JWT access token for API authentication

Example:

"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJlY2E1ZTk4Mi0wMGI1LTRhYTItYjcwOS03ZDVjZDY3M2U5NWMiLCJjb21wYW55SWQiOiJlY2E1ZTk4Mi0wMGI1LTRhYTItYjcwOS03ZDVjZDY3M2U5NWMiLCJjbGllbnRJZCI6ImNsaWVudF91dGtxNnV5MnB0IiwiaWF0IjoxNzYyMTY4MDIzLCJleHAiOjE3NjIxNzE2MjN9.hloSSSPJ2WFa31s41BL1nqhemuwHCJKC_wcwVupsBlU"

token_type
string
required

Type of token

Example:

"Bearer"

expires_in
integer
required

Token expiration time in seconds

Example:

3600