API Tokens
Manage service-account API tokens — the bearer tokens used for server-to-server integrations (the same auth method used by the examples throughout this reference). The group lets you create a token, read its metadata, update its name/description, and delete it.
Creating and storing a token
Creating a token provisions a hidden service account with the admin role in the current company; the token value is shown exactly once, in the create response. Deleting a token also removes the underlying service account.
Only a company administrator — a human signed in through the cabinet session, or platform staff — may create or rename a token; a manager or agent gets a plain 403. Calling POST/PATCH as the API token itself is never allowed, whatever permissions the role carries, including from the very service account the token represents — such a call is always refused with 403 and error: "api_token_admin_only". Listing tokens, fetching one by id, and deleting are not bound by this rule — they can be called with the API token itself, as long as it carries api_token.view / api_token.delete.
Deleting a token is how you switch off an integration that acts on behalf of the company, including the integration of a partner that set up your company: every call with the deleted token immediately gets 401. Deleting the token also revokes any temporary embed tokens (POST /v1/embed/auth, they live 8 hours) it minted — otherwise the integration could keep working through those for a while after the deletion. A service account cannot be demoted or revoked through member management (/v1/companies/current/members/{memberId}/role, .../revoke) — such calls answer 404. A deleted token cannot be restored: to bring the integration back, create a new token and hand it to the integrator. Issuing, renaming, and deleting a token are all recorded in the platform audit log.
Reading a token
When a token is read (listed or fetched by id) the token field is no longer returned — only metadata is available (name, description, created_at, last_used_at).
Which token may call this group
Since 2026-09-28 every endpoint of this group requires a full token — a user session or an API token with all abilities. A narrow token with a restricted ability set (for example the token of an embedded CRM window) gets 403 with error: "full_token_required": this way a short-lived token cannot mint itself a permanent one.
Request body
The create and update request body accepts:
name— required, a string up to 255 characters.description— optional, a string up to 1000 characters, nullable.
Endpoints
| Method | Path | Summary |
|---|---|---|
| GET | /v1/api-tokensList API tokens | List API tokens |
| POST | /v1/api-tokensCreate an API token | Create an API token |
| GET | /v1/api-tokens/{id}Get an API token | Get an API token |
| PUT | /v1/api-tokens/{id}Update a token's name/description | Update a token's name/description |
| PATCH | /v1/api-tokens/{id}Partially update a token's name/description | Partially update a token's name/description |
| DELETE | /v1/api-tokens/{id}Delete an API token (and its service account) | Delete an API token (and its service account) |
Examples
Create an API token
Request
curl -X POST https://api.aisar.app/v1/api-tokens \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "n8n Integration",
"description": "Server-to-server token for the n8n automation"
}'Response
{
"data": {
"id": 42,
"name": "n8n Integration",
"description": "Server-to-server token for the n8n automation",
"created_at": "2026-03-15T10:00:00.000000Z",
"token": "42|aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789abcdefg"
}
}List tokens
Request
curl https://api.aisar.app/v1/api-tokens \
-H "Authorization: Bearer YOUR_API_TOKEN"Response
{
"data": [
{
"id": 42,
"name": "n8n Integration",
"description": "Server-to-server token for the n8n automation",
"created_at": "2026-03-15T10:00:00.000000Z",
"last_used_at": "2026-03-16T08:12:44.000000Z"
}
]
}Get a token by id
Request
curl https://api.aisar.app/v1/api-tokens/42 \
-H "Authorization: Bearer YOUR_API_TOKEN"Response
{
"data": {
"id": 42,
"name": "n8n Integration",
"description": "Server-to-server token for the n8n automation",
"created_at": "2026-03-15T10:00:00.000000Z",
"last_used_at": "2026-03-16T08:12:44.000000Z"
}
}Update name and description
Request
curl -X PUT https://api.aisar.app/v1/api-tokens/42 \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "n8n Integration (prod)",
"description": "Rotated server-to-server token for the n8n automation"
}'Response
{
"data": {
"id": 42,
"name": "n8n Integration (prod)",
"description": "Rotated server-to-server token for the n8n automation",
"created_at": "2026-03-15T10:00:00.000000Z",
"last_used_at": "2026-03-16T08:12:44.000000Z"
}
}Delete a token
Request
curl -X DELETE https://api.aisar.app/v1/api-tokens/42 \
-H "Authorization: Bearer YOUR_API_TOKEN"Response
{
"data": {
"message": "API token deleted."
}
}