API Keys API
Manage API keys for authentication
The API Keys API allows you to manage API keys for users and organizations, including creating, listing, and deleting API keys.
List API keys
Retrieves a list of API keys for a user or organization.
List user API keys
GET /api-keys
List organization API keys
GET /api-keys
Query parameters
Parameter | Type | Description |
---|---|---|
organization | string | Filter by organization ID (optional) |
user | string | Filter by user ID (optional) |
Response
{
"keys": [
{
"id": "key_123",
"name": "Production API Key",
"preview": "xata_...",
"created_at": "2024-01-01T00:00:00Z",
"created_by": "user_123",
"created_by_key": null,
"expiry": "2025-01-01T00:00:00Z",
"last_used": "2024-01-15T10:30:00Z",
"scopes": ["read", "write"],
"projects": ["proj_123"],
"branches": ["br_123"]
}
]
}
Create API key
Creates a new API key for a user or organization.
POST /api-keys
Request body
{
"name": "New API Key",
"expiry": "2025-01-01T00:00:00Z",
"scopes": ["read", "write"],
"projects": ["proj_123"],
"branches": ["br_123"]
}
Request body parameters
Parameter | Type | Description |
---|---|---|
name | string | Human-readable name for the API key |
expiry | string (date-time) | Optional expiration date for the API key |
scopes | array | List of scopes for the API key |
projects | array | List of project IDs the key has access to |
branches | array | List of branch IDs the key has access to |
Response
{
"id": "key_123",
"name": "New API Key",
"key": "xata_live_abc123...",
"created_at": "2024-01-01T00:00:00Z",
"created_by": "user_123",
"created_by_key": null,
"expiry": "2025-01-01T00:00:00Z",
"scopes": ["read", "write"],
"projects": ["proj_123"],
"branches": ["br_123"]
}
Get API key
Retrieves details about a specific API key.
GET /api-keys/{apiKeyID}
Path parameters
Parameter | Type | Description |
---|---|---|
apiKeyID | string | Unique identifier for the API key |
Response
{
"id": "key_123",
"name": "Production API Key",
"preview": "xata_...",
"created_at": "2024-01-01T00:00:00Z",
"created_by": "user_123",
"created_by_key": null,
"expiry": "2025-01-01T00:00:00Z",
"last_used": "2024-01-15T10:30:00Z",
"scopes": ["read", "write"],
"projects": ["proj_123"],
"branches": ["br_123"]
}
Delete API key
Permanently deletes an API key.
DELETE /api-keys/{apiKeyID}
Path parameters
Parameter | Type | Description |
---|---|---|
apiKeyID | string | Unique identifier for the API key |
Response
Returns a 204 status code with no content on success.