openapi: 3.2.0 info: title: AI for Database Workflow Credentials 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: Workflow Credentials description: Manage encrypted, destination-bound credentials for workflow actions paths: /workflow-credentials: get: tags: - Workflow Credentials summary: List workflow credentials operationId: listWorkflowCredentials description: List metadata for encrypted workflow credentials. Requires the workflow_credentials scope and an organization admin role. Secret configuration is never returned. parameters: - $ref: '#/components/parameters/PageParam' - $ref: '#/components/parameters/PageSizeParam' responses: '200': description: Paginated credential metadata content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: type: array items: $ref: '#/components/schemas/WorkflowCredential' '403': $ref: '#/components/responses/Forbidden' post: tags: - Workflow Credentials summary: Create workflow credential operationId: createWorkflowCredential description: Encrypt a credential and bind it to exact outbound destination hostnames. Requires the workflow_credentials scope and an organization admin role. The secret is write-only. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/WorkflowCredentialCreate' responses: '201': description: Credential metadata content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: $ref: '#/components/schemas/WorkflowCredential' '400': $ref: '#/components/responses/BadRequest' '403': $ref: '#/components/responses/Forbidden' '409': description: Credential name already exists /workflow-credentials/{id}: get: tags: - Workflow Credentials summary: Get workflow credential metadata operationId: getWorkflowCredential description: Get non-secret credential metadata. Requires the workflow_credentials scope and an organization admin role. parameters: - $ref: '#/components/parameters/IdParam' responses: '200': description: Credential metadata content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: $ref: '#/components/schemas/WorkflowCredential' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' patch: tags: - Workflow Credentials summary: Rotate workflow credential secret operationId: rotateWorkflowCredential description: Replace only the encrypted secret configuration while preserving its kind and allowed hosts. Requires the workflow_credentials scope and an organization admin role. parameters: - $ref: '#/components/parameters/IdParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/WorkflowCredentialRotate' responses: '200': description: Updated credential metadata content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: $ref: '#/components/schemas/WorkflowCredential' '400': $ref: '#/components/responses/BadRequest' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' delete: tags: - Workflow Credentials summary: Delete workflow credential operationId: deleteWorkflowCredential description: Delete a credential only when no workflow draft or active published version references it. Requires the workflow_credentials scope and an organization admin role. parameters: - $ref: '#/components/parameters/IdParam' responses: '200': description: Credential deleted content: application/json: schema: allOf: - $ref: '#/components/schemas/SuccessEnvelope' - type: object properties: data: $ref: '#/components/schemas/DeletedResponse' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': description: Credential is still referenced by a workflow components: schemas: WorkflowCredential: type: object description: Credential metadata only. Stored secret configuration is never returned. properties: id: type: string format: uuid name: type: string kind: type: string enum: - API_KEY_HEADER - BEARER - BASIC - CUSTOM_HEADERS allowedHosts: type: array items: type: string hasSecret: type: boolean const: true lastTestedAt: type: string format: date-time nullable: true lastTestStatus: type: string nullable: true createdAt: type: string format: date-time updatedAt: type: string format: date-time DeletedResponse: type: object properties: deleted: type: boolean example: true 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 WorkflowCredentialCreate: type: object required: - name - kind - allowedHosts - config properties: name: type: string maxLength: 120 kind: type: string enum: - API_KEY_HEADER - BEARER - BASIC - CUSTOM_HEADERS allowedHosts: type: array minItems: 1 maxItems: 20 description: Exact destination hostnames without scheme, port, or path. items: type: string config: $ref: '#/components/schemas/WorkflowCredentialConfig' writeOnly: true WorkflowCredentialConfig: oneOf: - type: object title: API key header required: - headerName - value properties: headerName: type: string value: type: string writeOnly: true - type: object title: Bearer token required: - token properties: token: type: string writeOnly: true - type: object title: Basic authentication required: - username - password properties: username: type: string writeOnly: true password: type: string writeOnly: true - type: object title: Custom headers required: - headers properties: headers: type: array minItems: 1 maxItems: 20 writeOnly: true items: type: object required: - name - value properties: name: type: string value: type: string WorkflowCredentialRotate: type: object required: - config properties: config: $ref: '#/components/schemas/WorkflowCredentialConfig' writeOnly: true ErrorEnvelope: type: object properties: data: type: 'null' error: $ref: '#/components/schemas/ApiError' meta: $ref: '#/components/schemas/ApiMeta' required: - data - error - meta parameters: PageSizeParam: name: pageSize in: query schema: type: integer default: 20 maximum: 100 description: Items per page (max 100) IdParam: name: id in: path required: true schema: type: string description: Resource ID PageParam: name: page in: query schema: type: integer default: 1 description: Page number (1-based) 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' securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: API Key description: Platform API key starting with afd_