> ## Documentation Index
> Fetch the complete documentation index at: https://sendcloud.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a sales invoice

> Generate a sales invoice PDF for a parcel. The invoice is created based on the provided items, currency, and tax rate, combined with parcel and sender details fetched from the system.

Company details and addresses are auto-populated from the parcel tracking information.



## OpenAPI

````yaml /.openapi/v3/support/openapi.yaml post /dsf/documents/generate/invoice
openapi: 3.1.0
info:
  title: Support API [BETA]
  version: 3.0.0
  contact:
    name: Sendcloud API Support
    url: https://www.sendcloud.dev
    email: contact@sendcloud.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: >-
    The Sendcloud Support API lets you create support tickets easily and
    efficiently. This API can be used in conjunction with other core Sendcloud
    features or independently.
servers:
  - url: https://panel.sendcloud.sc/api/v3
    description: Sendcloud Production
security: []
tags:
  - name: Support
    description: Sendcloud's Support API
  - name: File upload
  - name: Carrier support contacts
  - name: Create ticket
  - name: Documents
  - name: Requested data
paths:
  /dsf/documents/generate/invoice:
    post:
      tags:
        - Documents
      summary: Create a sales invoice
      description: >-
        Generate a sales invoice PDF for a parcel. The invoice is created based
        on the provided items, currency, and tax rate, combined with parcel and
        sender details fetched from the system.


        Company details and addresses are auto-populated from the parcel
        tracking information.
      operationId: sc-public-v3-dsf-post-documents_generate_invoice
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateInvoiceRequest'
            example:
              tracking_number: 3SABCD1234567
              items:
                - description: T-Shirt
                  quantity: 3
                  unit_price: 19.95
                - description: Pants
                  quantity: 1
                  unit_price: 45
              currency_code: EUR
              tax_rate: 21
        required: true
      responses:
        '201':
          $ref: '#/components/responses/InvoiceCreated'
        '400':
          $ref: '#/components/responses/InvoiceGenerationFailed'
        '401':
          description: Unauthorized
        '429':
          $ref: '#/components/responses/RateLimitExceededResponse'
      security:
        - HTTPBasicAuth: []
        - OAuth2ClientCreds: []
components:
  schemas:
    GenerateInvoiceRequest:
      title: Generate invoice request
      type: object
      properties:
        tracking_number:
          description: Parcel tracking number
          type: string
          example: 3SABCD1234567
        items:
          type: array
          description: List of invoice line items
          items:
            type: object
            properties:
              description:
                type: string
                description: Description of the item
              quantity:
                type: integer
                description: Quantity of the item
                minimum: 1
              unit_price:
                type: number
                format: double
                description: Unit price of the item. **Must be tax-included.**
            required:
              - description
              - quantity
              - unit_price
        currency_code:
          type: string
          description: ISO 4217 currency code
          example: EUR
        tax_rate:
          type: number
          format: double
          description: Tax rate percentage (0-99)
          minimum: 0
          maximum: 99
          example: 21
        company_logo_path:
          type:
            - string
            - 'null'
          description: >-
            Optional company logo to include on the invoice. Provide a
            base64-encoded PNG image string or a public url leading to the
            company logo image. If not provided a company name will be used to
            generate a default logo.
        force:
          type: boolean
          description: >-
            Bypasses the maximum invoice amount validation (5000 EUR). Only use
            this when strictly necessary, as the validation exists to prevent
            erroneous invoices.
          default: false
      required:
        - tracking_number
        - items
        - currency_code
        - tax_rate
    GenerateDocumentResponse:
      title: Generate document response
      type: object
      properties:
        file_token:
          type: string
          description: >-
            A token referencing the generated document. Use this token when
            attaching the document to a ticket (in the `attachments` array) or
            when submitting it as part of a requested data response.
        preview_url:
          type: string
          description: >-
            Temporary pre-signed URL for previewing or downloading the generated
            PDF. This URL expires after 72 hours and should not be stored for
            long-term use.
      required:
        - file_token
        - preview_url
    ErrorsResponseSchema:
      description: Support API error response.
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                title: Error code
                type: string
              detail:
                title: Error description
                type: string
              title:
                title: Error title
                type: string
              status:
                title: HTTP status code
                type: integer
      required:
        - errors
  responses:
    InvoiceCreated:
      description: Invoice generated successfully
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GenerateDocumentResponse'
          example:
            file_token: b90e7a70-57c6-4338-992a-eae50d637261
            preview_url: https://s3.example.com/sales_invoice.pdf?token=...
    InvoiceGenerationFailed:
      description: Invoice generation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorsResponseSchema'
          examples:
            Invalid JSON:
              value:
                errors:
                  - code: bad_request
                    detail: Invalid JSON
                    title: Bad Request
                    status: 400
            Validation Error:
              value:
                errors:
                  - code: bad_request
                    detail: >-
                      Validation Error. Errors: [{'type': 'missing', 'loc':
                      ('items',), 'msg': 'Field required'}]
                    title: Bad Request
                    status: 400
            Generation Failed:
              value:
                errors:
                  - code: bad_request
                    detail: Invoice generation failed.
                    title: Bad Request
                    status: 400
    RateLimitExceededResponse:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorsResponseSchema'
          example:
            errors:
              - code: hit_rate_limit
                detail: 'Rate limit exceeded: 30 per 1 minute'
                title: Rate limit exceeded
                status: 429
  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.

````