openapi: 3.0.1
info:
  description: The Afnor Connector API
  title: Afnor Connector API
  version: '@project.version@'
servers:
- description: Generated server url
  url: https://api.btx.fr.banqup.com/network/documents
- description: Generated server url
  url: https://api.btx.eu.banqup.com/network/documents
security:
- oauth2: []
paths:
  /v1/flows:
    post:
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> \tSubmit a flow. A flow is a single-invoice file, with: \n\n\t\t- an
        XML/PDF file with the data of the invoice \n\n\tThe flow is created with a
        `flowInfo` object, allowing to qualify the flow. \n\n\tA flow can be: \n\n
        \t\t- an invoice (CII, UBL, Factur-X,...)\n\t\t- a lifecycle (CDAR)\n\t\t
        - or a e-reporting file \n\n <br/> Scope: space_write<br/> This Endpoint is
        part of: connectors-afnor <br/> Scope: space_write<br/> This Endpoint is part
        of: connectors-afnor <br/> Scope: space_write<br/> This Endpoint is part of:
        connectors-afnor"
      operationId: createFlow
      parameters:
      - description: Header parameter used to correlate logs from several components
        in: header
        name: X-Request-Id
        required: false
        schema:
          type: string
          format: uuid
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                flowInfo:
                  $ref: '#/components/schemas/FlowInfo'
              required:
              - file
              - flowInfo
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FullFlowInfo'
          description: OK - Response message once the flow has been uploaded.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 400 : Bad request.'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 401 : Authentication error.'
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 403 : Forbidden.'
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 413 : Payload Too Large.'
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 422 : Unprocessable entity.'
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 429 : Too many requests.'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 500 : Server Internal Error.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 503 : Unavailable Resource.'
      security:
      - oauth2:
        - space_write
      summary: Submit a new flow
      tags:
      - Afnor Connector API
  /v1/flows/search:
    post:
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> \t\tRetrieves a set of flows matching the provided search criteria:
        \n\n\t\t\t- Need at least one criterion to be specified\n\t\t\t- Assuming
        a logical AND when combining criteria\n\t\t\t- Assuming a logical OR for criteria
        allowing a list of values \n\n\t\tPagination works with the updatedAfter property
        \n\n <br/> Scope: space_read<br/> This Endpoint is part of: connectors-afnor
        <br/> Scope: space_read<br/> This Endpoint is part of: connectors-afnor <br/>
        Scope: space_read<br/> This Endpoint is part of: connectors-afnor"
      operationId: searchFlow
      parameters:
      - description: Header parameter used to correlate logs from several components
        in: header
        name: X-Request-Id
        required: false
        schema:
          type: string
          format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchFlowParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FullFlowInfo'
          description: OK - Response message when returning the results of a search
            request.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 400 : Bad request.'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 401 : Authentication error.'
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 403 : Forbidden.'
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 429 : Too many requests.'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 500 : Server Internal Error.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 503 : Unavailable Resource.'
      security:
      - oauth2:
        - space_read
      summary: Select flows upon criteria
      tags:
      - Afnor Connector API
  /v1/flows/{flowId}:
    get:
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> Download a file related to a given flow: \n\n- an invoice\n- a life
        cycle\n- an e-reporting \n\n <br/> Scope: space_read<br/> This Endpoint is
        part of: connectors-afnor <br/> Scope: space_read<br/> This Endpoint is part
        of: connectors-afnor <br/> Scope: space_read<br/> This Endpoint is part of:
        connectors-afnor"
      operationId: getFlow
      parameters:
      - description: Header parameter used to correlate logs from several components
        in: header
        name: X-Request-Id
        required: false
        schema:
          type: string
          format: uuid
      - in: path
        name: flowId
        required: true
        schema:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
      - description: "This parameter allows to provide the type of file to be downloaded,
          can be either one: \n\n- Metadata [Default]: provides the flow metadata
          as a JSON payload, no download\n- Original: the document that has been initially
          sent/provided by the emitter\n- Converted: the document that has been optionally
          converted by the system\n- ReadableView: the document that has been optionally
          generated as the readable file\n"
        in: query
        name: docType
        required: false
        schema:
          type: string
          default: METADATA
          enum:
          - Metadata
          - Original
          - Converted
          - ReadableView
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Flow'
            application/octet-stream: {}
          description: OK - Response message when returning the results of a search
            request.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 400 : Bad request.'
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 401 : Authentication error.'
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 403 : Forbidden.'
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 404 : Resource Not Found.'
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 429 : Too many requests.'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 500 : Server Internal Error.'
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: 'Error 503 : Unavailable Resource.'
      security:
      - oauth2:
        - space_read
      summary: Download the file of a flow
      tags:
      - Afnor Connector API
