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
| Field | Type | Description |
|---|---|---|
credits | integer | The user's current credit balance. |
currency | string | The currency of the credit balance. |
Example Response
{
"credits": 50000,
"currency": "USD"
}
Errors
| Status Code | Description |
|---|---|
| 401 - Unauthorized | Invalid or missing API key. |
| 500 - Internal Server Error | Server error. |
List API Keys
List all API keys for the authenticated user.
Endpoint
GET /tha/v2/me/api-keys
Query Parameters
| Field | Type | Description |
|---|---|---|
limit | integer | Maximum number of items to return. |
cursor | string | Pagination cursor. |
Example Request
curl -X GET "https://api.targon.com/tha/v2/me/api-keys?limit=10" \
-H "Authorization: Bearer <YOUR_API_KEY>"
Response
| Field | Type | Description |
|---|---|---|
items | array | List of API key objects. |
next_cursor | string | Cursor for the next page of results. |
Each item in items:
| Field | Type | Description |
|---|---|---|
uid | string | Unique identifier for the API key. |
name | string | Name of the API key. |
key_raw | string | The raw API key value. |
created_at | string | ISO 8601 creation timestamp. |
updated_at | string | ISO 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 Code | Description |
|---|---|
| 400 - Bad Request | Invalid query parameters. |
| 401 - Unauthorized | Invalid or missing API key. |
| 500 - Internal Server Error | Server error. |
Create API Key
Create a new API key for the authenticated user.
Endpoint
POST /tha/v2/me/api-keys
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Required. 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.
| Field | Type | Description |
|---|---|---|
uid | string | Unique identifier for the API key. |
name | string | Name of the API key. |
key_raw | string | The raw API key value. |
created_at | string | ISO 8601 creation timestamp. |
updated_at | string | ISO 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 Code | Description |
|---|---|
| 400 - Bad Request | Invalid request body. |
| 401 - Unauthorized | Invalid or missing API key. |
| 500 - Internal Server Error | Server error. |
Update API Key
Update an API key's name.
Endpoint
PATCH /tha/v2/me/api-keys/{key_uid}
Path Parameters
| Field | Type | Description |
|---|---|---|
key_uid | string | Unique identifier of the API key. |
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Required. 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 Code | Description |
|---|---|
| 400 - Bad Request | Invalid request body. |
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | API key not found. |
| 500 - Internal Server Error | Server error. |
Delete API Key
Delete an API key.
Endpoint
DELETE /tha/v2/me/api-keys/{key_uid}
Path Parameters
| Field | Type | Description |
|---|---|---|
key_uid | string | Unique 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 Code | Description |
|---|---|
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | API key not found. |
| 500 - Internal Server Error | Server 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
| Field | Type | Description |
|---|---|---|
key_uid | string | Unique 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 Code | Description |
|---|---|
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | API key not found. |
| 500 - Internal Server Error | Server error. |