Tenant
The Tenant object is supported by the MiRTA PBX OpenAPI endpoint. This object is managed at system scope and requires a global API key.
Object Summary
| Property | Value |
|---|---|
| Object | tenant |
| Primary path | /tenants |
| ID field | te_id |
| Label field | te_name |
| Primary source table | te_tenants |
| Required on create | te_name, te_code |
| Path aliases | /tenants |
Endpoint Patterns
| Action | Example pattern |
|---|---|
| List | GET https://pbx.example.com/pbx/openapi.php/tenants |
| Get by ID | GET https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID |
| Create | POST https://pbx.example.com/pbx/openapi.php/tenants |
| Update | PATCH https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID |
| Delete | DELETE https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID |
Accepted Field Aliases
| Request field | Source field |
|---|---|
name | te_name |
code | te_code |
billingcode | te_billingcode |
billing_code | te_billingcode |
timezone | te_timezone |
routing_profile_id | te_rp_id |
campaign_routing_profile_id | te_campaign_rp_id |
fax_routing_profile_id | te_fax_rp_id |
Examples
List Tenants
Returns the tenants visible to the key and scope.
curl -H "X-API-Key: GLOBAL_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/tenants"
To filter the list with a full or read-only legacy global key, pass tenant as a tenant code or name. The selector uses SQL LIKE. Use % for any sequence of characters or _ for a single character. Omit tenant to list all tenants available to the key.
curl --get 'https://pbx.example.com/pbx/openapi.php/tenants' \
-H 'X-API-Key: GLOBAL_API_KEY' \
--data-urlencode 'tenant=%Example%'
An advanced key needs global permission and access to listTenants. Supply one exact code or name within its allowed scope, or omit tenant to list that scope.
| HTTP status | Meaning |
|---|---|
| 400 | invalid_tenant when the selector is supplied in a form other than a string. |
| 404 | tenant_not_found when the selector has no match. |
| 409 | ambiguous_tenant when the exact selector for an advanced key is ambiguous. |
| 500 | database_error when the legacy tenant lookup or the tenant list query fails. |
| 503 | api_key_unavailable when the advanced key policy or exact tenant lookup is unavailable. |
Get Tenant
Reads one object by its internal ID.
curl -H "X-API-Key: GLOBAL_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID"
Create Tenant
Creates a new object. Use the short aliases shown above or the source field names.
curl -X POST \
-H "X-API-Key: GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Docs API Tenant",
"code": "DOCSAPI",
"timezone": "Europe/Rome"
}' \
"https://pbx.example.com/pbx/openapi.php/tenants"
Edit Tenant
Updates only the supplied fields.
curl -X PATCH \
-H "X-API-Key: GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"routing_profile_id": 3,
"te_payment_type": "Post Paid"
}' \
"https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID"
Delete Tenant
Deletes the object. Check references before deleting configuration used by routing or reporting.
curl -X DELETE \
-H "X-API-Key: GLOBAL_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/tenants/OBJECT_ID"
Tenant Initialization
POST /tenants requires a full global API key. It creates the tenant and its related records in one transaction.
curl -X POST \
-H "X-API-Key: GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme",
"code": "ACME",
"parking": {"start": 700, "end": 720, "hosted": ""},
"user_ids": [12],
"usergroup_ids": [3]
}' \
"https://pbx.example.com/pbx/openapi.php/tenants"
- Global new-item defaults for tenants and parking apply first; explicit request values override them. Tenant settings are copied from the global new-item defaults.
APIKEYandREADONLYAPIKEYdefaults set toRANDOM16become generated 16-character keys. EmptyPARKTIMEOUT,MAXCALLDURATIONandDIALTIMEOUTreceive 120, 7200 and 60. - One parking lot named after the tenant code is created, by default 700–720 on an automatic server. Use the
parkingobject, orpk_start/pk_end/pk_hosted. Asterisk is not reloaded and no server placement is performed. user_idsandusergroup_idsgive existing users and groups access to the tenant. The default custom destination restriction mode is applied;ctselected, an array of custom type IDs, overrides the configured exceptions.- Codes need at least two characters without spaces. Duplicate codes return 409 and the tenant license limit is checked before saving.
- The response includes an
initializationsummary. Errors includerolled_back:trueconfirms that nothing was saved. HTTP503 tenant_commit_unknownreturns thetenant_id; inspect that tenant before retrying.
These inputs apply only to creation. To change an existing tenant, use the tenant, settings, parking, user and user-group operations.
Tenant Server Placement
GET /tenants/TENANT_ID/placement shows which cluster servers a tenant uses, with a full or read-only global key. POST changes it and requires a full global key. Tenant keys cannot inspect or change placement. Use the numeric tenant ID in the path and omit tenant.
curl -H "X-API-Key: GLOBAL_API_KEY" \
"https://pbx.example.com/pbx/openapi.php/tenants/42/placement"
curl -X POST -H "X-API-Key: GLOBAL_API_KEY" -H "Content-Type: application/json" \
-d '{"settings":{"preferred_queue_node_id":2},"assignments":{"queues":2}}' \
"https://pbx.example.com/pbx/openapi.php/tenants/42/placement"
GET returns the placement settings, the raw stored preferences, the resolved defaults, the current assignment of each service and the server inventory with eligibility and diagnostics. Eligible means registered with a usable peer name; it does not prove that the server is healthy.
| Body object | Meaning |
|---|---|
settings | Defaults and preferences for new objects: cronjob_node_id, campaign_node_id, fax_node_id, preferred_queue_node_id, preferred_parking_node_id. Existing objects are not moved. |
assignments | Moves every current object of a service in the tenant: queues, parkinglots, conferences, campaigns, cronjobs. System jobs and UPLOADRECORDING jobs are excluded. |
- Values are server IDs, not peer names. Supply at least one field; omitted fields are preserved.
0clears a preference or explicit host so the object inherits the default or automatic placement again. - Changing
campaign_node_idalso updates the tenantDEFAULTCAMPAIGNSERVERsetting. - Stop running campaigns before changing their placement. A running or pending cron job returns
409 placement_busy; database lock conflicts also return 409, so reload and retry later. - Queue changes are notified to every registered server after saving;
queue_refreshreports which servers accepted the notification. Parking modules are not reloaded, so moving parking lots may need a scheduled restart, as in the web editor. - The save is a single transaction. Errors include
rolled_back;503 placement_commit_unknownmeans the outcome is unknown, so inspect GET before retrying.
Common Errors
| Error | Meaning |
|---|---|
missing_api_key | No API key was supplied in the query string, X-API-Key, or bearer token. |
invalid_api_key | The supplied key does not match the tenant or global API key. |
tenant_required | A tenant code is required for tenant-scoped writes or tenant-key reads. |
read_only_api_key | The key can read data but cannot create, update, or delete objects. |
missing_required_field | A required create field is missing. |
No comments to display
No comments to display