Create an access token
const url = 'https://example.com/api/v1/me/tokens';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"CI deploy token","expires_at":1751328000,"allowed_ips":["198.51.100.0/25"]}'};
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://example.com/api/v1/me/tokens \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "CI deploy token", "expires_at": 1751328000, "allowed_ips": [ "198.51.100.0/25" ] }'Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Friendly name for the token so you can identify it later.
Example
CI deploy tokenUTC timestamp (seconds) for when the token should expire. Must be at least 24 hours in the future.
Example
1751328000Optional allowlist of IPs or CIDR ranges that can use this token.
Responses
Section titled “ Responses ”Access token created. The plain bearer token is only returned once.
object
object
Operational status of the token, derived from revocation and expiration timestamps.
When this token was last used (null if never used).
When this token expires. Null means the token does not expire.
Optional list of IPs or CIDR ranges allowed to use this token.
object
The full bearer token. This is only returned once and cannot be retrieved again.
Example
{ "data": { "id": 23145, "name": "CI Deployments", "status": "active", "last_used_at": null, "usage_count": 0, "expires_at": null, "created_at": "2025-03-01T18:11:00Z", "allowed_ips": [ "10.0.0.0/24", "203.0.113.12" ] }, "meta": { "bearer_token": "YiRqNBToe7EIXAnmtCB3a9gAwHNh0xXZUX3A9zARG5CWKUcDhRn4U9qGcG3q7TwB", "message": "Token generated successfully. Store the bearer token immediately; it will not be shown again." }}Missing or invalid bearer token.
Standard RFC 9457 problem details envelope.
object
RFC 9457 compliant problem details response builder.
Unique identifier for the API request (if available).
Example
{ "type": "about:blank", "title": "Unauthorized", "status": 401, "detail": "Authentication failed", "instance": "/api/v1/me", "trace_id": "b4f5aa7a-1470-4d92-8d3c-98e7c7de9f5f"}Validation failed for the supplied token attributes.
object
RFC 9457 compliant problem details response builder.
Unique identifier for the API request (if available).
Validation errors keyed by input field.
object
Example
{ "type": "about:blank", "title": "Unauthorized", "status": 401, "detail": "Authentication failed", "instance": "/api/v1/me", "trace_id": "b4f5aa7a-1470-4d92-8d3c-98e7c7de9f5f", "errors": { "name": [ "The name field is required." ], "expires_at": [ "The expires at must be at least 24 hours from now." ] }}