> ## 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.

# Crear venta (DTE)

> Emite un documento de venta. El sistema externo debe enviar los desgloses fiscales y totales calculados.

**Permiso requerido:** `sales`



## OpenAPI

````yaml /api-reference/openapi.json post /sales
openapi: 3.0.3
info:
  title: FileXpress API Externa
  version: 1.0.0
  description: >-
    API para integrar sistemas de terceros con FileXpress: facturación, RRHH y
    contabilidad.
servers:
  - url: https://api.filexpress.app/api/external
    description: Producción
security:
  - ApiKey: []
tags:
  - name: General
  - name: Facturación · Ventas
  - name: Facturación · Compras
  - name: Facturación · Clientes
  - name: Facturación · Proveedores
  - name: Facturación · Productos
  - name: Catálogos
  - name: RRHH · Empleados
  - name: RRHH · Asistencia
  - name: RRHH · Permisos
  - name: RRHH · Planillas
  - name: Contabilidad
paths:
  /sales:
    post:
      tags:
        - Facturación · Ventas
      summary: Crear venta (DTE)
      description: >-
        Emite un documento de venta. El sistema externo debe enviar los
        desgloses fiscales y totales calculados.


        **Permiso requerido:** `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: Documento emitido
          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
                  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: Sucursal emisora (GET /branches).
        customer_id:
          type: string
          format: uuid
          description: Cliente receptor.
        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: Fecha y hora ISO 8601. Por defecto, ahora.
        observation:
          type: string
          description: Observaciones.
        is_credit:
          type: boolean
          description: Venta al crédito.
        credit_days:
          type: integer
          description: Días de crédito.
        project_id:
          type: string
          format: uuid
          description: Proyecto asociado.
        incoterm_id:
          type: string
          format: uuid
          description: Incoterm (exportación).
        payment_details:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                description: Código de forma de pago (GET /payment-methods).
              payment_method:
                type: string
                description: Nombre.
              amount:
                type: number
                description: Monto.
              reference:
                type: string
                description: Referencia.
            required:
              - amount
        products:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
                description: Producto en FileXpress (descuenta inventario).
              sku:
                type: string
                description: Código.
              name:
                type: string
                description: Descripción.
              quantity:
                type: number
                description: Cantidad.
              price_before_taxes:
                type: number
                description: Precio unitario sin impuestos.
              sale_not_suject:
                type: number
                description: No sujeto.
              sale_exent:
                type: number
                description: Exento.
              sale_taxed:
                type: number
                description: Gravado.
              subtotal:
                type: number
                description: Subtotal sin impuestos.
              discount:
                type: number
                description: Descuento.
              type:
                type: string
                description: Bien o servicio.
                enum:
                  - phisical
                  - service
            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
      required:
        - branch_id
        - customer_id
        - document_type
        - products
        - payment_details
        - totals
  responses:
    E401:
      description: API Key ausente o inválida
      content:
        application/json:
          example:
            status: false
            message: Invalid API Key.
    E403:
      description: Integración sin el permiso requerido o desactivada
      content:
        application/json:
          example:
            status: false
            message: This integration does not have the 'hr.employees' permission.
            required_scope: hr.employees
    E404:
      description: Recurso inexistente o de otro negocio
      content:
        application/json:
          example:
            status: false
            message: Not found.
    E422:
      description: Error de validación
      content:
        application/json:
          example:
            status: false
            message: Validation errors
            errors:
              start_date:
                - The start date field is required.
    E429:
      description: Límite de peticiones excedido
      content:
        application/json:
          example:
            status: false
            message: Rate limit exceeded. Please try again later.
            rate_limit: 100
    E500:
      description: Error interno
      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: API Key de la integración (Integraciones → Nueva Integración).

````

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