customers

Create a customer unit under a parent

Creates a unit by naming its parent alone; the customer is whoever the parent belongs to, so a caller that only knows its own ids never needs the customer routes. parentExternalId is looked up across the organization, ignoring letter case, among unit ids, customer external ids and aliases: a unit becomes the parent; a customer (by external id or alias) stands for the top of its tree, so the new unit goes under the root unit, or becomes the root when the customer has none. The parent is only ever named by your id, never by a Paid id, so a customer with no external id takes its units through the customer's unit routes. The answer carries the unit's externalId and its customer's ids, not Paid's unit id. externalId follows the same rules as on the customer-scoped create: required, immutable, unique within the organization ignoring letter case. 409 PARENT_NOT_FOUND when nothing matches, PARENT_NOT_ACTIVE for a deleted or draft parent, PARENT_AMBIGUOUS when legacy rows let the id name more than one customer (use that customer's unit routes), PARENT_CHANGED when the reference pointed elsewhere by the time the create ran (send it again), and otherwise the customer-scoped create's 409s (CUSTOMER_UNIT_EXISTS, EXTERNAL_ID_IN_USE, DEPTH_EXCEEDED, SEAT_BILLING, and ROOT_UNIT_ALWAYS_BILLABLE for billable: false on a unit that would become the root). 403 FEATURE_NOT_ENABLED for billable: false when non-billable units are not enabled for your organization.

post/customer-units/

Request

  • Base URL: https://api.agentpaid.io/api/v2
  • URL: https://api.agentpaid.io/api/v2/customer-units/
  • Auth: HTTP bearer

Request body

externalIdstring required

Your own id for the unit: required, immutable, at most 255 characters, and unique within the organization: no other customer's unit id, external id or alias may be the same, ignoring letter case. Every unit route addresses the unit by it (percent-encode it in the path), and so do signals (customerUnit.externalCustomerUnitId). Cannot be . or ...

namestring

Display name (defaults to the external ID).

externalTypestring

Your structural vocabulary for the unit (department, tenant, team, ...). Free text; filterable; Paid never branches on it.

parentExternalIdstring required

Your id of the parent, looked up across the organization ignoring letter case: a unit id makes the new unit its child; a customer external id or alias names the customer, so the new unit goes under that customer's root unit, or becomes the root when the customer has none. Required: a parent is only ever named by your id, never by a Paid id.

metadataobject nullable

Freeform JSON for your own use.

billableboolean

false makes the unit non-billable, together with every unit under it (a dev or QA environment, say). Defaults to true. The root unit is always billable (409 ROOT_UNIT_ALWAYS_BILLABLE): a customer that should never be billed simply has no order. Sending false needs non-billable units enabled for your organization (403 FEATURE_NOT_ENABLED otherwise). Usage on a non-billable unit is still recorded but not billed: it burns no credits, adds nothing to invoices or overage, and counts toward no cap, on a price whose usage comes from a meter (read from your events when the invoice closes) too. A meter's derived signal, and a correlation-window meter's window, follow the source event they take their unit from (the window's closing event, else its opening event): they are not billed when that event was not. Usage is still billed when it is sent with a customer API key, and on cost-plus pricing, which bills from costs that carry no unit. Only signals sent to /api/v2/signals that resolve to an active unit, by its key or through an alias on it, can be non-billable, and a change applies to signals received afterwards.

Response

201

externalIdstring required

Your own id for the unit, unique within the customer; the identifier every unit route takes.

customerIdstring nullable required

Paid's id of the customer the unit belongs to (cus_…). null only for a legacy customer that has no Paid id; customerExternalId still names it.

customerExternalIdstring nullable required

Your external id of that customer, when it has one.

namestring required

Display name. Never used to address the unit.

externalTypestring nullable required

Your structural vocabulary for the unit.

status'ACTIVE' | 'DELETED' | 'DRAFT' required

ACTIVE; DELETED after a soft delete (one-way); or DRAFT, a placeholder that holds the key for this customer until you create the unit with that key (which promotes it) or delete it (soft, the key stays reserved, as for any unit). A draft is never a parent and never carries a cap.

parentExternalIdstring nullable required

externalId of the parent unit; null only on the customer's root unit.

isRootboolean required

Whether this unit is the customer's root: the one unit without a parent. Derived from the missing parent, not stored. At most one active root per customer; the root cannot be moved, and once deleted a new root can be created.

billableboolean required

The unit's own setting, as last created or updated: false marks it, and every unit under it, non-billable. Always true on the root. effectiveBillable says whether the unit is billable once its ancestors are counted. Usage on a non-billable unit is still recorded but not billed: it burns no credits, adds nothing to invoices or overage, and counts toward no cap, on a price whose usage comes from a meter (read from your events when the invoice closes) too. A meter's derived signal, and a correlation-window meter's window, follow the source event they take their unit from (the window's closing event, else its opening event): they are not billed when that event was not. Usage is still billed when it is sent with a customer API key, and on cost-plus pricing, which bills from costs that carry no unit. Only signals sent to /api/v2/signals that resolve to an active unit, by its key or through an alias on it, can be non-billable, and a change applies to signals received afterwards.

effectiveBillableboolean required

Read-only. Whether the unit is billable in effect: false when the unit or any unit above it has billable: false. A unit cannot make itself billable under a non-billable ancestor, and moving a unit under one makes it non-billable.

metadataobject nullable required
createdAtstring date-time required
updatedAtstring date-time required

Changes

No recorded changes to this operation across all 1 revision of this API.