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 /organizations/{organizationID}/users/{userID}/keys

List organization API keys

GET /organizations/{organizationID}/keys

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
userIDstringUnique identifier for the user (for user keys)

Response

{
  "keys": [
    {
      "id": "key_123",
      "name": "Production API Key",
      "preview": "xata_...",
      "created_at": "2024-01-01T00:00:00Z",
      "expiry": "2025-01-01T00:00:00Z",
      "last_used": "2024-01-15T10:30:00Z"
    }
  ]
}

Create API key

Creates a new API key for a user or organization.

Create user API key

POST /organizations/{organizationID}/users/{userID}/keys

Create organization API key

POST /organizations/{organizationID}/keys

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
userIDstringUnique identifier for the user (for user keys)

Request body

{
  "name": "New API Key",
  "expiry": "2025-01-01T00:00:00Z"
}

Response

{
  "id": "key_123",
  "name": "New API Key",
  "key": "xata_live_abc123...",
  "created_at": "2024-01-01T00:00:00Z",
  "expiry": "2025-01-01T00:00:00Z"
}

Get API key

Retrieves details about a specific API key.

Get user API key

GET /organizations/{organizationID}/users/{userID}/keys/{keyID}

Get organization API key

GET /organizations/{organizationID}/keys/{keyID}

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
userIDstringUnique identifier for the user (for user keys)
keyIDstringUnique identifier for the API key

Response

{
  "id": "key_123",
  "name": "Production API Key",
  "preview": "xata_...",
  "created_at": "2024-01-01T00:00:00Z",
  "expiry": "2025-01-01T00:00:00Z",
  "last_used": "2024-01-15T10:30:00Z"
}

Delete API key

Permanently deletes an API key.

Delete user API key

DELETE /organizations/{organizationID}/users/{userID}/keys/{keyID}

Delete organization API key

DELETE /organizations/{organizationID}/keys/{keyID}

Path parameters

ParameterTypeDescription
organizationIDstringUnique identifier for the organization
userIDstringUnique identifier for the user (for user keys)
keyIDstringUnique identifier for the API key

Response

Returns a 204 status code with no content on success.