openapi: 3.1.0
info:
  title: Invoicing
  version: 2.0.0
  description: The Invoices API allows you to retrieve a list of your invoices and download individual invoices.
  contact:
    name: Sendcloud API Support
    url: https://www.sendcloud.dev
    email: contact@sendcloud.com
  license:
    url: https://www.apache.org/licenses/LICENSE-2.0.html
    name: Apache 2.0
servers:
  - url: https://panel.sendcloud.sc/api/v2
    description: Production
tags:
  - name: Invoices
paths:
  /user/invoices:
    get:
      summary: Retrieve a list of invoices
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoices:
                    type: array
                    minItems: 0
                    uniqueItems: true
                    items:
                      $ref: '#/components/schemas/Invoice'
              examples:
                RetrieveInvoices:
                  summary: Retrieve a list of invoices
                  value:
                    invoices:
                      - id: 1638405
                        ref: EU-CENTRAL-1-0-22-NL0063503
                        type: initial_payment
                        price_incl: 0.02
                        price_excl: 0.02
                        isPayed: true
                        date: 08-06-2022 11:39:36
                        items: https://panel.sendcloud.sc/api/v2/user/invoices/1638405
                empty_invoice_list:
                  summary: No invoices response
                  value:
                    invoices: []
      operationId: sc-public-v2-scp-get-all_user_invoices
      security:
        - HTTPBasicAuth: []
        - OAuth2ClientCreds: []
      description: Retrieve all invoices (with the associated invoice `id`) which have been issued to your account to date.
      x-mint:
        href: /api/v2/invoices/retrieve-a-list-of-invoices
      tags:
        - Invoices
  /user/invoices/{id}:
    parameters:
      - schema:
          type: integer
          minimum: 1
        name: id
        in: path
        required: true
        description: The id of the invoice you want to retrieve
    get:
      summary: Retrieve a specific invoice
      x-mint:
        href: /api/v2/invoices/retrieve-a-specific-invoice
      operationId: sc-public-v2-scp-get-invoice_by_id
      security:
        - HTTPBasicAuth: []
        - OAuth2ClientCreds: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice:
                    $ref: '#/components/schemas/InvoiceDetail'
              examples:
                RetrieveInvoice:
                  summary: Retrieve a specific invoice
                  value:
                    invoice:
                      id: 1
                      ref: EU-CENTRAL-0-1-22-NL0000001
                      type: periodic
                      price_incl: 0
                      price_excl: 0
                      isPayed: true
                      date: 05-10-2020 02:12:01
                      items:
                        - id: 33493679
                          name: PostNL Standard 0-23kg
                        - id: 33493681
                          name: Insurance
                        - id: 33495701
                          name: Credit requested for label
                        - id: 33495702
                          name: Insurance refund
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicesError'
              examples:
                NotFound:
                  summary: Invoice Not Found
                  value:
                    error:
                      code: 404
                      request: api/v2/user/invoices/12312312312
                      message: No Invoice matches the given query.
      description: |
        Retrieve detailed information about a specific invoice issued to your Sendcloud account, 
        including all line items.

        You can obtain the `id` from the [Retrieve a list of invoices](/api/v2/invoices/retrieve-a-list-of-invoices) endpoint.
      tags:
        - Invoices
components:
  schemas:
    Invoice:
      title: Invoice Object
      description: Sendcloud Invoice issued to an account
      type: object
      required:
        - id
        - ref
        - type
        - price_incl
        - price_excl
        - isPayed
        - date
        - items
      properties:
        id:
          type: integer
          minimum: 1
          example: 1291434
          description: ID of an invoice.
          format: int64
        ref:
          type: string
          minLength: 1
          description: Reference of an invoice. In the format of {PODID}-{YEAR}-{COUNTRY}{INVOICENUMBER}.
          example: EU-CENTRAL-0-1-22-NL0000001
        type:
          type: string
          minLength: 1
          description: |-
            *periodic - Invoices that have been created automatically each month

            *forced - Someone from the administration created an invoice manually

            *initial_payment - Invoice created for an initial payment on account setup

            *credit_limit - Invoice created due to reaching the credit limit

            *unblock_payment - Invoice unblocking the payment

            *other - Invoice that does not represent any type defined previously
          enum:
            - periodic
            - forced
            - initial_payment
            - credit_limit
            - unblock_payment
            - other
          example: initial_payment
          readOnly: true
        price_incl:
          type: number
          example: 6.5
          description: The price including tax
          format: double
        price_excl:
          type: number
          example: 5.5
          description: Price excluding the tax
          format: double
        isPayed:
          type: boolean
          description: Displays `True` if invoice is paid. If the invoice is not paid, displays `False`.
          example: true
        date:
          type: string
          minLength: 1
          example: 09-11-2021 04:20:23
          description: The creation datetime of the invoice
        items:
          type: string
          format: uri
          description: Link to retrieve invoice items of this invoice
    InvoicesError:
      title: Invoices Error Object
      type: object
      properties:
        error:
          type: object
          required:
            - code
            - request
            - message
          properties:
            code:
              type: integer
            request:
              type: string
              minLength: 1
            message:
              type: string
              minLength: 1
    InvoiceDetail:
      title: Invoice Detail Object
      type: object
      description: An invoice object as returned within a list
      properties:
        id:
          type: integer
          minimum: 1
          example: 1291434
          description: ID of an invoice.
          format: int64
        ref:
          type: string
          minLength: 1
          description: Reference of an invoice. In the format of {PODID}-{YEAR}-{COUNTRY}{INVOICENUMBER}.
          example: EU-CENTRAL-0-1-22-NL0000001
        type:
          type: string
          minLength: 1
          description: |-
            *periodical - Invoices that have been created automatically each month

            *forced - Someone from the administration created an invoice manually

            *initial - Invoice created for an initial payment

            *other - Invoice that does not represent any type defined previously

            *unblock_payment - Invoice to unblock shipment
          enum:
            - periodic
            - forced
            - initial_payment
            - other
            - unblock_payment
          example: initial_payment
          readOnly: true
        price_incl:
          type: number
          example: 5.5
          description: The price including tax
          format: double
        price_excl:
          type: number
          example: 6.5
          description: Price excluding the tax
          format: double
        isPayed:
          type: boolean
          description: Displays `True` if invoice is paid. If the invoice is not paid, displays `False`.
          example: true
        date:
          type: string
          minLength: 1
          format: date-time
          example: '2021-11-09T04:20:23Z'
          description: The creation date of the invoice in RFC3339 format
        items:
          type: array
          description: A list of the invoice items
          minItems: 0
          uniqueItems: true
          items:
            type: object
            properties:
              id:
                type: integer
                example: 1
                format: int64
                description: The id of the invoice item
              name:
                type: string
                description: The description of the invoice item
                example: Insurance
  securitySchemes:
    HTTPBasicAuth:
      type: http
      description: Basic Authentication using API key and secrets is currently the main authentication mechanism.
      scheme: basic
    OAuth2ClientCreds:
      type: oauth2
      description: OAuth2 is a standardized protocol for authorization that allows users to share their private resources stored on one site with another site without having to provide their credentials. OAuth2 Client Credentials Grant workflow. This workflow is typically used for server-to-server interactions that require authorization to access specific resources.
      flows:
        clientCredentials:
          tokenUrl: https://account.sendcloud.com/oauth2/token/
          scopes:
            api: Default OAuth scope required to access Sendcloud API.
