Skip to main content

User

Manage your account credits and API keys.

Authentication

All user endpoints require authentication using a Bearer token. Include your API key in the Authorization header:

Authorization: Bearer <YOUR_API_KEY>

Get Credits

Retrieve the credit balance for the authenticated user.

Endpoint

GET /tha/v2/me/credits

Example Request

curl -X GET https://api.targon.com/tha/v2/me/credits \
-H "Authorization: Bearer <YOUR_API_KEY>"

Response

FieldTypeDescription
creditsintegerThe user's current credit balance.
currencystringThe currency of the credit balance.

Example Response

{
"credits": 50000,
"currency": "USD"
}

Errors

Status CodeDescription
401 - UnauthorizedInvalid or missing API key.
500 - Internal Server ErrorServer error.

List API Keys

List all API keys for the authenticated user.

Endpoint

GET /tha/v2/me/api-keys

Query Parameters

FieldTypeDescription
limitintegerMaximum number of items to return.
cursorstringPagination cursor.

Example Request

curl -X GET "https://api.targon.com/tha/v2/me/api-keys?limit=10" \
-H "Authorization: Bearer <YOUR_API_KEY>"

Response

FieldTypeDescription
itemsarrayList of API key objects.
next_cursorstringCursor for the next page of results.

Each item in items:

FieldTypeDescription
uidstringUnique identifier for the API key.
namestringName of the API key.
key_rawstringThe raw API key value.
created_atstringISO 8601 creation timestamp.
updated_atstringISO 8601 last update timestamp.

Example Response

{
"items": [
{
"uid": "key-abc123def456",
"name": "my-api-key",
"key_raw": "tgn_...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
],
"next_cursor": ""
}

Errors

Status CodeDescription
400 - Bad RequestInvalid query parameters.
401 - UnauthorizedInvalid or missing API key.
500 - Internal Server ErrorServer error.

Create API Key

Create a new API key for the authenticated user.

Endpoint

POST /tha/v2/me/api-keys

Request Body

FieldTypeDescription
namestringRequired. Name for the new API key.

Example Request

curl -X POST https://api.targon.com/tha/v2/me/api-keys \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-new-key"
}'

Response

Returns the created API key object.

FieldTypeDescription
uidstringUnique identifier for the API key.
namestringName of the API key.
key_rawstringThe raw API key value.
created_atstringISO 8601 creation timestamp.
updated_atstringISO 8601 last update timestamp.

Example Response

{
"uid": "key-abc123def456",
"name": "my-new-key",
"key_raw": "tgn_...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}

Errors

Status CodeDescription
400 - Bad RequestInvalid request body.
401 - UnauthorizedInvalid or missing API key.
500 - Internal Server ErrorServer error.

Update API Key

Update an API key's name.

Endpoint

PATCH /tha/v2/me/api-keys/{key_uid}

Path Parameters

FieldTypeDescription
key_uidstringUnique identifier of the API key.

Request Body

FieldTypeDescription
namestringRequired. New name for the key.

Example Request

curl -X PATCH https://api.targon.com/tha/v2/me/api-keys/key-abc123def456 \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "renamed-key"
}'

Response

Returns the updated API key object.

Example Response

{
"uid": "key-abc123def456",
"name": "renamed-key",
"key_raw": "tgn_...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-16T08:00:00Z"
}

Errors

Status CodeDescription
400 - Bad RequestInvalid request body.
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundAPI key not found.
500 - Internal Server ErrorServer error.

Delete API Key

Delete an API key.

Endpoint

DELETE /tha/v2/me/api-keys/{key_uid}

Path Parameters

FieldTypeDescription
key_uidstringUnique identifier of the API key.

Example Request

curl -X DELETE https://api.targon.com/tha/v2/me/api-keys/key-abc123def456 \
-H "Authorization: Bearer <YOUR_API_KEY>"

Response

Returns 204 No Content on success.

Errors

Status CodeDescription
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundAPI key not found.
500 - Internal Server ErrorServer error.

Rotate API Key

Rotate an API key's secret, generating a new raw key value.

Endpoint

POST /tha/v2/me/api-keys/{key_uid}:roll

Path Parameters

FieldTypeDescription
key_uidstringUnique identifier of the API key.

Example Request

curl -X POST https://api.targon.com/tha/v2/me/api-keys/key-abc123def456:roll \
-H "Authorization: Bearer <YOUR_API_KEY>"

Response

Returns the API key object with the new raw key value.

Example Response

{
"uid": "key-abc123def456",
"name": "my-api-key",
"key_raw": "tgn_new_...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-17T12:00:00Z"
}

Errors

Status CodeDescription
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundAPI key not found.
500 - Internal Server ErrorServer error.