Contract
- shape
- entity
- authority
- act
- evidence
- none
- subscription
- false
- permission
- any one of: org.admin (carried by the caller's role template in the org `org_id`, or by a role held on the unit `parent_id` or any unit above it by a member of that org; without `parent_id`, by the template); a deactivated caller is refused first
- idempotency
- keyed
- emits
- unit.created
- MCP tool
- create_unit
- decision_set
- approve, reject, edit, request_info
- REST
- POST https://api.containertradehq.com/v1/cap/create_unit
Through MCP this call returns an approval request first; see Approvals.
Idempotency: keyed by the caller's Idempotency-Key, which is required: the same key and inputs replay the first result, the same key with other inputs is 409 idempotency_key_reused
Inputs
| name | type | required | validation |
|---|---|---|---|
| org_id | org_id | required | tradehq-org-id; 1 to 20 characters The org whose tree the unit joins. |
| parent_id | unit_id | optional | tradehq-unit-id The unit it goes beneath, in the same org. Absent, the unit is a root. |
| kind | one_of | required | one of division, region, depot, office division, region, depot (a yard, always a leaf) or office. |
| name | text | required | 1 to 200 characters The unit's name, as the org's people know it. |
Response
unit_id· string · The new unit's id.org_id· string · Its org.parent_id· stringnull · Its parent; null for a root.kind· string · Its kind.name· string · Its name.created_by· string · Who created it.
Full JSON Schema
{
"type": "object",
"properties": {
"unit_id": {
"type": "string",
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
"format": "tradehq-unit-id",
"description": "The new unit's id.",
"x-data-class": "operational"
},
"org_id": {
"type": "string",
"minLength": 1,
"maxLength": 20,
"pattern": "^[A-Za-z0-9_-]{1,20}$",
"format": "tradehq-org-id",
"description": "Its org.",
"x-data-class": "operational"
},
"parent_id": {
"type": [
"string",
"null"
],
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
"format": "tradehq-unit-id",
"description": "Its parent; null for a root.",
"x-data-class": "operational"
},
"kind": {
"type": "string",
"enum": [
"division",
"region",
"depot",
"office"
],
"description": "Its kind.",
"x-data-class": "operational"
},
"name": {
"type": "string",
"description": "Its name.",
"x-data-class": "operational"
},
"created_by": {
"type": "string",
"minLength": 1,
"maxLength": 20,
"pattern": "^[A-Za-z0-9_-]{1,20}$",
"format": "tradehq-user-id",
"description": "Who created it.",
"x-data-class": "operational"
}
},
"required": [
"unit_id",
"org_id",
"parent_id",
"kind",
"name",
"created_by"
],
"additionalProperties": false
} Refusals
not yet declared
The platform refusals apply to every call: version, authentication, authority, validation and rate limits, each in the same envelope.
Surfaces
- Mobile: degraded: composition
- MCP: approval required
- Voice: degraded: composition
- OneBox: no document originates a unit
- Outbound: crosses to no counterparty
Events
unit.createdaudit_only