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

# Create sale (DTE)

> Issues a sales document. The external system must send the tax breakdowns and calculated totals. The control number uses the point of sale of the sale's cash shift, or `point_of_sale_id`, or the branch default. A `point_of_sale_id` from another branch or an inactive one returns 422 and the sale is not transmitted.

**Required permission:** `sales`



## OpenAPI

````yaml /api-reference/openapi.en.json post /sales
openapi: 3.0.3
info:
  title: FileXpress External API
  version: 1.0.0
  description: >-
    API for integrating third-party systems with FileXpress: billing, HR,
    accounting, inventory, projects, accounts receivable and payable, treasury,
    pricing and promotions, and cash. Current base URL: /api/external/v1. The
    legacy unversioned path (/api/external) will be removed on January 1, 2027;
    migrate to /api/external/v1 (same endpoints, only the base URL changes). The
    v2 API (/api/external/v2) exposes currencies and exchange rates, sales and
    purchases in foreign currency, taxes by id, payrolls with branch, and errors
    with a stable `code`; its operations carry the /v2 prefix in the path. We
    suggest migrating to the available v2 routes before March 30, 2027.
servers:
  - url: https://api.filexpress.app/api/external/v1
    description: Production
security:
  - ApiKey: []
tags:
  - name: General
  - name: Billing · Sales
  - name: Billing · Purchases
  - name: Billing · Customers
  - name: Billing · Suppliers
  - name: Billing · Products
  - name: Catalogs
  - name: HR · Employees
  - name: HR · Attendance
  - name: HR · Labor rules
  - name: HR · Schedules
  - name: HR · Holidays
  - name: HR · Attendance results
  - name: HR · Leave requests
  - name: HR · Payrolls
  - name: Accounting
  - name: Inventory
  - name: Projects
  - name: Accounts receivable
  - name: Accounts payable
  - name: Treasury
  - name: Pricing and promotions
  - name: Cash
  - name: Points of sale
  - name: API v2 · General
  - name: API v2 · Currencies and rates
  - name: API v2 · Countries
  - name: API v2 · Sales
  - name: API v2 · Purchases
  - name: API v2 · Payrolls
paths:
  /sales:
    post:
      tags:
        - Billing · Sales
      summary: Create sale (DTE)
      description: >-
        Issues a sales document. The external system must send the tax
        breakdowns and calculated totals. The control number uses the point of
        sale of the sale's cash shift, or `point_of_sale_id`, or the branch
        default. A `point_of_sale_id` from another branch or an inactive one
        returns 422 and the sale is not transmitted.


        **Required permission:** `sales`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SaleRequest'
            example:
              branch_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
              customer_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
              document_type: fc
              date: '2026-10-01T10:00:00'
              observation: Entrega en bodega central
              is_credit: false
              credit_days: 0
              payment_details:
                - code: '01'
                  payment_method: Efectivo
                  amount: 22.6
                  reference: ''
              products:
                - id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                  sku: PRD-001
                  name: Producto A
                  quantity: 2
                  price_before_taxes: 10
                  sale_not_suject: 0
                  sale_exent: 0
                  sale_taxed: 20
                  subtotal: 20
                  discount: 0
                  type: phisical
              totals:
                netTotals: 20
                saleTotalNotSuject: 0
                saleTotalExent: 0
                saleTotalTax: 20
                totalTax: 2.6
                totalRetein: 0
                totalRent: 0
                freight: 0
                insurance: 0
                saleTotalToPayment: 22.6
      responses:
        '200':
          description: Document issued
          content:
            application/json:
              example:
                status: true
                message: Invoice created successfully
                data:
                  sale_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                  generation_code: 6F1E2D3C-8A4B-4C5D-9E6F-0A1B2C3D4E5F
                  control_number: DTE-01-M001P001-000000000000001
                  status: processed
                  issue_time: '2026-10-01 10:30:00'
                  stamp: 2026A1B2C3D4E5F6
                  point_of_sale_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                  establishment_code: M001
                  point_of_sale_code: P001
                  total: 22.6
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '422':
          $ref: '#/components/responses/E422'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
