openapi: 3.1.0
info:
  title: xedi.ai Public API
  version: 0.1.0
  summary: Agent-ready EDI document processing API for xedi.ai.
  description: 'Public OpenAPI specification for xedi.ai.


    This API is designed for account-level API token access. Each account has one active API token used as a Bearer credential for document processing, validation, transformation and MCP-backed workflows.


    This spec is intentionally curated for the xedi.ai public API/MCP surface and excludes likely internal, admin, billing provider, webhook, UI-only and operational endpoints.


    Treat request and response schemas as draft placeholders until confirmed against real payload examples.

    '
servers:
- url: https://api.xedi.ai/1
  description: Production API v1
- url: https://staging-api.xedi.ai/1
  description: Staging API v1
security:
- accountApiToken: []
tags:
- name: API Tokens
  description: Account API token/key management. Each account has one active API token.
- name: Documents
  description: Create, import, transform, retrieve and manage documents.
- name: Files
  description: File upload and retrieval endpoints.
- name: Partners
  description: Trading partner discovery and partner metadata.
- name: Partnerships
  description: Business-to-business trading relationships.
- name: Document Types
  description: Supported document types and resolver endpoints.
- name: Schemas
  description: EDI schema discovery, parsing and resolution.
- name: Tasks
  description: Long-running task tracking and operations.
- name: Usage
  description: Usage data for billing and monitoring.
