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

# Register purchase

> Registers a supplier purchase with calculated tax breakdowns.

**Required permission:** `expenses`



## OpenAPI

````yaml /api-reference/openapi.en.json post /expenses
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:
  /expenses:
    post:
      tags:
        - Billing · Purchases
      summary: Register purchase
      description: |-
        Registers a supplier purchase with calculated tax breakdowns.

        **Required permission:** `expenses`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExpenseRequest'
            example:
              branch_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
              provider_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
              document_type: ccf
              date: '2026-10-01'
              observation: Compra de insumos
              is_credit: false
              credit_days: 0
              number_control: DTE-03-M001P001-000000000000123
              generation_code: A1B2C3D4-...
              stamp: 2026XYZ...
              products:
                - sku: INS-001
                  name: Insumo A
                  type: goods
                  quantity: 5
                  price_before_taxes: 8
                  expense_not_suject: 0
                  expense_exent: 0
                  expense_taxed: 40
                  subtotal: 40
              totals:
                netTotals: 40
                charge_1: 0
                charge_2: 0
                expenseTotalTax: 40
                totalRent: 0
                totalTax: 5.2
                totalRetein: 0
                expenseTotalToPayment: 45.2
      responses:
        '200':
          description: Purchase registered
          content:
            application/json:
              example:
                status: true
                message: Expense created successfully
                data:
                  expense_id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                  generation_code: A1B2C3D4-...
                  control_number: DTE-03-M001P001-000000000000123
                  status: processed
                  issue_time: '2026-10-01 10:00:00'
                  total: 45.2
        '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:
    ExpenseRequest:
      type: object
      properties:
        branch_id:
          type: string
          format: uuid
          description: Branch.
        provider_id:
          type: string
          format: uuid
          description: Supplier.
        document_type:
          type: string
          description: Document type.
          enum:
            - ccf
            - fse
            - ticket
        date:
          type: string
          format: date
          description: Date.
        is_credit:
          type: boolean
          description: On credit.
        credit_days:
          type: integer
          description: Credit days.
        observation:
          type: string
          description: Notes.
        number_control:
          type: string
          description: DTE control number.
        generation_code:
          type: string
          description: Generation code.
        stamp:
          type: string
          description: Stamp.
        cost_center_id:
          type: string
          format: uuid
          description: >-
            Cost center of the purchase (leaf and active; GET
            /accounting/cost-centers).
        products:
          type: array
          items:
            type: object
            properties:
              sku:
                type: string
              name:
                type: string
              type:
                type: string
                description: Good or service.
                enum:
                  - goods
                  - services
              quantity:
                type: number
              price_before_taxes:
                type: number
              expense_not_suject:
                type: number
              expense_exent:
                type: number
              expense_taxed:
                type: number
              subtotal:
                type: number
              cost_center_id:
                type: string
                format: uuid
                description: >-
                  Cost center of the line; if missing, that of the purchase. The
                  expense is grouped by account and center.
              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 purchase's is used. Mutually exclusive
                  with `cost_center_id` at the same level (422 `Indique centro
                  de costo o distribución, no ambos.`).
            required:
              - sku
              - name
              - type
              - quantity
              - price_before_taxes
              - expense_not_suject
              - expense_exent
              - expense_taxed
              - subtotal
        totals:
          type: object
          properties:
            netTotals:
              type: number
            charge_1:
              type: number
            charge_2:
              type: number
            expenseTotalTax:
              type: number
            totalRent:
              type: number
            totalTax:
              type: number
            totalRetein:
              type: number
            expenseTotalToPayment:
              type: number
          required:
            - netTotals
            - charge_1
            - charge_2
            - expenseTotalTax
            - totalRent
            - totalTax
            - totalRetein
            - expenseTotalToPayment
        cost_center_distribution_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            Active distribution: the expense 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
        - provider_id
        - document_type
        - date
        - is_credit
        - products
        - 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.