components:
  schemas:
    SaleRequest:
      type: object
      properties:
        branch_id:
          type: string
          format: uuid
          description: Issuing branch (GET /branches).
        customer_id:
          type: string
          format: uuid
          description: Receiving customer.
        document_type:
          type: string
          description: 'SV: fc, ccf, fex, nc, nd, nr. US: inv, cm, dm.'
          enum:
            - fc
            - ccf
            - fex
            - nc
            - nd
            - nr
            - inv
            - cm
            - dm
        date:
          type: string
          description: 'ISO 8601 date and time. Default: now.'
        observation:
          type: string
          description: Notes.
        is_credit:
          type: boolean
          description: Credit sale.
        credit_days:
          type: integer
          description: Credit days.
        project_id:
          type: string
          format: uuid
          description: Associated project.
        point_of_sale_id:
          type: string
          format: uuid
          description: >-
            Issuing point of sale (of the branch and active). Default: the
            branch's default.
        cost_center_id:
          type: string
          format: uuid
          description: >-
            Cost center of the sale (leaf and active; GET
            /accounting/cost-centers). Applied to income lines when posting.
        incoterm_id:
          type: string
          format: uuid
          description: Incoterm (export).
        payment_details:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                description: Payment method code (GET /payment-methods).
              payment_method:
                type: string
                description: Name.
              amount:
                type: number
                description: Amount.
              reference:
                type: string
                description: Reference.
            required:
              - amount
        products:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
                description: Product in FileXpress (deducts inventory).
              sku:
                type: string
                description: Code.
              name:
                type: string
                description: Description.
              quantity:
                type: number
                description: Quantity.
              price_before_taxes:
                type: number
                description: Unit price before taxes.
              sale_not_suject:
                type: number
                description: Not subject.
              sale_exent:
                type: number
                description: Exempt.
              sale_taxed:
                type: number
                description: Taxable.
              subtotal:
                type: number
                description: Subtotal before taxes.
              discount:
                type: number
                description: Discount.
              type:
                type: string
                description: Good or service.
                enum:
                  - phisical
                  - service
              cost_center_id:
                type: string
                format: uuid
                description: Cost center of the line; if missing, that of the sale.
              cost_center_distribution_id:
                type: string
                format: uuid
                nullable: true
                description: >-
                  Distribution of the line; if the line has neither a center nor
                  a distribution, the sale's is used. Mutually exclusive with
                  `cost_center_id` at the same level (422 `Indique centro de
                  costo o distribución, no ambos.`).
            required:
              - name
              - quantity
              - price_before_taxes
              - subtotal
        totals:
          type: object
          properties:
            netTotals:
              type: number
              description: netTotals
            saleTotalNotSuject:
              type: number
              description: saleTotalNotSuject
            saleTotalExent:
              type: number
              description: saleTotalExent
            saleTotalTax:
              type: number
              description: saleTotalTax
            totalTax:
              type: number
              description: totalTax
            totalRetein:
              type: number
              description: totalRetein
            totalRent:
              type: number
              description: totalRent
            freight:
              type: number
              description: freight
            insurance:
              type: number
              description: insurance
            saleTotalToPayment:
              type: number
              description: saleTotalToPayment
        cost_center_distribution_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            Active distribution (GET /accounting/cost-center-distributions):
            income is split among its centers by percentage. Mutually exclusive
            with `cost_center_id` at the same level (422 `Indique centro de
            costo o distribución, no ambos.`).
      required:
        - branch_id
        - customer_id
        - document_type
        - products
        - payment_details
        - totals
  responses:
    E401:
      description: Missing or invalid API Key
      content:
        application/json:
          example:
            status: false
            message: Invalid API Key.
    E403:
      description: Integration without the required permission or deactivated
      content:
        application/json:
          example:
            status: false
            message: This integration does not have the 'hr.employees' permission.
            required_scope: hr.employees
    E404:
      description: Resource does not exist or belongs to another business
      content:
        application/json:
          example:
            status: false
            message: Not found.
    E422:
      description: Validation error
      content:
        application/json:
          example:
            status: false
            message: Validation errors
            errors:
              start_date:
                - The start date field is required.
    E429:
      description: Rate limit exceeded
      content:
        application/json:
          example:
            status: false
            message: Rate limit exceeded. Please try again later.
            rate_limit: 100
    E500:
      description: Internal error
      content:
        application/json:
          example:
            status: false
            message: An error occurred while creating the invoice
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Integration API Key (Integrations → New Integration).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.