Issue an access token (OAuth2 Client Credentials)
const url = 'https://api.loyx.se/partners/v1/auth/token';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams({grant_type: 'example'})};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.loyx.se/partners/v1/auth/token \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=exampleExchange client_id and client_secret (via HTTP Basic) for an opaque access token valid for one hour (expires_in). Use it as Authorization: Bearer <token> against every other Partners endpoint, and fetch a new one on a 401. The token carries the API key’s scopes (scope). Limited to 30 calls a minute per API key and 60 per caller IP.
Request Bodyrequired
Section titled “Request Bodyrequired”object
OAuth2 grant type — must be client_credentials.
Example generated
grant_type=exampleResponses
Section titled “Responses”The issued access token, its lifetime and its scopes.
OAuth2 Client Credentials token response.
object
Opaque bearer token
Token lifetime in seconds from issuance
The scopes this token carries, space-separated (RFC 6749 §5.1), for example members:read sales:write. They are the API key’s scopes at issuance; a scope change in the Portal ends the token at once.
Always ‘bearer’
Example
{ "scope": "", "token_type": "bearer"}Unsupported grant_type.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Missing or invalid client credentials, or a revoked key.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Validation Error
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Token requests over the limit; see Retry-After.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}internal_server_error or database_error (type internal_error): our fault. Retry with backoff; quote request_id.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}The rate limiter is unreachable, so issuance is refused.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}