Skip to main content

Service Tokens

Service tokens authenticate API requests scoped to an organization. Unlike personal access tokens, service tokens are org-owned and can be used for automation and CI.

Creating and deleting service tokens requires ADMIN or OWNER.

Authentication

Authorization: Bearer <YOUR_API_TOKEN>

List Service Tokens

Lists service tokens for the selected organization.

GET /tha/v3/orgs/{org_slug}/tokens

QueryTypeDescription
limitintegerMax items.
cursorstringPagination cursor.

Response

Each item in items:

FieldTypeDescription
uidstringToken UID.
namestringToken name.
created_byobject{ "email", "username" }.
created_atstringISO 8601 creation timestamp.

Create Service Token

Creates a service token. The token value is only returned once, on creation.

POST /tha/v3/orgs/{org_slug}/tokens

Request Body

FieldTypeDescription
namestringRequired. Name for the token.

Example Request

curl -X POST https://api.targon.com/tha/v3/orgs/my-team/tokens \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "ci-deploy"
}'

Response

FieldTypeDescription
uidstringToken UID.
namestringToken name.
tokenstringRaw token value (returned once).
created_byobject{ "email", "username" }.
created_atstringISO 8601 creation timestamp.

Delete Service Token

Deletes a service token by UID.

DELETE /tha/v3/orgs/{org_slug}/tokens/{token_uid}

Returns 204 No Content.


Errors

Status CodeDescription
400Invalid request or query parameters.
401Invalid or missing token.
403Insufficient role.
404Service token not found.
500Server error.