paths:
  /tokens:
    get:
      tags:
      - API Tokens
      summary: Get the current account API token
      operationId: getAccountApiToken
      responses:
        '200':
          description: Current account API token details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiTokenEnvelope'
        '401':
          $ref: '#/components/responses/Unauthorised'
      description: Returns metadata for the single active API token assigned to the current account. The full secret value is only shown when the token is created or regenerated.
    post:
      tags:
      - API Tokens
      summary: Create or regenerate the account API token
      operationId: createOrRegenerateAccountApiToken
      responses:
        '200':
          description: Account API token created. Store the returned secret securely because it may not be shown again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiTokenCreatedEnvelope'
        '409':
          description: An active account API token already exists. Revoke it before issuing a replacement.
        '401':
          $ref: '#/components/responses/Unauthorised'
      description: Issues the single account-level API token used for xedi.ai API and MCP access. If an active token already exists, revoke it before creating a replacement unless the implementation supports regeneration in one action.
  /tokens/{token_id}:
    delete:
      tags:
      - API Tokens
      summary: Revoke the account API token
      operationId: revokeAccountApiToken
      parameters:
      - $ref: '#/components/parameters/TokenId'
      responses:
        '204':
          description: Account API token revoked.
        '404':
          $ref: '#/components/responses/NotFound'
      description: Revokes the active account API token. After revocation, API and MCP requests using that token will fail until a new token is issued.
  /documents:
    get:
      tags:
      - Documents
      summary: List documents
      operationId: listDocuments
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - name: partnership_id
        in: query
        schema:
          type: string
          format: uuid
      - name: doctype_id
        in: query
        schema:
          type: string
      - name: direction
        in: query
        schema:
          type: string
          enum:
          - inbound
          - outbound
      - name: search
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Documents returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentCollectionEnvelope'
    post:
      tags:
      - Documents
      summary: Create a document
      operationId: createDocument
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentCreateRequest'
      responses:
        '200':
          description: Document created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
        '422':
          $ref: '#/components/responses/ValidationError'
  /documents/export:
    get:
      tags:
      - Documents
      summary: List documents ready for export
      operationId: listDocumentsForExport
      parameters:
      - name: partnership_id
        in: query
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Exportable documents returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentCollectionEnvelope'
  /documents/import:
    post:
      tags:
      - Documents
      summary: Import a CSV invoice document using a configured format driver
      operationId: importDocument
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              - partnership_id
              properties:
                file:
                  type: string
                  format: binary
                partnership_id:
                  type: string
                  format: uuid
                format:
                  type: string
                  default: Invoice.Xedi
                  example: Invoice.Xedi
      responses:
        '200':
          description: Imported document.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
        '422':
          $ref: '#/components/responses/ValidationError'
  /documents/importcsv:
    post:
      tags:
      - Documents
      summary: Import a CSV file through a mapping collection
      operationId: importCsvDocument
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              - mapping_collection_id
              - partnership_id
              properties:
                file:
                  type: string
                  format: binary
                mapping_collection_id:
                  type: string
                  format: uuid
                partnership_id:
                  type: string
                  format: uuid
      responses:
        '200':
          description: Imported document.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
        '422':
          $ref: '#/components/responses/ValidationError'
  /documents/importasn:
    post:
      tags:
      - Documents
      summary: Import an ASN document
      operationId: importAsnDocument
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              - partnership_id
              properties:
                file:
                  type: string
                  format: binary
                partnership_id:
                  type: string
                  format: uuid
      responses:
        '200':
          description: Imported ASN document.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
        '422':
          $ref: '#/components/responses/ValidationError'
  /documents/getUnsent:
    get:
      tags:
      - Documents
      summary: Get unsent documents for a partnership and document type
      operationId: getUnsentDocuments
      parameters:
      - name: partnership_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: doctype_id
        in: query
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Unsent documents returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentCollectionEnvelope'
  /documents/{document_id}:
    get:
      tags:
      - Documents
      summary: Get a document
      operationId: getDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Document returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
        '404':
          $ref: '#/components/responses/NotFound'
    patch:
      tags:
      - Documents
      summary: Update a document
      operationId: updateDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentUpdateRequest'
      responses:
        '200':
          description: Document updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentEnvelope'
    delete:
      tags:
      - Documents
      summary: Delete a document
      operationId: deleteDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Document deleted.
        '404':
          $ref: '#/components/responses/NotFound'
  /documents/{document_id}/raw:
    get:
      tags:
      - Documents
      summary: Download the raw source file for a document
      operationId: getRawDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Raw document file.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '404':
          $ref: '#/components/responses/NotFound'
  /documents/{document_id}/convert:
    get:
      tags:
      - Documents
      summary: Convert a document to PDF
      operationId: convertDocumentToPdf
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Converted PDF document.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
  /documents/{document_id}/read:
    put:
      tags:
      - Documents
      summary: Mark a document as read
      operationId: markDocumentRead
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /documents/{document_id}/unread:
    put:
      tags:
      - Documents
      summary: Mark a document as unread
      operationId: markDocumentUnread
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /documents/{document_id}/archive:
    post:
      tags:
      - Documents
      summary: Archive a document
      operationId: archiveDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Document archived.
  /documents/{document_id}/restore:
    post:
      tags:
      - Documents
      summary: Restore an archived document
      operationId: restoreDocument
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Document restored.
  /documents/{document_id}/exported:
    patch:
      tags:
      - Documents
      summary: Mark a document as exported
      operationId: markDocumentExported
      parameters:
      - $ref: '#/components/parameters/DocumentId'
      responses:
        '200':
          description: Document marked as exported.
  /files:
    get:
      tags:
      - Files
      summary: List files
      operationId: listFiles
      responses:
        '200':
          description: Files returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
    post:
      tags:
      - Files
      summary: Upload a file
      operationId: uploadFile
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              properties:
                file:
                  type: string
                  format: binary
                options:
                  type: string
                  description: Optional JSON encoded file processing options.
      responses:
        '200':
          description: File uploaded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileEnvelope'
  /files/{file_id}:
    get:
      tags:
      - Files
      summary: Get or download a file
      operationId: getFile
      security: []
      parameters:
      - $ref: '#/components/parameters/FileId'
      responses:
        '200':
          description: File returned.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
    delete:
      tags:
      - Files
      summary: Delete a file
      operationId: deleteFile
      parameters:
      - $ref: '#/components/parameters/FileId'
      responses:
        '204':
          description: File deleted.
  /partners:
    get:
      tags:
      - Partners
      summary: List trading partners
      operationId: listPartners
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - name: search
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Partners returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerCollectionEnvelope'
    post:
      tags:
      - Partners
      summary: Create a partner
      operationId: createPartner
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerUpsertRequest'
      responses:
        '200':
          description: Partner created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerEnvelope'
  /partners/list:
    get:
      tags:
      - Partners
      summary: Public partner list
      operationId: publicPartnerList
      security: []
      parameters:
      - name: search
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Partner list returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerCollectionEnvelope'
  /partners/{partner_id}:
    get:
      tags:
      - Partners
      summary: Get a partner
      operationId: getPartner
      parameters:
      - $ref: '#/components/parameters/PartnerId'
      responses:
        '200':
          description: Partner returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerEnvelope'
    patch:
      tags:
      - Partners
      summary: Update a partner
      operationId: updatePartner
      parameters:
      - $ref: '#/components/parameters/PartnerId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerUpsertRequest'
      responses:
        '200':
          description: Partner updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerEnvelope'
  /partners/{partner_id}/fields:
    get:
      tags:
      - Partners
      summary: Get mapped fields for a partner
      operationId: getPartnerFields
      parameters:
      - $ref: '#/components/parameters/PartnerId'
      responses:
        '200':
          description: Partner fields returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /partnerships:
    get:
      tags:
      - Partnerships
      summary: List partnerships
      operationId: listPartnerships
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          description: Partnerships returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnershipCollectionEnvelope'
    post:
      tags:
      - Partnerships
      summary: Create a partnership
      operationId: createPartnership
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnershipUpsertRequest'
      responses:
        '200':
          description: Partnership created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnershipEnvelope'
  /partnerships/account-setup:
    post:
      tags:
      - Partnerships
      summary: Set up a trading account relationship
      operationId: setupPartnershipAccount
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /partnerships/{partnership_id}:
    get:
      tags:
      - Partnerships
      summary: Get a partnership
      operationId: getPartnership
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      responses:
        '200':
          description: Partnership returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnershipEnvelope'
    patch:
      tags:
      - Partnerships
      summary: Update a partnership
      operationId: updatePartnership
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnershipUpsertRequest'
      responses:
        '200':
          description: Partnership updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnershipEnvelope'
    delete:
      tags:
      - Partnerships
      summary: Delete a partnership
      operationId: deletePartnership
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      responses:
        '200':
          description: Partnership deleted.
  /partnerships/{partnership_id}/inverse:
    get:
      tags:
      - Partnerships
      summary: Get the inverse partnership
      operationId: getInversePartnership
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      responses:
        '200':
          description: Inverse partnership returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnershipEnvelope'
  /partnerships/{partnership_id}/fields:
    get:
      tags:
      - Partnerships
      summary: Get partnership field values
      operationId: getPartnershipFields
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      responses:
        '200':
          description: Partnership fields returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
    patch:
      tags:
      - Partnerships
      summary: Update partnership field values
      operationId: updatePartnershipFields
      parameters:
      - $ref: '#/components/parameters/PartnershipId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /documenttypes:
    get:
      tags:
      - Document Types
      summary: List supported document types
      operationId: listDocumentTypes
      responses:
        '200':
          description: Document types returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentTypeCollectionEnvelope'
  /documenttypes/resolve:
    get:
      tags:
      - Document Types
      summary: Resolve a document type
      operationId: resolveDocumentType
      parameters:
      - name: code
        in: query
        schema:
          type: string
      - name: standard
        in: query
        schema:
          type: string
          example: EDIFACT
      responses:
        '200':
          description: Document type resolved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentTypeEnvelope'
  /documenttypes/{document_type_id}:
    get:
      tags:
      - Document Types
      summary: Get a document type
      operationId: getDocumentType
      parameters:
      - name: document_type_id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Document type returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentTypeEnvelope'
  /schemas:
    get:
      tags:
      - Schemas
      summary: List schemas
      operationId: listSchemas
      responses:
        '200':
          description: Schemas returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
    post:
      tags:
      - Schemas
      summary: Store a schema
      operationId: storeSchema
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /schemas/parse:
    post:
      tags:
      - Schemas
      summary: Parse an EDI schema or message payload
      operationId: parseSchema
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - payload
              properties:
                payload:
                  type: string
                standard:
                  type: string
                  example: EDIFACT
              additionalProperties: true
      responses:
        '200':
          description: Parsed schema data.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/resolve:
    post:
      tags:
      - Schemas
      summary: Resolve schema metadata from supplied criteria
      operationId: resolveSchema
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          description: Schema resolved.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/versions:
    get:
      tags:
      - Schemas
      summary: List schema versions
      operationId: listSchemaVersions
      responses:
        '200':
          description: Schema versions returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/messages:
    get:
      tags:
      - Schemas
      summary: List schema messages
      operationId: listSchemaMessages
      responses:
        '200':
          description: Schema messages returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/{message}:
    get:
      tags:
      - Schemas
      summary: Get a schema message definition
      operationId: getSchemaMessage
      parameters:
      - name: message
        in: path
        required: true
        schema:
          type: string
          example: INVOIC
      responses:
        '200':
          description: Message schema returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
    patch:
      tags:
      - Schemas
      summary: Update a schema record
      operationId: updateSchema
      parameters:
      - name: message
        in: path
        required: true
        description: Current route uses `{id}` in code; exposed here as message/id pending confirmation.
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
      responses:
        '200':
          $ref: '#/components/responses/GenericSuccess'
  /schemas/parse/{message}:
    get:
      tags:
      - Schemas
      summary: Parse a named schema message
      operationId: parseSchemaMessage
      parameters:
      - name: message
        in: path
        required: true
        schema:
          type: string
          example: INVOIC
      responses:
        '200':
          description: Parsed message schema.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/{message}/groups/{group}:
    get:
      tags:
      - Schemas
      summary: Get a group from a schema message
      operationId: getSchemaGroup
      parameters:
      - name: message
        in: path
        required: true
        schema:
          type: string
          example: INVOIC
      - name: group
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Schema group returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /schemas/segments/{segment}:
    get:
      tags:
      - Schemas
      summary: Get an EDI segment definition
      operationId: getSchemaSegment
      parameters:
      - name: segment
        in: path
        required: true
        schema:
          type: string
          example: BGM
      responses:
        '200':
          description: Segment definition returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /tasks:
    get:
      tags:
      - Tasks
      summary: List tasks
      operationId: listTasks
      responses:
        '200':
          description: Tasks returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCollectionEnvelope'
    post:
      tags:
      - Tasks
      summary: Create a task
      operationId: createTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskUpsertRequest'
      responses:
        '200':
          description: Task created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskEnvelope'
  /tasks/{task_id}:
    get:
      tags:
      - Tasks
      summary: Get a task
      operationId: getTask
      parameters:
      - $ref: '#/components/parameters/TaskId'
      responses:
        '200':
          description: Task returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskEnvelope'
    patch:
      tags:
      - Tasks
      summary: Update a task
      operationId: updateTask
      parameters:
      - $ref: '#/components/parameters/TaskId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskUpsertRequest'
      responses:
        '200':
          description: Task updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskEnvelope'
    delete:
      tags:
      - Tasks
      summary: Delete a task
      operationId: deleteTask
      parameters:
      - $ref: '#/components/parameters/TaskId'
      responses:
        '200':
          description: Task deleted.
  /tasks/operation/{operation}:
    get:
      tags:
      - Tasks
      summary: Get tasks by operation
      operationId: getTasksByOperation
      parameters:
      - name: operation
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Tasks returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCollectionEnvelope'
  /usages:
    get:
      tags:
      - Usage
      summary: List usage records
      operationId: listUsage
      parameters:
      - name: from
        in: query
        schema:
          type: string
          format: date-time
      - name: to
        in: query
        schema:
          type: string
          format: date-time
      responses:
        '200':
          description: Usage records returned.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
