openapi: 3.1.0
info:
  title: InvoiceXpress API
  description: >
    Endpoints for managing Accounts, Invoices, Estimates, and organization data
    in InvoiceXpress.
  version: 2.0.0
  contact:
    name: InvoiceXpress API Support
    email: support@invoicexpress.com
  x-logo:
    url: ../images/ix-logo.svg
    altText: InvoiceXpress Logo
servers:
  - url: https://{account_name}.app.invoicexpress.com
    description: Production Server
    variables:
      account_name:
        default: your-account
        description: Your account subdomain.
tags:
  - name: Accounts
    description: Create, update and get info about your account.
  - name: Invoices
    description: >-
      Create invoices, invoice receipts, simplified invoices, vat moss invoices,
      credit notes & debit notes and send them to your clients.
  - name: Estimates
    description: Create quotes, proformas or fees notes and send them to your clients.
  - name: Guides
    description: Create shippings, transports & devolutions and send them to your clients.
  - name: Sequences
    description: A Sequence is used to group invoices in a sequential order.
  - name: Taxes
    description: A Tax is applied to invoice items when creating invoices.
  - name: SAFT
    description: >-
      Export the Standard Audit File for Tax (SAF-T PT) required by the
      Portuguese Tax Authority.
security:
  - apiKeyAuth: []
