openapi: 3.2.0 info: title: AI for Database Keys API version: 1.0.0 description: API for AI agents to interact with databases through natural language, dashboards, workflows, and more. servers: - url: https://app.aifordatabase.com/api/v1 security: - bearerAuth: [] tags: - name: Keys description: Manage platform API keys paths: /keys: get: tags: - Keys summary: List API keys operationId: listApiKeys description: List all active (non-revoked) API keys for the organization. Admin only. responses: '200': description: List of API keys content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: type: array items: $ref: '#/components/schemas/ApiKey' '403': $ref: '#/components/responses/Forbidden' post: tags: - Keys summary: Create API key operationId: createApiKey description: Create a new platform API key. The full key is returned only once in the response. Admin only. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ApiKeyCreate' responses: '201': description: API key created (includes full key) content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: $ref: '#/components/schemas/ApiKeyCreated' '400': $ref: '#/components/responses/BadRequest' '403': $ref: '#/components/responses/Forbidden' /keys/{id}: delete: tags: - Keys summary: Revoke API key operationId: revokeApiKey description: Revoke an API key. The key will no longer be usable for authentication. Admin only. parameters: - $ref: '#/components/parameters/IdParam' responses: '200': description: API key revoked content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: type: object properties: revoked: type: boolean example: true '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' components: schemas: ApiKey: type: object properties: id: type: string keyPrefix: type: string name: type: string scopes: type: string lastUsedAt: type: string format: date-time nullable: true createdAt: type: string format: date-time expiresAt: type: string format: date-time nullable: true ApiKeyCreated: type: object properties: id: type: string name: type: string keyPrefix: type: string scopes: type: string expiresAt: type: string format: date-time nullable: true createdAt: type: string format: date-time key: type: string description: Full API key — only returned at creation time ApiMeta: type: object properties: requestId: type: string format: uuid timestamp: type: string format: date-time pagination: $ref: '#/components/schemas/Pagination' required: - requestId - timestamp SuccessEnvelope: type: object properties: data: {} error: type: 'null' meta: $ref: '#/components/schemas/ApiMeta' required: - data - error - meta ApiError: type: object properties: code: type: string message: type: string details: {} required: - code - message Pagination: type: object properties: total: type: integer page: type: integer pageSize: type: integer totalPages: type: integer required: - total - page - pageSize - totalPages ErrorEnvelope: type: object properties: data: type: 'null' error: $ref: '#/components/schemas/ApiError' meta: $ref: '#/components/schemas/ApiMeta' required: - data - error - meta ApiKeyCreate: type: object required: - name properties: name: type: string scopes: type: array items: type: string default: - '*' description: Permission scopes — use '*' for all expiresAt: type: string format: date-time responses: BadRequest: description: Validation error or bad request content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' NotFound: description: Resource not found content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' Forbidden: description: Insufficient permissions content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' parameters: IdParam: name: id in: path required: true schema: type: string description: Resource ID securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: API Key description: Platform API key starting with afd_