Upsert a cost type
Create or update a single cost type. This is one endpoint for both operations: omit id to
create a new cost type (responds 201), or pass the id of an existing cost type to update it
(responds 200). The URL and request shape are identical either way.
On create, name, cost_per_unit, unit_type_id and allow_inline_edits are all required.
On update the body is sparse — only the fields you send are changed, and any field you omit
keeps its current value. unit_type_id is immutable: once a cost type has a unit type it cannot
be reassigned, so sending a different unit_type_id on update is rejected. name must be unique
within your company, compared case-insensitively, among cost types that are both active and not
soft-deleted; inactive or deleted cost types do not reserve their name, so deactivating or
deleting a cost type frees its name for reuse. cost_per_unit must be non-zero (it may be
negative).
A cost type is configuration, not a transaction: this endpoint writes only the cost-type
template itself. It does not create, consume, reserve, or release inventory, and it never syncs
to Metrc or BioTrack — cost types have no compliance identity of their own. It also does not
touch costs already applied from this cost type: each applied cost (on a plant, a package or
batch, an assembly or breakdown output, a purchase item, or a product) snapshots its own amount
and quantity at apply time, so changing this cost type's cost_per_unit or allow_inline_edits
affects only future applications, never historical cost records.
Required permission: costs_permissions_manage_cost_types.
BearerAuthorizationBearer <token>API token generated in Distru (Settings → Distru API). Send it on every request as Authorization: Bearer YOUR_API_TOKEN.
application/json- body
id?stringID of an existing cost type to update. Omit to create a new cost type. When given, the matching cost type in your company is updated in place; the update is sparse, so only the other fields you send are changed.
name*stringDisplay name of the cost type (e.g. "Freight", "Labor"). Required on create. Leading and trailing whitespace is trimmed. Must be unique within your company, compared case-insensitively, among cost types that are both active and not soft-deleted; the name of a deleted or inactive cost type may be reused. On update, omit to leave unchanged.
description?stringOptional free-text description of the cost type. Nullable — send null or omit on create to leave it empty. Leading and trailing whitespace is trimmed. On update, omit to leave the current description unchanged, or send null to clear it.
cost_per_unit*stringDefault cost amount per one unit of unit_type_id, as a decimal string (e.g. "12.50"), with up to 9 decimal places. Required on create. Must be non-zero; may be negative. This is the amount pre-filled when the cost type is applied to a record: when allow_inline_edits is true it can be overridden at apply time, otherwise the applied amount is locked to this value. Changing it does not rewrite costs already applied. On update, omit to leave unchanged.
unit_type_id*stringID of the unit of measure this cost is priced per — call GET /public/v1/unit-types to list valid IDs. Required on create and immutable afterwards: once set it cannot be changed, so sending a different value on update is rejected. On update, omit (or resend the same value) to leave unchanged.
active?booleanWhether the cost type is active and selectable when applying new costs. Defaults to true when omitted on create. Inactive cost types are still returned by the read endpoints. Name uniqueness only considers active cost types, so setting this to false releases the name for another active cost type to use. On update, omit to leave unchanged.
allow_inline_edits*booleanRequired on create. When true, the per-unit amount can be overridden each time this cost type is applied to a record; when false, the applied amount is locked to this cost type's cost_per_unit. On update, omit to leave unchanged.
The updated cost type
*/*- response
A single cost type
data?A cost type
curl -X POST 'https://app.distru.com/public/v1/cost-types' \ -H 'Content-Type: application/json' \ -d '{ "active": true, "allow_inline_edits": true, "cost_per_unit": "25.5", "description": "Inbound shipping", "name": "Freight", "unit_type_id": "00000000-0000-0000-0000-000000000dc7"}'{ "data": { "active": true, "allow_inline_edits": true, "cost_per_unit": "string", "deleted_at": "string", "description": "string", "id": "string", "inserted_datetime": "string", "name": "string", "unit_type": { "id": "string", "name": "string" }, "updated_datetime": "string" }}