Skip to content
Last updated

Authentication

Every Product API request must be authenticated with a short-lived bearer token.

Sandbox and Staging: every request, including the token exchange below, must also send the CF-Access-Client-Id and CF-Access-Client-Secret headers. See Cloudflare Access. Production does not use them.

For the whole flow with Python and JavaScript examples, see the Quickstart.

1. Exchange your API key for a token

Send your JWT API key to the token endpoint:

curl --location 'https://api.sandbox.aiwyn.app/v1/auth/token' \
  --header 'CF-Access-Client-Id: <cf-access-client-id>' \
  --header 'CF-Access-Client-Secret: <cf-access-client-secret>' \
  --header 'Content-Type: application/json' \
  --data '{ "jwtApiKey": "<your-jwt-api-key>" }'

The response is the bearer token alone: { "token": "eyJ..." }.

2. Send the token on every request

Authorization: Bearer <token>
curl --request POST 'https://api.sandbox.aiwyn.app/gql/v1/clients' \
  --header 'CF-Access-Client-Id: <cf-access-client-id>' \
  --header 'CF-Access-Client-Secret: <cf-access-client-secret>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "pageSize": 5, "page": 0 }'

Token lifetime

  • Tokens are short-lived and last up to an hour. The exchange can return a token it issued earlier, so a token you have just received may have only minutes left.
  • Don't schedule refreshes by the clock: when a call answers 401, request a new token from POST /v1/auth/token and retry the call once.
  • A 401 Unauthorized response means the token is missing, malformed, or expired.

What a token can do

The operations a token is allowed to perform are determined by the roles provisioned for your API key. See Authentication & authorization for the full list of roles and the endpoints each one grants, and Errors for the 401 / 403 response shapes.