paths:
  /api/accounts/create.json:
    post:
      summary: Create Account
      operationId: createAccount
      tags:
        - Accounts
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountCreateRequest'
      responses:
        '201':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountCreateSuccess'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CreateAccount'
  /api/accounts/create_already_user.json:
    post:
      summary: Create for existing user
      operationId: createAccountExisting
      tags:
        - Accounts
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountCreateRequest'
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountCreateSuccess'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422AlreadyUser'
  /api/accounts/{account-id}/get.json:
    get:
      summary: Get Account
      operationId: getAccount
      tags:
        - Accounts
      parameters:
        - $ref: '#/components/parameters/AccountIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: SUCCESS.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountGetSuccess'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
  /api/accounts/{account-id}/update.json:
    put:
      summary: Update Account
      operationId: updateAccount
      tags:
        - Accounts
      parameters:
        - $ref: '#/components/parameters/AccountIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountUpdateRequest'
      responses:
        '200':
          description: SUCCESS
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422UpdateAccount'
  /api/v3/accounts/at_communication.json:
    post:
      summary: AT Communication
      operationId: atCommunication
      tags:
        - Accounts
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AtCommunicationRequest'
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AtCommunicationSuccess'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422AtCommunication'
  /invoices.json:
    get:
      summary: List All
      operationId: listInvoices
      tags:
        - Invoices
      description: Returns a list of invoices.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/ListInvoicesQueryParamns'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceListAllResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
  /{invoices-type}.json:
    post:
      summary: Create Invoice
      operationId: createInvoice
      tags:
        - Invoices
      description: >
        Creates a new invoice, simplified_invoice, invoice_receipt, credit_note
        or debit_note.




        ### Creating new clients or items along with the documents

        This method also allows to create a new client and/or new items in the
        same request with the following behavior:

        * If the client name does not exist, a new one is created.

        * If items do not exist with the given names, new ones will be created.

        * If item name already exists, the item is updated with the new values.


        ### Taxes

        Regarding item taxes, if the tax name is not found, the default tax is
        applyed to that item. Portuguese accounts should also send the IVA
        exemption reason if the invoice contains exempt items (IVA 0%).


        > **Note:** Simplified Invoices are only available in Portugal.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/DocumentTypeInvoiceParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceCreateRequest'
      responses:
        '201':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '409':
          description: CONFLICT
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/409CreateInvoice'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CreateInvoice'
  /{estimates-type}.json:
    post:
      summary: Create Estimate
      operationId: createEstimate
      tags:
        - Estimates
      description: Creates a new quote, proforma or fees_note.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/DocumentTypeEstimateParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EstimateCreateRequest'
      responses:
        '201':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CreateInvoice'
  /{guides-type}.json:
    post:
      summary: Create Guide
      operationId: createGuide
      tags:
        - Guides
      description: Creates a new shipping, transport or devolution.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/DocumentTypeGuideParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuideCreateRequest'
      responses:
        '201':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuideGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CreateInvoice'
  /{invoices-type}/{document-id}.json:
    get:
      summary: Get Invoice
      operationId: getInvoice
      tags:
        - Invoices
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/DocumentTypeInvoiceParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
    put:
      summary: Update Invoice
      operationId: updateInvoice
      tags:
        - Invoices
      description: >
        Updates a new invoice, simplified_invoice, invoice_receipt, credit_note
        or debit_note.




        ### Creating new clients or items along with the invoice

        This method also allows to create a new client and/or new items in the
        same request with the following behavior:

        * If the client name does not exist, a new one is created.

        * If items do not exist with the given names, new ones will be created.

        * If item name already exists, the item is updated with the new values.


        ### Taxes

        Regarding item taxes, if the tax name is not found, the default tax is
        applyed to that item. Portuguese accounts should also send the IVA
        exemption reason if the invoice contains exempt items (IVA 0%).


        > **Note:** Simplified Invoices are only available in Portugal.
      parameters:
        - $ref: '#/components/parameters/DocumentTypeInvoiceParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceUpdateRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422UpdateInvoices'
  /{estimates-type}/{document-id}.json:
    get:
      summary: Get Estimate
      operationId: getEstimate
      tags:
        - Estimates
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/DocumentTypeEstimateParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
    put:
      summary: Update Estimate
      operationId: updateEstimate
      tags:
        - Estimates
      description: Updates a quote, proforma or fees_note.
      parameters:
        - $ref: '#/components/parameters/DocumentTypeEstimateParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EstimateCreateRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422UpdateInvoices'
  /{guides-type}/{document-id}.json:
    get:
      summary: Get Guide
      operationId: getGuide
      tags:
        - Guides
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/DocumentTypeGuideParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuideGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
    put:
      summary: Update Guide
      operationId: updateGuide
      tags:
        - Guides
      description: Updates a shipping, transport or devolution.
      parameters:
        - $ref: '#/components/parameters/DocumentTypeGuideParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GuideCreateRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuideGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422UpdateInvoices'
  /{invoices-type}/{document-id}/change-state.json:
    put:
      summary: Change Invoice State
      operationId: changeInvoiceState
      tags:
        - Invoices
      description: >
        Changes the state of invoice documents.


        | From | To | State on Request Body | Notes |

        | :--- | :--- | :--- | :--- |

        | draft | final | **finalized** | All documents. |

        | draft | settled | **finalized** | Only `invoice_receipt`. |

        | draft | deleted | **deleted** | All documents. |

        | final | canceled | **canceled** | All documents. |

        | settled | canceled | **canceled** | Only `invoice_receipt`. |

        | final | settled | **settled** | All documents. |

        | settled | final | **unsettled** | Only `credit_note` and `debit_note`.
        |
      parameters:
        - $ref: '#/components/parameters/DocumentTypeInvoiceParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeStateInvoiceRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422ChangeState'
  /{estimates-type}/{document-id}/change-state.json:
    put:
      summary: Change Estimate State
      operationId: changeEstimateState
      tags:
        - Estimates
      description: |
        Changes the state of estimate documents (quotes, proformas, fees_notes).

        | From | To | Event |
        | :--- | :--- | :--- |
        | Draft | final | `finalized` |
        | Draft | deleted | `deleted` |
        | final | Accepted | `accept` |
        | final | refused | `refuse` |
        | final | canceled | `canceled` |
        | Accepted | refused | `refuse` |
        | refused | Accepted | `accept` |
        | Accepted | canceled | `canceled` |
        | refused | canceled | `canceled` |
      parameters:
        - $ref: '#/components/parameters/DocumentTypeEstimateParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeStateEstimateRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422ChangeState'
  /{guides-type}/{document-id}/change-state.json:
    put:
      summary: Change Guide State
      operationId: changeGuideState
      tags:
        - Guides
      description: >
        Changes the state of guide documents (shippings, transports,
        devolutions).


        | From | To | Event |

        | :--- | :--- | :--- |

        | draft | final | **finalized** |

        | draft | deleted | **deleted** |

        | final | canceled | **canceled** |
      parameters:
        - $ref: '#/components/parameters/DocumentTypeGuideParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeStateGuideRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuideGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422ChangeState'
  /{invoices-type}/{document-id}/email-document.json:
    put:
      summary: Send Invoice by Email
      operationId: sendInvoiceEmail
      tags:
        - Invoices
      parameters:
        - $ref: '#/components/parameters/DocumentTypeInvoiceParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailDocumentRequest'
      responses:
        '200':
          description: SUCCESS
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422SendEmail'
  /{estimates-type}/{document-id}/email-document.json:
    put:
      summary: Send Estimate by Email
      operationId: sendEstimateEmail
      tags:
        - Estimates
      parameters:
        - $ref: '#/components/parameters/DocumentTypeEstimateParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailDocumentRequest'
      responses:
        '200':
          description: SUCCESS
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422SendEmail'
  /{guides-type}/{document-id}/email-document.json:
    put:
      summary: Send Guide by Email
      operationId: sendGuideEmail
      tags:
        - Guides
      parameters:
        - $ref: '#/components/parameters/DocumentTypeGuideParam'
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailDocumentRequest'
      responses:
        '200':
          description: SUCCESS
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422SendEmail'
  /estimates.json:
    get:
      summary: List All
      operationId: listEstimates
      tags:
        - Estimates
      description: Returns a list of estimates (Quotes, Proformas, Fees Notes).
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/ListEstimatesQueryParamns'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimatesListAll'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
  /api/pdf/{document-id}.json:
    get:
      summary: Generate PDF
      operationId: generatePdf
      tags:
        - Invoices
        - Estimates
        - Guides
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
        - name: second_copy
          in: query
          schema:
            type: boolean
            example: false
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PdfResponse'
        '202':
          description: ACCEPTED
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
  /api/qr_codes/{document-id}.json:
    get:
      summary: Get QR Code
      operationId: getQrCode
      tags:
        - Invoices
        - Guides
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QrCodeResponse'
        '202':
          description: ACCEPTED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/202QRCode'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404QRCode'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422QRCode'
  /document/{document-id}/related_documents.json:
    get:
      summary: Related Documents
      operationId: relatedDocs
      tags:
        - Invoices
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/200RelatedDocuments'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
  /documents/{document-id}/partial_payments.json:
    post:
      summary: Generate Payment
      operationId: generatePayment
      tags:
        - Invoices
      parameters:
        - $ref: '#/components/parameters/DocumentIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentRequest'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422GeneratePayment'
  /receipts/{receipt-id}/change-state.json:
    put:
      summary: Cancel Payment
      operationId: cancelReceipt
      tags:
        - Invoices
      parameters:
        - name: receipt-id
          in: path
          required: true
          schema:
            type: integer
            example: 42
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelPaymentRequest'
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Documents'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CancelPayment'
  /guides.json:
    get:
      summary: List All
      operationId: listGuides
      tags:
        - Guides
      description: Returns a list of guides (Shippings, Transports and Devolutions).
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/ListGuidesQueryParamns'
      responses:
        '200':
          description: >
            SUCCESS 


            Creates a new quote, proforma or fees_note.


            #### Possible values for field atcud:


            * ABCD1234-1 (or similar) - Unique document identifier to the Tax
            Authority, when the sequence is registered.

            * N/D - The document's sequence is relevant for ATCUD but is not
            registered in the Tax Authority.

            * N/A - The document's sequence is not relevant for ATCUD and is not
            registered in the Tax Authority.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GuideListAll'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
  /api/export_saft.json:
    get:
      summary: Export Saft
      operationId: export_saft
      tags:
        - SAF-T
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
        - $ref: '#/components/parameters/SaftExportQueryParams'
      responses:
        '200':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Saft200Response'
        '202':
          description: ACCEPTED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Saft202Response'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Saft422Response'
        '500':
          description: FAILED TO GENERATE SAF-T
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Saft500Response'
  /sequences/{sequence_id}/register.json:
    put:
      summary: Register Sequence
      operationId: registerSequence
      tags:
        - Sequences
      description: Registers a document sequence with the Tax Authority (AT).
      parameters:
        - $ref: '#/components/parameters/SequenceIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            OK


            <br>


            **Possible values for fields `current_<document
            type>_validation_code`:**


            | Value | Description |

            | :--- | :--- |

            | **ABCD1234** | Validation code for each sequence that is
            registered in the Tax Authority. |

            | **N/D** | The sequence is relevant for ATCUD but is not registered
            in the Tax Authority. |

            | **N/A** | The sequence is not relevant for ATCUD and is not
            registered in the Tax Authority. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SequenceResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sequence006Response'
        '409':
          description: |
            CONFLICT

            **Available codes:**
            | Code | Description |
            | :--- | :--- |
            | **005** | All sequences are registered. |
            | **008** | The sequence is already being registered. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sequence005Response'
        '422':
          description: >
            UNPROCESSABLE ENTITY


            **Available codes:**

            | Code | Description |

            | :--- | :--- |

            | **001** | Sequence name not allowed. |

            | **002** | Invalid Tax Authority credentials. |

            | **003** | Account fiscal ID doesn’t have open activity in Tax
            Authority. |

            | **004** | Account is not portuguese. |

            | **007** | All Sequences are registered in AT. |

            | **000** | Unknown error. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sequence001Response'
  /sequences.json:
    get:
      summary: List All Sequences
      operationId: listSequences
      tags:
        - Sequences
      description: Returns all your sequences.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            Success.


            <br>


            **Possible values for fields `current_<document
            type>_validation_code`:**


            | Value | Description |

            | :--- | :--- |

            | **ABCD1234** | Validation code for each sequence that is
            registered in the Tax Authority. |

            | **N/D** | The sequence is relevant for ATCUD but is not registered
            in the Tax Authority. |

            | **N/A** | The sequence is not relevant for ATCUD and is not
            registered in the Tax Authority. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SequenceResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
    post:
      summary: Create Sequence
      operationId: createSequence
      tags:
        - Sequences
      description: >
        Creates and registers a new sequence. 

        For portuguese accounts, it’s necessary to have AT credentials
        configured.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SequenceCreateRequest'
      responses:
        '201':
          description: >
            SUCCESS. Created.


            <br>


            **Possible values for fields `current_<document
            type>_validation_code`:**


            | Value | Description |

            | :--- | :--- |

            | **ABCD1234** | Validation code for each sequence that is
            registered in the Tax Authority. |

            | **N/D** | The sequence is relevant for ATCUD but is not registered
            in the Tax Authority. |

            | **N/A** | The sequence is not relevant for ATCUD and is not
            registered in the Tax Authority. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SequenceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '409':
          description: |
            CONFLICT

            **Available codes:**
            | Code | Description |
            | :--- | :--- |
            | **006** | The sequence is already being registered. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sequence006Response'
        '422':
          description: >
            UNPROCESSABLE ENTITY


            **Available codes:**

            | Code | Description |

            | :--- | :--- |

            | **001** | Sequence name not allowed. |

            | **002** | Sequence already exists. |

            | **003** | Invalid sequence. |

            | **004** | Invalid Tax Authority credentials. |

            | **005** | Account fiscal ID doesn’t have open activity in Tax
            Authority. |

            | **000** | Unknown error. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sequence001Response'
  /sequences/{sequence_id}.json:
    get:
      summary: Get Sequence
      operationId: getSequence
      tags:
        - Sequences
      description: Returns a specific sequence.
      parameters:
        - $ref: '#/components/parameters/SequenceIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: >
            Success.


            <br>


            **Possible values for fields `current_<document
            type>_validation_code`:**


            | Value | Description |

            | :--- | :--- |

            | **ABCD1234** | Validation code for each sequence that is
            registered in the Tax Authority. |

            | **N/D** | The sequence is relevant for ATCUD but is not registered
            in the Tax Authority. |

            | **N/A** | The sequence is not relevant for ATCUD and is not
            registered in the Tax Authority. |
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SequenceGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
  /sequences/{sequence_id}/set_current.json:
    put:
      summary: Set Sequence as Default
      operationId: setSequenceDefault
      tags:
        - Sequences
      description: Sets a specific sequence as the default.
      parameters:
        - $ref: '#/components/parameters/SequenceIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: SUCCESS
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
  /taxes.json:
    get:
      summary: List All Taxes
      operationId: listTaxes
      tags:
        - Taxes
      description: Returns all your taxes.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaxesResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
    post:
      summary: Create Taxes
      operationId: createTax
      tags:
        - Taxes
      description: Creates a new tax.
      parameters:
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaxesCreateRequest'
      responses:
        '201':
          description: SUCCESS
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaxesGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422CreateTaxes'
  /taxes/{taxes_id}.json:
    get:
      summary: Get Taxes
      operationId: getTax
      tags:
        - Taxes
      description: Returns a specific tax.
      parameters:
        - $ref: '#/components/parameters/TaxesIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaxesGetResponse'
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
    put:
      summary: Update Taxes
      operationId: updateTax
      tags:
        - Taxes
      description: Updates a tax.
      parameters:
        - $ref: '#/components/parameters/TaxesIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaxesCreateRequest'
      responses:
        '200':
          description: Success
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
        '422':
          description: UNPROCESSABLE ENTITY
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/422UpdateTaxes'
    delete:
      summary: Delete Tax
      operationId: deleteTax
      tags:
        - Taxes
      description: Deletes a tax.
      parameters:
        - $ref: '#/components/parameters/TaxesIdParam'
        - $ref: '#/components/parameters/ApiKeyParam'
      responses:
        '200':
          description: Success
        '401':
          description: ACCESS DENIED
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/401'
        '404':
          description: NOT FOUND
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: query
      name: api_key
  parameters:
    ApiKeyParam:
      name: api_key
      in: query
      required: true
      schema:
        type: string
        example: YOUR_API_KEY
      description: Your API Key.
    DocumentTypeParam:
      name: document-type
      in: path
      required: true
      schema:
        type: string
        enum:
          - invoices
          - invoice_receipts
          - simplified_invoices
          - credit_notes
          - debit_notes
          - receipts
          - quotes
          - proformas
          - fees_notes
          - shippings
          - transports
          - devolutions
      description: The type of the document.
    DocumentTypeInvoiceParam:
      name: invoices-type
      in: path
      required: true
      schema:
        type: string
        enum:
          - invoices
          - invoice_receipts
          - simplified_invoices
          - credit_notes
          - debit_notes
      description: The type of the invoice document.
    DocumentTypeEstimateParam:
      name: estimates-type
      in: path
      required: true
      schema:
        type: string
        enum:
          - quotes
          - proformas
          - fees_notes
      description: The type of the estimate document.
    DocumentTypeGuideParam:
      name: guides-type
      in: path
      required: true
      schema:
        type: string
        enum:
          - shippings
          - transports
          - devolutions
      description: The type of the guide document.
    DocumentIdParam:
      name: document-id
      in: path
      required: true
      schema:
        type: integer
        example: 1050
      description: The ID of the document.
    AccountIdParam:
      name: account-id
      in: path
      required: true
      schema:
        type: integer
        example: 1
    ListInvoicesQueryParamns:
      name: Query Parameters
      in: query
      style: form
      explode: true
      schema:
        $ref: '#/components/schemas/QueryParamns'
      description: Click to expand options.
    ListEstimatesQueryParamns:
      name: Query Parameters
      in: query
      style: form
      explode: true
      schema:
        $ref: '#/components/schemas/EstimateFilters'
      description: Click to expand options.
    ListGuidesQueryParamns:
      name: Query Parameters
      in: query
      style: form
      explode: true
      schema:
        $ref: '#/components/schemas/GuideQueryParamns'
      description: Click to expand options.
    SaftExportQueryParams:
      name: Saft Params
      in: query
      style: form
      explode: true
      required: true
      schema:
        $ref: '#/components/schemas/SaftExportParams'
      description: Click to expand options.
    SequenceIdParam:
      name: sequence_id
      in: path
      required: true
      description: ID of the sequence to register.
      schema:
        type: string
        example: '12345'
    TaxesIdParam:
      name: taxes_id
      in: path
      required: true
      description: ID of the sequence to register.
      schema:
        type: string
        example: '12345'
  schemas:
    '202':
      type: object
      properties:
        accepted:
          type: object
          properties:
            code:
              type: string
              example: '202'
            message:
              type: string
              example: >-
                The request will be processed. You need to keep requesting until
                you get a response with HTTP status code 200.
    '400':
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '400'
            message:
              type: string
              example: Some parameters were incorrect.
    '401':
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Invalid API key
    '409':
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '409'
            message:
              type: string
              example: There's an ongoing document creation with the provided UID.
    '422':
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '422'
            message:
              type: string
              example: Some parameters were incorrect.
    AccountCreateRequest:
      type: object
      required:
        - account
      properties:
        account:
          type: object
          required:
            - organization_name
            - email
            - password
            - terms
          properties:
            first_name:
              type: string
              example: John
            last_name:
              type: string
              example: Doe
            organization_name:
              type: string
              example: My Company
            phone:
              type: string
              example: '912345678'
            email:
              type: string
              example: john.doe@example.com
            password:
              type: string
              example: secret123
            fiscal_id:
              type: string
              example: '500100200'
            tax_country:
              type: string
              enum:
                - '1'
                - '2'
                - '3'
              example: '1'
            language:
              type: string
              enum:
                - pt
                - en
                - es
              example: pt
            terms:
              type: string
              enum:
                - '1'
                - '0'
              example: '1'
            marketing:
              type: string
              enum:
                - '1'
                - '0'
              example: '0'
    AccountCreateSuccess:
      type: object
      properties:
        account:
          type: object
          properties:
            id:
              type: string
              example: '12345'
            name:
              type: string
              example: My Company
            url:
              type: string
              example: https://mycompany.app.invoicexpress.com
            api_key:
              type: string
              example: abc123xyz456
            state:
              type: string
              example: active
    AccountGetSuccess:
      type: object
      properties:
        account:
          type: object
          properties:
            organization_name:
              type: string
              example: My Company
            fiscal_id:
              type: string
              example: '500100200'
            email:
              type: string
              example: john.doe@example.com
            state:
              type: string
              example: active
            at_configured:
              type: boolean
              example: true
            trial:
              type: boolean
              example: true
    AccountUpdateRequest:
      type: object
      required:
        - account
      properties:
        account:
          type: object
          required:
            - organization_name
            - email
            - password
            - terms
          properties:
            first_name:
              type: string
              example: My New Company Name
            last_name:
              type: string
              example: My New Company Name
            organization_name:
              type: string
              example: My New Company Name
            phone:
              type: string
              example: '210000000'
            email:
              type: string
              example: billing@company.com
            password:
              type: string
              example: secret123
            fiscal_id:
              type: string
              description: Cannot be changed
              example: '500100200'
            address:
              type: string
              example: Main Street, 123
            city:
              type: string
              example: Lisbon
            postal_code:
              type: string
              example: 1000-001
            website:
              type: string
              example: www.company.com
            fax:
              type: string
              example: '210000001'
            terms:
              type: string
              enum:
                - '1'
                - '0'
              example: '1'
            credentials:
              $ref: '#/components/schemas/Credentials'
    AccountUpdateSuccess:
      type: object
      properties:
        Response:
          type: object
          properties:
            code:
              type: string
              example: '200'
            message:
              type: string
              example: Success
    Credentials:
      type: object
      description: AT Credentials.
      required:
        - username
        - password
      properties:
        username:
          type: string
          example: 500100200/1
        password:
          type: string
          example: cGFzc3dvcmQ=
        type:
          type: string
          enum:
            - AT
          default: AT
        context:
          type: string
          enum:
            - Sequences
          default: Sequences
    AtCommunicationRequest:
      type: object
      required:
        - at_communication
      properties:
        at_communication:
          type: object
          required:
            - at_subuser
            - at_password
            - communication_type
          properties:
            at_subuser:
              type: string
              example: 500100200/1
            at_password:
              type: string
              example: cGFzc3dvcmQ=
            communication_type:
              type: string
              enum:
                - auto
                - manual
                - guides
                - portal_at
              example: auto
    AtCommunicationSuccess:
      type: object
      properties:
        success:
          type: string
          example: 'true'
    InvoiceCreateRequest:
      type: object
      description: Document details.
      required:
        - invoice
      properties:
        invoice:
          $ref: '#/components/schemas/CreateBody'
        proprietary_uid:
          type: string
          example: uuid-123
    InvoiceUpdateRequest:
      type: object
      description: Document details.
      required:
        - invoice
      properties:
        invoice:
          $ref: '#/components/schemas/CreateBody'
    CreateBody:
      type: object
      description: Invoice Body
      required:
        - date
        - due_date
        - client
        - items
      properties:
        date:
          type: string
          example: 22/11/2025
          description: dd/mm/yyyy
        due_date:
          type: string
          example: 22/12/2025
          description: dd/mm/yyyy
        reference:
          type: string
          example: PO-999
        observations:
          type: string
          example: Services rendered
        retention:
          type: string
          example: '0'
        tax_exemption:
          type: string
          example: M00
        sequence_id:
          type: string
          example: '123456'
        manual_sequence_number:
          type: string
        client:
          $ref: '#/components/schemas/ClientRequest'
        items:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceItemRequest'
        mb_reference:
          type: string
          enum:
            - '0'
            - '1'
          example: '1'
        owner_invoice_id:
          type: integer
          example: 1049
        tax_exemption_reason:
          type: string
          example: M00
        currency_code:
          type: string
          example: USD
        rate:
          type: string
          example: '1.10'
        plugin_id:
          type: string
          example: plugin_123
        global_discount:
          $ref: '#/components/schemas/GlobalDiscountRequest'
    ClientRequest:
      type: object
      description: Client Details.
      required:
        - name
        - code
      properties:
        name:
          type: string
          example: Client A
        code:
          type: string
          example: CLI-001
        email:
          type: string
          example: client@mail.com
        address:
          type: string
          example: Street A
        city:
          type: string
          example: Lisbon
        postal_code:
          type: string
          example: 1000-100
        fiscal_id:
          type: string
          example: '500999888'
        country:
          type: string
          example: Portugal
        website:
          type: string
          example: www.client-a.com
        phone:
          type: string
          example: '912345678'
        fax:
          type: string
          example: '212345678'
        observations:
          type: string
          example: VIP Client
    InvoiceItemRequest:
      type: object
      description: Line Item.
      required:
        - name
        - description
        - unit_price
        - quantity
      properties:
        name:
          type: string
          example: Consulting
        description:
          type: string
          example: IT Services
        unit_price:
          type: number
          example: 50
        quantity:
          type: number
          example: 2
        unit:
          type: string
          example: hour
        discount:
          type: number
          example: 0
        tax:
          $ref: '#/components/schemas/InvoiceTaxRequest'
    InvoiceTaxRequest:
      type: object
      properties:
        name:
          type: string
          example: IVA23
    GlobalDiscountRequest:
      type: object
      properties:
        value_type:
          type: string
          enum:
            - percentage
            - absolute
          example: percentage
        value:
          type: number
          example: 10
    ChangeStateInvoiceRequest:
      type: object
      required:
        - invoice
      properties:
        invoice:
          type: object
          required:
            - state
          properties:
            state:
              type: string
              enum:
                - finalized
                - canceled
                - deleted
                - accepted
                - refused
                - settled
              example: finalized
            message:
              type: string
              example: Wrong value
    EmailDocumentRequest:
      type: object
      required:
        - message
      properties:
        message:
          type: object
          required:
            - client
          properties:
            client:
              type: object
              required:
                - email
                - save
              properties:
                email:
                  type: string
                  example: dest@mail.com
                save:
                  type: string
                  enum:
                    - '0'
                    - '1'
                  example: '1'
            subject:
              type: string
              example: Invoice
            body:
              type: string
              example: Attached.
            cc:
              type: string
              example: cc@mail.com
            bcc:
              type: string
              example: bcc@mail.com
            logo:
              type: string
              enum:
                - '0'
                - '1'
              example: '1'
    PaymentRequest:
      type: object
      required:
        - partial_payment
      properties:
        partial_payment:
          type: object
          required:
            - amount
          properties:
            amount:
              type: number
              example: 10
            payment_mechanism:
              type: string
              enum:
                - TB
                - MB
                - CC
              example: TB
            note:
              type: string
              example: Transfer
            serie:
              type: string
            payment_date:
              type: string
              example: 22/11/2025
    CancelPaymentRequest:
      type: object
      required:
        - receipt
      properties:
        receipt:
          type: object
          required:
            - state
            - message
          properties:
            state:
              type: string
              enum:
                - canceled
              example: canceled
            message:
              type: string
              example: Error
    ChangeStateEstimateRequest:
      type: object
      required:
        - quote
      properties:
        quote:
          type: object
          required:
            - state
          properties:
            state:
              type: string
              enum:
                - finalized
                - canceled
                - deleted
                - accepted
                - refused
              example: finalized
            message:
              type: string
              example: Wrong value
    EstimatesItemRequest:
      type: object
      description: Line Item.
      required:
        - name
        - description
        - unit_price
        - quantity
      properties:
        name:
          type: string
          example: Consulting
        description:
          type: string
          example: IT Services
        unit_price:
          type: number
          example: 50
        quantity:
          type: number
          example: 2
        unit:
          type: string
          example: hour
        discount:
          type: number
          example: 0
        tax:
          $ref: '#/components/schemas/EstimatesTaxRequest'
    EstimatesTaxRequest:
      type: object
      properties:
        name:
          type: string
          example: IVA23
    EstimateCreateRequest:
      type: object
      required:
        - quote
      properties:
        quote:
          type: object
          required:
            - client
            - items
          properties:
            date:
              type: string
              example: 22/11/2025
              description: dd/mm/yyyy
            due_date:
              type: string
              example: 22/12/2025
              description: dd/mm/yyyy
            reference:
              type: string
              example: PO-999
            observations:
              type: string
              example: Services rendered
            retention:
              type: string
              example: '0'
            tax_exemption:
              type: string
              example: M00
            sequence_id:
              type: string
              example: '123456'
            manual_sequence_number:
              type: string
            client:
              $ref: '#/components/schemas/ClientRequest'
            items:
              type: array
              items:
                $ref: '#/components/schemas/EstimatesItemRequest'
            mb_reference:
              type: string
              enum:
                - '0'
                - '1'
              example: '1'
            auto_add_related_document:
              type: string
              example: '0'
            tax_exemption_reason:
              type: string
              example: M00
    GuideGetResponse:
      type: object
      properties:
        shipping:
          type: object
          properties:
            id:
              type: integer
              example: 541797
            status:
              type: string
              example: final
            archived:
              type: boolean
              example: false
            type:
              type: string
              example: Shipping
            sequence_number:
              type: string
              example: 1/D
            inverted_sequence_number:
              type: string
              example: D/1
            atcud:
              type: string
              example: ABCD1234-1
            date:
              type: string
              example: 13/07/2017
            due_date:
              type: string
              example: foo
            reference:
              type: string
              example: foo
            observations:
              type: string
              example: foo
            retention:
              type: string
              example: foo
            permalink:
              type: string
              example: >-
                https://www.app.invoicexpress.com/documents/541797d75bbee48911934cbd4a4294946a324295f52b08
            saft_hash:
              type: string
              example: vaDf
            sum:
              type: number
              example: 1
            discount:
              type: number
              example: 0
            before_taxes:
              type: number
              example: 1
            taxes:
              type: number
              example: 0.07
            total:
              type: number
              example: 1.07
            currency:
              type: string
              example: Euro
            address_from:
              type: object
              properties:
                country:
                  type: string
                  example: Portugal
                postal_code:
                  type: string
                  example: 1050-083
                detail:
                  type: string
                  example: Avenida Duque D'Avila, 46 - 3ºA
                city:
                  type: string
                  example: Lisboa
            address_to:
              type: object
              properties:
                country:
                  type: string
                  example: Portugal
                postal_code:
                  type: string
                  example: 4000-327
                detail:
                  type: string
                  example: Avenida dos Aliados
                city:
                  type: string
                  example: Porto
            client:
              type: object
              properties:
                id:
                  type: integer
                  example: 1310176
                name:
                  type: string
                  example: John
                country:
                  type: string
                  example: Portugal
            items:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    example: iPhone
                  description:
                    type: string
                    example: foo
                  unit_price:
                    type: string
                    example: '1.0'
                  unit:
                    type: string
                    example: foo
                  quantity:
                    type: string
                    example: '1.0'
                  tax:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 31597
                      name:
                        type: string
                        example: IVA7
                      value:
                        type: number
                        example: 7
                  discount:
                    type: number
                    example: 0
                  subtotal:
                    type: number
                    example: 1
                  tax_amount:
                    type: number
                    example: 0.07
                  discount_amount:
                    type: number
                    example: 0
                  total:
                    type: number
                    example: 1.07
            sequence_id:
              type: string
              example: '12345'
            tax_exemption:
              type: string
              example: M01
            at_doc_code_id:
              type: string
              example: '999'
            license_plate:
              type: string
              example: 11-AA-22
    ChangeStateGuideRequest:
      type: object
      required:
        - shipping
      properties:
        shipping:
          type: object
          required:
            - state
          properties:
            state:
              type: string
              enum:
                - finalized
                - canceled
                - deleted
              example: finalized
            message:
              type: string
              example: Wrong value
    GuideListAllResponse:
      $ref: '#/components/schemas/GuideListAll'
    GuideCreateRequest:
      type: object
      required:
        - shipping
      properties:
        shipping:
          type: object
          required:
            - date
            - due_date
            - loaded_at
            - address_from
            - address_to
            - client
            - items
          properties:
            date:
              type: string
              description: dd/mm/yyyy
              example: 03/12/2017
            due_date:
              type: string
              description: dd/mm/yyyy
              example: 03/12/2017
            loaded_at:
              type: string
              description: dd/mm/yyyy HH:mm:ss
              example: 02/12/2017 19:00:00
            license_plate:
              type: string
              example: 11-AA-22
            address_from:
              type: object
              required:
                - detail
                - city
                - postal_code
                - country
              properties:
                detail:
                  type: string
                  example: Rua 5
                city:
                  type: string
                  example: Lisboa
                postal_code:
                  type: string
                  example: 1000-555
                country:
                  type: string
                  example: Portugal
            address_to:
              type: object
              required:
                - detail
                - city
                - postal_code
                - country
              properties:
                detail:
                  type: string
                  example: Avenida 10
                city:
                  type: string
                  example: Porto
                postal_code:
                  type: string
                  example: 2000-555
                country:
                  type: string
                  example: Portugal
            reference:
              type: string
              example: '999'
            observations:
              type: string
              example: Observations
            retention:
              type: string
              example: '0'
            tax_exemption:
              type: string
              example: M01
            sequence_id:
              type: string
              example: '12345'
            manual_sequence_number:
              type: string
              example: '1'
            client:
              type: object
              required:
                - name
                - code
              properties:
                name:
                  type: string
                  example: Client Name
                code:
                  type: string
                  example: A1
                email:
                  type: string
                  example: foo@bar.com
                address:
                  type: string
                  example: Saldanha
                city:
                  type: string
                  example: Lisbon
                postal_code:
                  type: string
                  example: 1050-555
                country:
                  type: string
                  example: Portugal
                fiscal_id:
                  type: string
                  example: '508000000'
                website:
                  type: string
                  example: www.website.com
                phone:
                  type: string
                  example: '910000000'
                fax:
                  type: string
                  example: '210000000'
                observations:
                  type: string
                  example: Observations
            items:
              type: array
              items:
                type: object
                required:
                  - name
                  - description
                  - unit_price
                  - quantity
                properties:
                  name:
                    type: string
                    example: Item Name
                  description:
                    type: string
                    example: Item Description
                  unit_price:
                    type: string
                    example: '100'
                  quantity:
                    type: string
                    example: '5'
                  unit:
                    type: string
                    example: service
                  discount:
                    type: string
                    example: '50'
                  tax:
                    type: object
                    properties:
                      name:
                        type: string
                        example: IVA23
            tax_exemption_reason:
              type: string
              example: M00
            load_site:
              type: string
              example: Lisbon, Portugal
            delivery_site:
              type: string
              example: Madrid, Spain
    Saft200Response:
      type: object
      properties:
        Url:
          type: string
          example: https://some.url
    Saft202Response:
      type: object
      properties:
        message:
          type: string
          example: >-
            The SAF-T file generation was started. Please keep requesting until
            you get back the url.
    Saft500Response:
      type: object
      properties:
        message:
          type: string
          example: Error generating SAF-T. Please try again.
    Saft422Response:
      type: object
      properties:
        message:
          type: string
          example: There aren't any documents to export on the selected period.
    SequenceResponse:
      type: object
      properties:
        sequences:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 146090
              serie:
                type: string
                example: '2022'
              default_sequence:
                type: integer
                example: 1
              current_invoice_number:
                type: integer
                example: 0
              current_invoice_sequence_id:
                type: integer
                example: 146090
              current_invoice_validation_code:
                type: string
                example: ABCD1230
              current_invoice_receipt_number:
                type: integer
                example: 0
              current_invoice_receipt_sequence_id:
                type: integer
                example: 146092
              current_invoice_receipt_validation_code:
                type: string
                example: ABCD1231
              current_simplified_invoice_number:
                type: integer
                example: 0
              current_simplified_invoice_sequence_id:
                type: integer
                example: 146091
              current_simplified_invoice_validation_code:
                type: string
                example: ABCD1232
              current_credit_note_number:
                type: integer
                example: 0
              current_credit_note_sequence_id:
                type: integer
                example: 146095
              current_credit_note_validation_code:
                type: string
                example: ABCD1233
              current_debit_note_number:
                type: integer
                example: 0
              current_debit_note_sequence_id:
                type: integer
                example: 146094
              current_debit_note_validation_code:
                type: string
                example: ABCD1234
              current_receipt_number:
                type: integer
                example: 0
              current_receipt_sequence_id:
                type: integer
                example: 146093
              current_receipt_validation_code:
                type: string
                example: ABCD1235
              current_shipping_number:
                type: integer
                example: 0
              current_shipping_sequence_id:
                type: integer
                example: 146104
              current_shipping_validation_code:
                type: string
                example: ABCD1236
              current_transport_number:
                type: integer
                example: 0
              current_transport_sequence_id:
                type: integer
                example: 146106
              current_transport_validation_code:
                type: string
                example: ABCD1237
              current_devolution_number:
                type: integer
                example: 0
              current_devolution_sequence_id:
                type: integer
                example: 146105
              current_devolution_validation_code:
                type: string
                example: ABCD1238
              current_proforma_number:
                type: integer
                example: 0
              current_proforma_sequence_id:
                type: integer
                example: 146102
              current_proforma_validation_code:
                type: string
                example: ABCD1239
              current_quote_number:
                type: integer
                example: 0
              current_quote_sequence_id:
                type: integer
                example: 146101
              current_quote_validation_code:
                type: string
                example: ABCD1240
              current_fees_note_number:
                type: integer
                example: 0
              current_fees_note_sequence_id:
                type: integer
                example: 146103
              current_fees_note_validation_code:
                type: string
                example: N/A
              current_vat_moss_invoice_number:
                type: integer
                example: 0
              current_vat_moss_invoice_sequence_id:
                type: integer
                example: 146097
              current_vat_moss_invoice_validation_code:
                type: string
                example: N/A
              current_vat_moss_credit_note_number:
                type: integer
                example: 0
              current_vat_moss_credit_note_sequence_id:
                type: integer
                example: 146098
              current_vat_moss_credit_note_validation_code:
                type: string
                example: N/A
              current_vat_moss_receipt_number:
                type: integer
                example: 0
              current_vat_moss_receipt_sequence_id:
                type: integer
                example: 146099
              current_vat_moss_receipt_validation_code:
                type: string
                example: N/A
    SequenceGetResponse:
      type: object
      properties:
        sequences:
          type: object
          properties:
            id:
              type: integer
              example: 146090
            serie:
              type: string
              example: '2022'
            default_sequence:
              type: integer
              example: 1
            current_invoice_number:
              type: integer
              example: 0
            current_invoice_sequence_id:
              type: integer
              example: 146090
            current_invoice_validation_code:
              type: string
              example: ABCD1230
            current_invoice_receipt_number:
              type: integer
              example: 0
            current_invoice_receipt_sequence_id:
              type: integer
              example: 146092
            current_invoice_receipt_validation_code:
              type: string
              example: ABCD1231
            current_simplified_invoice_number:
              type: integer
              example: 0
            current_simplified_invoice_sequence_id:
              type: integer
              example: 146091
            current_simplified_invoice_validation_code:
              type: string
              example: ABCD1232
            current_credit_note_number:
              type: integer
              example: 0
            current_credit_note_sequence_id:
              type: integer
              example: 146095
            current_credit_note_validation_code:
              type: string
              example: ABCD1233
            current_debit_note_number:
              type: integer
              example: 0
            current_debit_note_sequence_id:
              type: integer
              example: 146094
            current_debit_note_validation_code:
              type: string
              example: ABCD1234
            current_receipt_number:
              type: integer
              example: 0
            current_receipt_sequence_id:
              type: integer
              example: 146093
            current_receipt_validation_code:
              type: string
              example: ABCD1235
            current_shipping_number:
              type: integer
              example: 0
            current_shipping_sequence_id:
              type: integer
              example: 146104
            current_shipping_validation_code:
              type: string
              example: ABCD1236
            current_transport_number:
              type: integer
              example: 0
            current_transport_sequence_id:
              type: integer
              example: 146106
            current_transport_validation_code:
              type: string
              example: ABCD1237
            current_devolution_number:
              type: integer
              example: 0
            current_devolution_sequence_id:
              type: integer
              example: 146105
            current_devolution_validation_code:
              type: string
              example: ABCD1238
            current_proforma_number:
              type: integer
              example: 0
            current_proforma_sequence_id:
              type: integer
              example: 146102
            current_proforma_validation_code:
              type: string
              example: ABCD1239
            current_quote_number:
              type: integer
              example: 0
            current_quote_sequence_id:
              type: integer
              example: 146101
            current_quote_validation_code:
              type: string
              example: ABCD1240
            current_fees_note_number:
              type: integer
              example: 0
            current_fees_note_sequence_id:
              type: integer
              example: 146103
            current_fees_note_validation_code:
              type: string
              example: N/A
            current_vat_moss_invoice_number:
              type: integer
              example: 0
            current_vat_moss_invoice_sequence_id:
              type: integer
              example: 146097
            current_vat_moss_invoice_validation_code:
              type: string
              example: N/A
            current_vat_moss_credit_note_number:
              type: integer
              example: 0
            current_vat_moss_credit_note_sequence_id:
              type: integer
              example: 146098
            current_vat_moss_credit_note_validation_code:
              type: string
              example: N/A
            current_vat_moss_receipt_number:
              type: integer
              example: 0
            current_vat_moss_receipt_sequence_id:
              type: integer
              example: 146099
            current_vat_moss_receipt_validation_code:
              type: string
              example: N/A
    SequenceCreateRequest:
      type: object
      required:
        - sequence
      properties:
        sequence:
          type: object
          required:
            - serie
          properties:
            serie:
              type: string
              description: Series name
              example: '2023'
            default_sequence:
              type: string
              description: >-
                If "1", this sequence is chosen as the default sequence. Other
                values are ignored.
              example: '1'
    Sequence006Response:
      type: object
      properties:
        errors:
          type: object
          properties:
            code:
              type: string
              example: '006'
            message:
              type: string
              example: The sequence doesn't exist.
    Sequence005Response:
      type: object
      properties:
        errors:
          type: object
          properties:
            code:
              type: string
              example: '005'
            message:
              type: string
              example: All sequences are registered.
    Sequence001Response:
      type: object
      properties:
        errors:
          type: object
          properties:
            code:
              type: string
              example: '001'
            message:
              type: string
              example: Sequence name not allowed.
    TaxesResponse:
      type: object
      properties:
        taxes:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 31554
              name:
                type: string
                example: IVA23
              value:
                type: number
                example: 23
              region:
                type: string
                example: PT
              code:
                type: string
                example: NOR
              default_tax:
                type: integer
                example: 1
                description: 1 if it is the default tax, 0 otherwise
    TaxesGetResponse:
      type: object
      properties:
        tax:
          type: object
          properties:
            id:
              type: integer
              example: 31540
            name:
              type: string
              example: IVA23
            value:
              type: number
              example: 23
            region:
              type: string
              example: PT
            code:
              type: string
              example: NOR
            default_tax:
              type: integer
              example: 1
              description: 1 if it is the default tax, 0 otherwise
    TaxesCreateRequest:
      type: object
      required:
        - tax
      properties:
        tax:
          type: object
          required:
            - name
            - value
          properties:
            name:
              type: string
              description: Tax name
              example: IVA23
            value:
              type: string
              description: Tax value (%)
              example: '23.0'
            region:
              type: string
              description: >
                Tax region. Required to export SAF-T PT.


                Must be one of: `PT`, `PT-AC`, `PT-MA`, `Desconhecido`, or
                country codes.
              example: PT
            code:
              type: string
              description: >
                Tax code.


                Must be one of: `NOR` (Normal), `INT` (Intermediate), `RED`
                (Reduced), `OUT` (Other), `ISE` (Exempt).
              enum:
                - NOR
                - INT
                - RED
                - OUT
                - ISE
              example: NOR
            default_tax:
              type: integer
              description: If "1", the tax is chosen as the default tax on your account.
              example: 1
    422UpdateTaxes:
      type: object
      properties:
        base:
          type: array
          items:
            type: string
          example:
            - Tax region is empty
    422CreateTaxes:
      type: object
      properties:
        name:
          type: array
          items:
            type: string
          example:
            - is not available.
    InvoiceGetResponse:
      type: object
      properties:
        invoice:
          $ref: '#/components/schemas/FullDocumentObject'
    EstimateGetResponse:
      type: object
      properties:
        quote:
          type: object
          properties:
            id:
              type: integer
              example: 541791
            status:
              type: string
              example: final
            archived:
              type: boolean
              example: false
            type:
              type: string
              example: Quote
            sequence_number:
              type: string
              example: 1/A
            inverted_sequence_number:
              type: string
              example: A/1
            atcud:
              type: string
              example: ABCD1234-1
            date:
              type: string
              example: 12/06/2017
            due_date:
              type: string
              example: 12/06/2017
            reference:
              type: string
              example: foo
            observations:
              type: string
              example: foo
            retention:
              type: string
              example: foo
            permalink:
              type: string
              example: >-
                https://www.app.invoicexpress.com/documents/541791f16ae45a73b703c684a221ef198c10020f3d56a1
            saft_hash:
              type: string
              example: NfTN
            sum:
              type: number
              example: 10
            discount:
              type: number
              example: 0
            before_taxes:
              type: number
              example: 10
            taxes:
              type: number
              example: 2.3
            total:
              type: number
              example: 12.3
            currency:
              type: string
              example: Euro
            sequence_id:
              type: string
              example: '12345'
            tax_exemption:
              type: string
              example: M01
            client:
              $ref: '#/components/schemas/InvoiceClient'
            items:
              type: array
              items:
                $ref: '#/components/schemas/InvoiceItem'
    InvoiceListAllResponse:
      type: object
      properties:
        invoices:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 541793
              status:
                type: string
                example: final
              archived:
                type: boolean
                example: true
              type:
                type: string
                example: Invoice
              sequence_number:
                type: string
                example: A/28
              inverted_sequence_number:
                type: string
                example: A/28
              atcud:
                type: string
                example: ABCD1234-28
              date:
                type: string
                description: dd/mm/yyyy
                example: 27/06/2017
              due_date:
                type: string
                description: dd/mm/yyyy
                example: 27/06/2017
              reference:
                type: string
                example: fb30
              observations:
                type: string
                example: foo
              retention:
                type: string
                example: foo
              permalink:
                type: string
                example: >-
                  https://www.app.invoicexpress.com/documents/541793e1ab2ebd5c06def40c346ffbe0ff2b463eb1c0f0
              saft_hash:
                type: string
                example: Tdik
              sum:
                type: number
                example: 1
              discount:
                type: number
                example: 0
              before_taxes:
                type: number
                example: 1
              taxes:
                type: number
                example: 0.07
              total:
                type: number
                example: 1.07
              currency:
                type: string
                example: Euro
              sequence_id:
                type: string
                example: '12345'
              tax_exemption:
                type: string
                example: M01
              client:
                type: object
                properties:
                  id:
                    type: integer
                    example: 1310176
                  name:
                    type: string
                    example: John
                  country:
                    type: string
                    example: Portugal
              items:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      example: ' iPhone '
                    description:
                      type: string
                      example: foo
                    unit_price:
                      type: string
                      example: '1.0'
                    unit:
                      type: string
                      example: foo
                    quantity:
                      type: string
                      example: '1.0'
                    discount:
                      type: number
                      example: 0
                    subtotal:
                      type: number
                      example: 1
                    tax_amount:
                      type: number
                      example: 0.07
                    discount_amount:
                      type: number
                      example: 0
                    total:
                      type: number
                      example: 1.07
                    tax:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 31597
                        name:
                          type: string
                          example: IVA7
                        value:
                          type: number
                          example: 7
        pagination:
          $ref: '#/components/schemas/Pagination'
    CreateInvoiceResponse:
      type: object
      properties:
        invoice:
          type: object
          properties:
            id:
              type: integer
              example: 2137287
            status:
              type: string
              example: draft
            archived:
              type: boolean
              example: false
            type:
              type: string
              example: Invoice
            sequence_number:
              type: string
              example: 6/G
            inverted_sequence_number:
              type: string
              example: G/6
            atcud:
              type: string
              example: ABCD1234-28
            sequence_id:
              type: string
              example: '12345'
            tax_exemption:
              type: string
              example: M01
            date:
              type: string
              description: dd/mm/yyyy
              example: 04/08/2016
            due_date:
              type: string
              description: dd/mm/yyyy
              example: 19/08/2016
            reference:
              type: string
              example: foo
            observations:
              type: string
              example: foo
            retention:
              type: string
              example: foo
            permalink:
              type: string
              example: >-
                https://www.app.invoicexpress.com/documents/213728738ca780a8de4330cad4a5a556360304bd9c57011
            saft_hash:
              type: string
              example: J4ay
            sum:
              type: number
              example: 24.39
            discount:
              type: number
              example: 0
            before_taxes:
              type: number
              example: 24.39
            taxes:
              type: number
              example: 5.61
            total:
              type: number
              example: 30
            currency:
              type: string
              example: Euro
            client:
              type: object
              properties:
                id:
                  type: integer
                  example: 628535
                name:
                  type: string
                  example: John
                country:
                  type: string
                  example: Portugal
            items:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    example: Large
                  description:
                    type: string
                    example: foo
                  unit_price:
                    type: string
                    example: '24.3902'
                  unit:
                    type: string
                    example: foo
                  quantity:
                    type: string
                    example: '1.0'
                  discount:
                    type: number
                    example: 0
                  subtotal:
                    type: number
                    example: 24.39
                  tax_amount:
                    type: number
                    example: 5.61
                  discount_amount:
                    type: number
                    example: 0
                  total:
                    type: number
                    example: 30
                  tax:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 69166
                      name:
                        type: string
                        example: IVA23
                      value:
                        type: number
                        example: 23
            mb_reference:
              type: object
              properties:
                entity:
                  type: string
                  example: '10611'
                value:
                  type: number
                  example: 30
                reference:
                  type: string
                  example: '952000823'
            global_discount:
              type: object
              properties:
                value_type:
                  type: string
                  example: percentage
                value:
                  type: number
                  example: 50
    FullDocumentListResponse:
      type: object
      properties:
        documents:
          type: array
          items:
            $ref: '#/components/schemas/FullDocumentObject'
        pagination:
          $ref: '#/components/schemas/Pagination'
    PaymentResponse:
      type: object
      properties:
        receipt:
          $ref: '#/components/schemas/FullDocumentObject'
    FullDocumentObject:
      type: object
      properties:
        id:
          type: integer
          example: 2137287
        status:
          type: string
          example: final
        archived:
          type: boolean
          example: false
        type:
          type: string
          example: Invoice
        sequence_number:
          type: string
          example: 6/G
        inverted_sequence_number:
          type: string
          example: G/6
        atcud:
          type: string
          example: ABCD1234-6
        sequence_id:
          type: string
          example: '12345'
        tax_exemption:
          type: string
          example: M01
        date:
          type: string
          example: 04/08/2016
        due_date:
          type: string
          example: 19/08/2016
        reference:
          type: string
          example: ref123
        observations:
          type: string
          example: Observations
        retention:
          type: string
          example: '0'
        permalink:
          type: string
          example: https://www.app.invoicexpress.com/documents/...
        saft_hash:
          type: string
          example: J4ay
        sum:
          type: number
          example: 24.39
        discount:
          type: number
          example: 0
        before_taxes:
          type: number
          example: 24.39
        taxes:
          type: number
          example: 5.61
        total:
          type: number
          example: 30
        currency:
          type: string
          example: Euro
        client:
          $ref: '#/components/schemas/InvoiceClient'
        items:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceItem'
        mb_reference:
          $ref: '#/components/schemas/MbReference'
    InvoiceClient:
      type: object
      properties:
        id:
          type: integer
          example: 628535
        name:
          type: string
          example: John Doe
        code:
          type: string
          example: C1
        country:
          type: string
          example: Portugal
        email:
          type: string
          example: john@example.com
    InvoiceItem:
      type: object
      properties:
        name:
          type: string
          example: Product A
        description:
          type: string
          example: Big Product
        unit_price:
          type: number
          example: 100
        quantity:
          type: number
          example: 1
        unit:
          type: string
          example: un
        discount:
          type: number
          example: 0
        tax:
          type: object
          properties:
            name:
              type: string
              example: IVA23
            value:
              type: number
              example: 23
        total:
          type: number
          example: 123
    MbReference:
      type: object
      properties:
        entity:
          type: string
          example: '10611'
        reference:
          type: string
          example: 123 456 789
        value:
          type: number
          example: 123.45
    PdfResponse:
      type: object
      properties:
        output:
          type: object
          properties:
            pdfUrl:
              type: string
              example: url.pdf
    QrCodeResponse:
      type: object
      properties:
        qr_code:
          type: object
          properties:
            url:
              type: string
              example: url.png
    Pagination:
      type: object
      properties:
        total_entries:
          type: integer
          example: 50
        per_page:
          type: integer
          example: 20
        current_page:
          type: integer
          example: 1
        total_pages:
          type: integer
          example: 3
    422CreateAccount:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Owner Owner is invalid
    422UpdateAccount:
      type: array
      items:
        type: string
      example:
        - fiscal_id
        - is invalid
    422AlreadyUser:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Terms and Conditions should be accepted
    422AtCommunication:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: The field at_subuser has an incorrect size
    404Account:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '404'
            message:
              type: string
              example: The account doesn't exist.
    422CreateInvoice:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: undefined method `match' for 1:Integer
    409CreateInvoice:
      type: object
      properties:
        reason:
          type: string
          example: >-
            There's an ongoing document creation with the provided UID
            UUID41237123189981ddajkls23478y
    422UpdateInvoices:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Elemento client não fornecido
    404Documents:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Document not found
    422ChangeState:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: 'CantHandle: 1 for Invoice'
    202QRCode:
      type: object
      properties:
        qr_code:
          type: object
          properties:
            status:
              type: string
              example: In progress
    404QRCode:
      type: object
      properties:
        error:
          type: string
          example: No document with ID 24563387 was found in this account
    422QRCode:
      type: object
      properties:
        error:
          type: string
          example: >-
            Document with ID 248920464 is still in draft. QR Codes are only
            available for final, canceled or settled documents.
    200RelatedDocuments:
      type: object
      properties:
        documents:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 541793
              status:
                type: string
                example: final
              archived:
                type: boolean
                example: true
              type:
                type: string
                example: Invoice
              sequence_number:
                type: string
                example: 28/A
              inverted_sequence_number:
                type: string
                example: A/28
              atcud:
                type: string
                example: ABCD1234-28
              date:
                type: string
                example: 27/06/2017
              due_date:
                type: string
                example: 27/06/2017
              reference:
                type: string
                example: foo
              observations:
                type: string
                example: foo
              retention:
                type: string
                example: foo
              permalink:
                type: string
                example: >-
                  https://www.app.invoicexpress.com/documents/541793e1ab2ebd5c06def40c346ffbe0ff2b463eb1c0f0
              saft_hash:
                type: string
                example: Tdik
              sum:
                type: number
                example: 1
              discount:
                type: number
                example: 0
              before_taxes:
                type: number
                example: 1
              taxes:
                type: number
                example: 0.07
              total:
                type: number
                example: 1.07
              currency:
                type: string
                example: Euro
              sequence_id:
                type: string
                example: '12345'
              tax_exemption:
                type: string
                example: M01
              client:
                type: object
                properties:
                  id:
                    type: integer
                    example: 1310176
                  name:
                    type: string
                    example: John
                  country:
                    type: string
                    example: Portugal
              items:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      example: ' iPhone '
                    description:
                      type: string
                      example: foo
                    unit_price:
                      type: string
                      example: '1.0'
                    unit:
                      type: string
                      example: foo
                    quantity:
                      type: string
                      example: '1.0'
                    discount:
                      type: number
                      example: 0
                    subtotal:
                      type: number
                      example: 1
                    tax_amount:
                      type: number
                      example: 0.07
                    discount_amount:
                      type: number
                      example: 0
                    total:
                      type: number
                      example: 1.07
                    tax:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 31597
                        name:
                          type: string
                          example: IVA7
                        value:
                          type: number
                          example: 7
    422GeneratePayment:
      type: array
      items:
        type: string
      example:
        - payment_mechanism
        - is invalid
    422CancelPayment:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: 'CantHandle: 1 for Invoice'
    EstimatesListAll:
      type: object
      properties:
        estimates:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 541791
              status:
                type: string
                example: final
              archived:
                type: boolean
                example: false
              type:
                type: string
                example: Quote
              sequence_number:
                type: string
                example: 1/A
              inverted_sequence_number:
                type: string
                example: A/1
              atcud:
                type: string
                example: ABCD1234-1
              date:
                type: string
                example: 12/06/2017
              due_date:
                type: string
                example: 12/06/2017
              reference:
                type: string
                example: foo
              observations:
                type: string
                example: foo
              retention:
                type: string
                example: foo
              permalink:
                type: string
                example: >-
                  https://www.app.invoicexpress.com/documents/541791f16ae45a73b703c684a221ef198c10020f3d56a1
              saft_hash:
                type: string
                example: NfTN
              sum:
                type: number
                example: 10
              discount:
                type: number
                example: 0
              before_taxes:
                type: number
                example: 10
              taxes:
                type: number
                example: 2.3
              total:
                type: number
                example: 12.3
              currency:
                type: string
                example: Euro
              sequence_id:
                type: string
                example: '12345'
              tax_exemption:
                type: string
                example: M01
              client:
                type: object
                properties:
                  id:
                    type: integer
                    example: 1310176
                  name:
                    type: string
                    example: John
                  country:
                    type: string
                    example: Portugal
              items:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                      example: iPhone
                    description:
                      type: string
                      example: foo
                    unit_price:
                      type: string
                      example: '10.0'
                    unit:
                      type: string
                      example: foo
                    quantity:
                      type: string
                      example: '1.0'
                    discount:
                      type: number
                      example: 0
                    subtotal:
                      type: number
                      example: 10
                    tax_amount:
                      type: number
                      example: 2.3
                    discount_amount:
                      type: number
                      example: 0
                    total:
                      type: number
                      example: 12.3
                    tax:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 31567
                        name:
                          type: string
                          example: IVA23
                        value:
                          type: number
                          example: 23
        pagination:
          $ref: '#/components/schemas/Pagination'
    422SendEmail:
      type: object
      properties:
        errors:
          type: object
          properties:
            error:
              type: string
              example: Email is a required field
    422PDF:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '422'
            message:
              type: string
              example: The {document-id} provided is in an invalid state.
    QueryParamns:
      type: object
      required:
        - type[]
        - status[]
        - non_archived
      properties:
        type[]:
          type: array
          items:
            type: string
            enum:
              - Invoice
              - InvoiceReceipt
              - CreditNote
              - DebitNote
              - Receipt
              - CashInvoice
          example:
            - Invoice
          description: Type(s) of document.
        status[]:
          type: array
          items:
            type: string
            enum:
              - draft
              - sent
              - settled
              - canceled
              - second_copy
              - deleted
          example:
            - sent
          description: Status(es) of document.
        non_archived:
          type: boolean
          example: true
          description: Show non-archived documents.
        archived:
          type: boolean
          description: Include archived docs
        text:
          type: string
          description: Filter by client/doc text
        reference:
          type: string
          description: Filter by reference
        date[from]:
          type: string
          description: Start date (dd/mm/yyyy)
        date[to]:
          type: string
          description: End date (dd/mm/yyyy)
        due_date[from]:
          type: string
          description: Due date start
        due_date[to]:
          type: string
          description: Due date end
        total_before_taxes[from]:
          type: number
          description: Min value
        total_before_taxes[to]:
          type: number
          description: Max value
        page:
          type: integer
          description: Page number
        per_page:
          type: integer
          description: Items per page
    EstimateFilters:
      type: object
      required:
        - type[]
        - status[]
        - non_archived
      properties:
        type[]:
          type: array
          items:
            type: string
            enum:
              - Quote
              - Proforma
              - FeesNote
          example:
            - Quote
          description: Type(s) of document.
        status[]:
          type: array
          items:
            type: string
            enum:
              - draft
              - sent
              - accepted
              - refused
              - canceled
              - deleted
          example:
            - sent
          description: Status(es) of document.
        non_archived:
          type: boolean
          example: true
          description: Show non-archived documents.
        archived:
          type: boolean
          description: Include archived docs
        text:
          type: string
          description: Filter by client/doc text
        due_date[from]:
          type: string
          description: Start date (dd/mm/yyyy)
        due_date[to]:
          type: string
          description: End date (dd/mm/yyyy)
        date[from]:
          type: string
          description: Start date (dd/mm/yyyy)
        date[to]:
          type: string
          description: End date (dd/mm/yyyy)
        total_before_taxes[from]:
          type: number
          description: Min value
        total_before_taxes[to]:
          type: number
          description: Max value
        page:
          type: integer
          description: Page number
        per_page:
          type: integer
          description: Items per page
    GuideQueryParamns:
      type: object
      required:
        - type[]
        - status[]
        - non_archived
      properties:
        text:
          type: string
          description: Search for guide, client or item details.
        type[]:
          type: array
          items:
            type: string
            enum:
              - Shipping
              - Transport
              - Devolution
          example:
            - Shipping
          description: Type(s) of document.
        status[]:
          type: array
          items:
            type: string
            enum:
              - draft
              - sent
              - canceled
              - second_copy
          example:
            - sent
          description: Status(es) of document.
        non_archived:
          type: boolean
          example: true
          description: Show non-archived documents.
        archived:
          type: boolean
          description: Include archived docs
        loaded_at[from]:
          type: string
          description: Date in format dd/mm/yyyy.
        loaded_at[to]:
          type: string
          description: Date in format dd/mm/yyyy.
        page:
          type: integer
          description: Page number
        per_page:
          type: integer
          description: Items per page
    GuideListAll:
      type: object
      properties:
        guides:
          type: object
          properties:
            id:
              type: integer
              example: 541797
            status:
              type: string
              example: final
            archived:
              type: boolean
              example: false
            type:
              type: string
              example: Shipping
            sequence_number:
              type: string
              example: 1/D
            inverted_sequence_number:
              type: string
              example: D/1
            atcud:
              type: string
              example: ABCD1234-1
            date:
              type: string
              example: 13/07/2017
            due_date:
              type: string
              example: foo
            reference:
              type: string
              example: foo
            observations:
              type: string
              example: foo
            retention:
              type: string
              example: foo
            permalink:
              type: string
              example: >-
                https://www.app.invoicexpress.com/documents/541797d75bbee48911934cbd4a4294946a324295f52b08
            saft_hash:
              type: string
              example: vaDf
            sum:
              type: number
              example: 1
            discount:
              type: number
              example: 0
            before_taxes:
              type: number
              example: 1
            taxes:
              type: number
              example: 0.07
            total:
              type: number
              example: 1.07
            currency:
              type: string
              example: Euro
            address_from:
              type: object
              properties:
                country:
                  type: string
                  example: Portugal
                postal_code:
                  type: string
                  example: 1050-083
                detail:
                  type: string
                  example: Avenida Duque D'Avila, 46 - 3ºA
                city:
                  type: string
                  example: Lisboa
            address_to:
              type: object
              properties:
                country:
                  type: string
                  example: Portugal
                postal_code:
                  type: string
                  example: 4000-327
                detail:
                  type: string
                  example: Avenida dos Aliados
                city:
                  type: string
                  example: Porto
            client:
              type: object
              properties:
                id:
                  type: integer
                  example: 1310176
                name:
                  type: string
                  example: John
                country:
                  type: string
                  example: Portugal
            items:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    example: iPhone
                  description:
                    type: string
                    example: foo
                  unit_price:
                    type: string
                    example: '1.0'
                  unit:
                    type: string
                    example: foo
                  quantity:
                    type: string
                    example: '1.0'
                  tax:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 31597
                      name:
                        type: string
                        example: IVA7
                      value:
                        type: number
                        example: 7
                  discount:
                    type: number
                    example: 0
                  subtotal:
                    type: number
                    example: 1
                  tax_amount:
                    type: number
                    example: 0.07
                  discount_amount:
                    type: number
                    example: 0
                  total:
                    type: number
                    example: 1.07
            sequence_id:
              type: string
              example: '12345'
            tax_exemption:
              type: string
              example: M01
            at_doc_code_id:
              type: string
              example: '999'
            license_plate:
              type: string
              example: 11-AA-22
        pagination:
          $ref: '#/components/schemas/Pagination'
    SaftExportParams:
      type: object
      required:
        - month
        - year
      properties:
        month:
          type: string
          description: The month for which you want to generate the SAF-T.
          example: '10'
        year:
          type: string
          description: The year for which you want to generate the SAF-T.
          example: '2017'