components:
  schemas:
    Acknowledgement:
      type: object
      properties:
        details:
          $ref: '#/components/schemas/AcknowledgementDetails'
        status:
          type: string
          enum:
          - Pending
          - Ok
          - Error
      required:
      - status
    AcknowledgementDetail:
      type: object
      properties:
        item:
          type: string
        level:
          type: string
          enum:
          - Error
          - Warning
        reasonCode:
          $ref: '#/components/schemas/ReasonCode'
        reasonMessage:
          type: string
    AcknowledgementDetails:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/AcknowledgementDetail'
    Error:
      type: object
      properties:
        errorCode:
          type: string
        errorMessage:
          type: string
    Flow:
      type: object
      properties:
        acknowledgement:
          $ref: '#/components/schemas/Acknowledgement'
        flowDirection:
          type: string
          enum:
          - In
          - Out
        flowId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
        flowProfile:
          type: string
          enum:
          - Basic
          - CIUS
          - Extended-CTC-FR
        flowSyntax:
          type: string
          enum:
          - CII
          - UBL
          - Factur-X
          - CDAR
          - FRR
        flowType:
          type: string
          enum:
          - CustomerInvoice
          - SupplierInvoice
          - StateInvoice
          - CustomerInvoiceLC
          - SupplierInvoiceLC
          - StateCustomerInvoiceLC
          - StateSupplierInvoiceLC
          - AggregatedCustomerTransactionReport
          - UnitaryCustomerTransactionReport
          - AggregatedCustomerPaymentReport
          - UnitaryCustomerPaymentReport
          - UnitarySupplierTransactionReport
          - MultiFlowReport
        processingRule:
          type: string
          enum:
          - B2B
          - B2BInt
          - B2C
          - OutOfScope
          - ArchiveOnly
          - NotApplicable
        processingRuleSource:
          type: string
          enum:
          - Input
          - Computed
        submittedAt:
          type: string
          format: date-time
        trackingId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
        updatedAt:
          type: string
          format: date-time
    FlowInfo:
      type: object
      properties:
        flowProfile:
          type: string
          enum:
          - Basic
          - CIUS
          - Extended-CTC-FR
        flowSyntax:
          type: string
          enum:
          - CII
          - UBL
          - Factur-X
          - CDAR
          - FRR
        name:
          type: string
          maxLength: 255
          minLength: 0
        processingRule:
          type: string
          enum:
          - B2B
          - B2BInt
          - B2C
          - OutOfScope
          - ArchiveOnly
          - NotApplicable
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
        trackingId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
      required:
      - flowSyntax
    FullFlowInfo:
      type: object
      properties:
        flowId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
          minLength: 0
        flowProfile:
          type: string
          enum:
          - Basic
          - CIUS
          - Extended-CTC-FR
        flowSyntax:
          type: string
          enum:
          - CII
          - UBL
          - Factur-X
          - CDAR
          - FRR
        name:
          type: string
          maxLength: 255
          minLength: 0
        processingRule:
          type: string
          enum:
          - B2B
          - B2BInt
          - B2C
          - OutOfScope
          - ArchiveOnly
          - NotApplicable
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
        submittedAt:
          type: string
          format: date-time
        trackingId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
      required:
      - flowSyntax
    ReasonCode:
      type: object
      discriminator:
        propertyName: type
      properties:
        type:
          type: string
      required:
      - type
    SearchFlowFilters:
      type: object
      properties:
        ackStatus:
          type: string
          enum:
          - Pending
          - Ok
          - Error
        flowDirection:
          type: array
          items:
            type: string
            enum:
            - In
            - Out
        flowType:
          type: array
          items:
            type: string
            enum:
            - CustomerInvoice
            - SupplierInvoice
            - StateInvoice
            - CustomerInvoiceLC
            - SupplierInvoiceLC
            - StateCustomerInvoiceLC
            - StateSupplierInvoiceLC
            - AggregatedCustomerTransactionReport
            - UnitaryCustomerTransactionReport
            - AggregatedCustomerPaymentReport
            - UnitaryCustomerPaymentReport
            - UnitarySupplierTransactionReport
            - MultiFlowReport
        processingRule:
          type: array
          items:
            type: string
            enum:
            - B2B
            - B2BInt
            - B2C
            - OutOfScope
            - ArchiveOnly
            - NotApplicable
        trackingId:
          type: string
          description: Unique identifier supporting UUID but not only, for flexibility
            purpose
          maxLength: 36
        updatedAfter:
          type: string
          format: date-time
        updatedBefore:
          type: string
          format: date-time
    SearchFlowParams:
      type: object
      properties:
        limit:
          type: integer
          format: int32
          maximum: 100
        where:
          $ref: '#/components/schemas/SearchFlowFilters'
      required:
      - where
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://api.btx.fr.banqup.com/oauth2/client_credential/gettoken
          scopes:
            info: Scopes are endpoint-specific, see each endpoint for required scope.
        authorizationCode:
          authorizationUrl: https://api.btx.fr.banqup.com/oauth2/auth
          tokenUrl: https://api.btx.fr.banqup.com/oauth2/token
          scopes:
            info: Scopes are endpoint-specific, see each endpoint for required scope.
