Skip to main content
These are explicit permissions: they must be checked one by one in External integrations; existing integrations do not receive them automatically.
Cost centers are hierarchical (a center can have sub-centers). Their id values are sent as cost_center_id in journal entries, sales, purchases, collections, payments, transfers and payrolls, and they serve as a filter in the financial statements.
Only leaf (is_leaf: true) and active centers are accepted in documents and journal entries. Parent centers group their sub-centers in reports.
For functional usage (policy per account, how centers reach the journal entry, reassignment), see Cost centers in the manual.

Cost center object

List cost centers

Required permission: accounting.cost_centers Returns the flat list (sorted by code) and the same set as a tree.

Get cost center

Required permission: accounting.cost_centers Responds 200 with the cost center object inside data, or 404 Cost center not found.

Create cost center

Required permission: accounting.cost_centers.write
Behavior
  • The level (level) is calculated from the parent.
  • When you create a sub-center, its parent stops being a leaf: it can no longer be assigned to new documents, but it still groups its children in reports.
Response 201: the created cost center object.

Edit cost center

Required permission: accounting.cost_centers.write Accepts the same fields as creation, all optional: only the ones you send change.
Behavior
  • If you change parent_id, the level of the center and of all its sub-centers is recalculated.
  • A center cannot depend on itself or on one of its sub-centers.
  • Deactivating a center (is_active: false) prevents assigning it to new documents and journal entries; what is already recorded is preserved.
Response 200: the updated cost center object.

Delete cost center

Required permission: accounting.cost_centers.write Behavior
  • If the center has not been used in journal entries or documents, it is deleted: {"deleted": true, "deactivated": false}.
  • If it already has movements or documents, it is not deleted: it is deactivated to preserve the history: {"deleted": false, "deactivated": true}.
  • If it has sub-centers, it responds 422: delete them or move them to another parent first.

Distributions

A distribution splits an amount among several leaf centers by percentage (for example, rent 60% Sales and 40% Administration). Its id is sent as cost_center_distribution_id instead of cost_center_id in journal entries, sales, purchases and payrolls. See Distributions in the manual. Usage rules
  • cost_center_id and cost_center_distribution_id are mutually exclusive at the same level (document or line): sending both responds 422 Indique centro de costo o distribución, no ambos..
  • The distribution must be active and belong to the company.
  • When posting, each line of an account that accepts a center is split into one line per center according to the percentage; rounding is adjusted on the part with the highest percentage (60/40 over 100.01 gives 60.01 and 40.00). On accounts with the None policy, a single line without a center is used.
  • Changing the percentages does not modify journal entries that were already generated.
  • Collections, payments and transfers do not accept distributions.

Distribution object

percentage has up to 4 decimals and the sum of the lines is exactly 100. Lines are returned from highest to lowest percentage.

List distributions

Required permission: accounting.cost_centers Returns in data the list of distributions sorted by code.

Get distribution

Required permission: accounting.cost_centers Responds 200 with the distribution or 404 Distribution not found.

Create distribution

Required permission: accounting.cost_centers.write
Response 201: the created distribution.

Edit distribution

Required permission: accounting.cost_centers.write Accepts the same fields, all optional. If you send lines, they replace all previous lines (with the same rules). Responds 200 with the updated distribution.

Delete distribution

Required permission: accounting.cost_centers.write
  • Not used in documents or journal entries: it is deleted, {"deleted": true}.
  • Already used: it is deactivated to preserve the history, {"deleted": false, "deactivated": true}.

Distribution errors

422 Validation errors when the code is repeated, there are fewer than 2 lines, the sum is not 100 (errors.lines), a center is repeated, belongs to another company, is inactive or has sub-centers (errors["lines.N.cost_center_id"]), or a percentage is 0 or negative.

Errors