API Keys#

Project API key management

List API keys#

GET/projects/{project_id}/api-keys

List API keys for project

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Parameters#

NameTypeLocationRequiredDescription
project_idstringpathYesProject ID

Code Examples#

curl -X GET "https://searchaf.antfly.io/api/v1/projects/{project_id}/api-keys" \\
    -H "Authorization: Bearer YOUR_API_KEY"

Responses#

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "project_id": "550e8400-e29b-41d4-a716-446655440000",
      "key_type": "read_only",
      "key_prefix": "sk_live_",
      "name": "Production API Key",
      "created_at": "2025-10-02T15:30:00Z",
      "last_used_at": "2025-10-02T15:30:00Z",
      "expires_at": "2025-10-02T15:30:00Z",
      "status": "active"
    }
  ]
}

Create API key#

POST/projects/{project_id}/api-keys

Create new API key for project (requires project_admin role)

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Parameters#

NameTypeLocationRequiredDescription
project_idstringpathYesProject ID

Request Body#

Example:

{
    "name": "string",
    "key_type": "read_only",
    "expires_at": "2025-10-02T15:30:00Z"
}

Code Examples#

curl -X POST "https://searchaf.antfly.io/api/v1/projects/{project_id}/api-keys" \\
    -H "Authorization: Bearer YOUR_API_KEY" \\
    -H "Content-Type: application/json" \\
    -d '{
    "name": "string",
    "key_type": "read_only",
    "expires_at": "2025-10-02T15:30:00Z"
}'

Responses#

{
  "api_key": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "project_id": "550e8400-e29b-41d4-a716-446655440000",
    "key_type": "read_only",
    "key_prefix": "sk_live_",
    "name": "Production API Key",
    "created_at": "2025-10-02T15:30:00Z",
    "last_used_at": "2025-10-02T15:30:00Z",
    "expires_at": "2025-10-02T15:30:00Z",
    "status": "active"
  },
  "key": "sk_live_abcdef123456..."
}

Revoke API key#

DELETE/projects/{project_id}/api-keys/{key_id}

Revoke API key (requires project_admin role)

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Parameters#

NameTypeLocationRequiredDescription
project_idstringpathYesProject ID
key_idstringpathYesAPI Key ID

Code Examples#

curl -X DELETE "https://searchaf.antfly.io/api/v1/projects/{project_id}/api-keys/{key_id}" \\
    -H "Authorization: Bearer YOUR_API_KEY"

Responses#

No response body

Rotate API key#

POST/projects/{project_id}/api-keys/{key_id}/rotate

Atomically rotate an API key by revoking the old key and creating a new one with the same name and type. This operation is transactional - both the revoke and create succeed or both fail. Requires project_admin role.

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Parameters#

NameTypeLocationRequiredDescription
project_idstringpathYesProject ID
key_idstringpathYesAPI Key ID

Code Examples#

curl -X POST "https://searchaf.antfly.io/api/v1/projects/{project_id}/api-keys/{key_id}/rotate" \\
    -H "Authorization: Bearer YOUR_API_KEY"

Responses#

{
  "old_key": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "revoked",
    "revoked_at": "2025-10-02T15:30:00Z"
  },
  "new_key": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "project_id": "550e8400-e29b-41d4-a716-446655440000",
    "key_type": "read_only",
    "key_prefix": "sk_live_",
    "name": "Production API Key",
    "created_at": "2025-10-02T15:30:00Z",
    "last_used_at": "2025-10-02T15:30:00Z",
    "expires_at": "2025-10-02T15:30:00Z",
    "status": "active"
  },
  "key": "searchaf_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6"
}

Decrypt API key#

GET/projects/{project_id}/api-keys/{key_id}/decrypt

Retrieve the full decrypted API key. This endpoint returns the plaintext key for copying or reference. Access is restricted to users with project access.

Security#

Provide your bearer token in the Authorization header when making requests to protected resources.

Example: Authorization: Bearer YOUR_API_KEY

Parameters#

NameTypeLocationRequiredDescription
project_idstringpathYesProject ID
key_idstringpathYesAPI Key ID

Code Examples#

curl -X GET "https://searchaf.antfly.io/api/v1/projects/{project_id}/api-keys/{key_id}/decrypt" \\
    -H "Authorization: Bearer YOUR_API_KEY"

Responses#

{
  "key": "searchaf_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6"
}