components:
  securitySchemes:
    accountApiToken:
      type: http
      scheme: bearer
      bearerFormat: Account API Token
      description: 'Use the account API token generated in xedi.ai as a Bearer token. Example: Authorization: Bearer xedi_live_... Each account has one active API token. Revoke and regenerate the token from the account dashboard if it is compromised.'
  parameters:
    Page:
      name: page
      in: query
      schema:
        type: integer
        minimum: 1
    PerPage:
      name: per_page
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 250
    DocumentId:
      name: document_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    PartnerId:
      name: partner_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    PartnershipId:
      name: partnership_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    TokenId:
      name: token_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    FileId:
      name: file_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    TaskId:
      name: task_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  responses:
    GenericSuccess:
      description: Successful response.
      content:
        application/json:
          schema:
            type: object
            additionalProperties: true
    Unauthorised:
      description: Missing, revoked or invalid account API token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Authenticated user does not have permission to perform this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Request validation failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
  schemas:
    ApiToken:
      type: object
      properties:
        id:
          type: string
          format: uuid
        business_id:
          type: string
          format: uuid
          description: Account or business this API token belongs to.
        token:
          type: string
          description: Masked or stored token reference. This is not the full secret token.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        last_used_at:
          type: string
          format: date-time
          nullable: true
        revoked_at:
          type: string
          format: date-time
          nullable: true
      additionalProperties: true
      description: Metadata for the single account API token. The secret token value is only returned at creation/regeneration time.
    ApiTokenEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/ApiToken'
      additionalProperties: true
    ApiTokenCreatedEnvelope:
      type: object
      properties:
        data:
          type: object
          properties:
            token:
              $ref: '#/components/schemas/ApiToken'
            full_token:
              type: string
              description: The full account API token secret. Show once and store securely.
              example: xedi_live_1234567890abcdef
      additionalProperties: true
      description: Response returned when a new account API token is created or regenerated.
    User:
      type: object
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        name:
          type: string
      additionalProperties: true
    Document:
      type: object
      properties:
        id:
          type: string
          format: uuid
        meta:
          type: object
          additionalProperties: true
        data:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      additionalProperties: true
    DocumentCreateRequest:
      type: object
      properties:
        meta:
          type: object
          additionalProperties: true
        data:
          type: object
          additionalProperties: true
      additionalProperties: true
    DocumentUpdateRequest:
      type: object
      properties:
        meta:
          type: object
          additionalProperties: true
        data:
          type: object
          additionalProperties: true
      additionalProperties: true
    DocumentEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Document'
      additionalProperties: true
    DocumentCollectionEnvelope:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Document'
        meta:
          type: object
          additionalProperties: true
        links:
          type: object
          additionalProperties: true
      additionalProperties: true
    Partner:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        code:
          type: string
        meta:
          type: object
          additionalProperties: true
      additionalProperties: true
    PartnerEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Partner'
      additionalProperties: true
    PartnerCollectionEnvelope:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Partner'
      additionalProperties: true
    PartnerUpsertRequest:
      type: object
      properties:
        name:
          type: string
        code:
          type: string
        meta:
          type: object
          additionalProperties: true
      additionalProperties: true
    Partnership:
      type: object
      properties:
        id:
          type: string
          format: uuid
        sender_id:
          type: string
          format: uuid
        receiver_id:
          type: string
          format: uuid
        meta:
          type: object
          additionalProperties: true
      additionalProperties: true
    PartnershipEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Partnership'
      additionalProperties: true
    PartnershipCollectionEnvelope:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Partnership'
      additionalProperties: true
    PartnershipUpsertRequest:
      type: object
      properties:
        sender_id:
          type: string
          format: uuid
        receiver_id:
          type: string
          format: uuid
        meta:
          type: object
          additionalProperties: true
      additionalProperties: true
    DocumentType:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        code:
          type: string
        standard:
          type: string
      additionalProperties: true
    DocumentTypeEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/DocumentType'
      additionalProperties: true
    DocumentTypeCollectionEnvelope:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/DocumentType'
      additionalProperties: true
    File:
      type: object
      properties:
        id:
          type: string
          format: uuid
        filename:
          type: string
        mime_type:
          type: string
        size:
          type: integer
        url:
          type: string
          format: uri
      additionalProperties: true
    FileEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/File'
      additionalProperties: true
    Task:
      type: object
      properties:
        id:
          type: string
          format: uuid
        operation:
          type: string
        status:
          type: string
          enum:
          - pending
          - running
          - completed
          - failed
          - cancelled
        arguments:
          type: object
          additionalProperties: true
        result:
          type: object
          additionalProperties: true
      additionalProperties: true
    TaskEnvelope:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Task'
      additionalProperties: true
    TaskCollectionEnvelope:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Task'
      additionalProperties: true
    TaskUpsertRequest:
      type: object
      properties:
        operation:
          type: string
        arguments:
          type: object
          additionalProperties: true
        status:
          type: string
      additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
        error:
          type: string
        status:
          type: integer
      additionalProperties: true
    ValidationErrorResponse:
      type: object
      properties:
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
      additionalProperties: true
