DID

The DID object is supported by the MiRTA PBX OpenAPI endpoint. This object is tenant-scoped. Tenant API keys must include tenant=CANISTRACCI; writes require a writable API key.

Object Summary

PropertyValue
Objectdid
Primary path/dids
ID fielddi_id
Label fielddi_number
Primary source tabledi_dids
Required on createdi_number
Path aliases/dids

Endpoint Patterns

ActionExample pattern
ListGET https://pbx.example.com/pbx/openapi.php/dids?tenant=CANISTRACCI
Get by IDGET https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI
CreatePOST https://pbx.example.com/pbx/openapi.php/dids?tenant=CANISTRACCI
UpdatePATCH https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI
DeleteDELETE https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI

Accepted Field Aliases

Request fieldSource field
numberdi_number
countrydi_country
areadi_area
commentdi_comment

Destination Fields

Destination fields accept one destination string or an array of destination strings such as EXT-100, VOICEMAIL-100, or another supported destination type and ID pair.

Destination typeAccepted aliases
DIDdestination, did
DID-UNCONDITIONALunconditional
DID-SMSsms
DID-FAXSUCCESSfaxsuccess, fax_success

Examples

List DIDs

Returns the dids visible to the key and scope.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/dids?tenant=CANISTRACCI"

Get DID

Reads one object by its internal ID.

curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

Create DID

Creates a new object. Use the short aliases shown above or the source field names.

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "number": "+15551234567",
  "country": "US",
  "area": "212",
  "comment": "Docs API inbound DID"
}' \
  "https://pbx.example.com/pbx/openapi.php/dids?tenant=CANISTRACCI"

Edit DID

Updates only the supplied fields.

curl -X PATCH \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "comment": "Docs API DID updated"
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

Delete DID

Deletes the object. Check references before deleting configuration used by routing or reporting.

curl -X DELETE \
  -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

DID Destination

Updates the DID destination. The same value can also be sent inside a destinations object.

curl -X PATCH \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "destination": [
    "EXT-100"
  ]
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

DID UNCONDITIONAL Destination

Updates the DID-UNCONDITIONAL destination. The same value can also be sent inside a destinations object.

curl -X PATCH \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "unconditional": [
    "EXT-100"
  ]
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

DID SMS Destination

Updates the DID-SMS destination. The same value can also be sent inside a destinations object.

curl -X PATCH \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sms": [
    "EXT-100"
  ]
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

DID FAXSUCCESS Destination

Updates the DID-FAXSUCCESS destination. The same value can also be sent inside a destinations object.

curl -X PATCH \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "faxsuccess": [
    "EXT-100"
  ]
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/OBJECT_ID?tenant=CANISTRACCI"

DID Validation and Storage Rules

DID create, update and delete follow the web interface. Country, area and number together, ignoring leading zeros, must be unique across all tenants and unassigned DIDs. Creation respects the tenant DID limit. New destinations must reference objects the tenant may use, including available shared objects; use internal IDs such as EXT-123, or SAMENUMBERVM.

Updates replace only the destination lists explicitly supplied; omit a list to preserve it or send an empty array to clear it. An unconditional forward is reset if it has no destinations. Tenant keys may select only a fax routing profile already in use by that tenant. With a global key, global=yes manages unassigned DIDs, which cannot have destinations.

When DID storage selection (DIDSSTORAGE) is enabled, deleting a tenant DID returns its number to the unassigned pool with the same ID and cleared routing/settings. Otherwise deletion removes it. Check references before deleting.

List Filters

GET /dids and the available pool (available=yes, also true, 1 or on) accept exact filters: number (alias di_number), country and area. Filters are combined with AND, compare the stored value exactly, keep leading zeros, and an empty value matches an empty field. Values are at most 255 UTF-8 bytes without control characters. Ordinary lists need a tenant, or global=yes with a global key, when filtering.

curl --fail --show-error \
  --header "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/dids?tenant=CANISTRACCI&country=39&number=0612345678"

Unknown parameters return 400 unknown_filter. Invalid values, repeated parameters, or number and di_number with different values return 400 invalid_did_filter.

Assign, Transfer or Release a DID

Use POST /dids/{id}/assign with a full API key. to_tenant accepts a tenant code, name or ID; "pool" or 0 releases the DID. Optional from_tenant checks the expected current owner and prevents acting on a number that has moved. The equivalent query form is POST /dids?action=assign&id={id}.

OperationPermissions and result
Pool to tenantA global full key can assign a number. A tenant full key can claim a pool number only for its own tenant with DID storage enabled. The ID and number are preserved; tenant defaults and default destinations are applied.
Tenant to another tenantRequires a global full key. Old destinations are removed and the target tenant defaults are applied. The new DID has a new ID; the response includes previous_id.
Tenant to poolRequires a global full key. Use to_tenant: "pool". The ID is retained, routes are cleared and stored settings are reset. Do not include other DID fields or destinations.
Same ownerReturns unchanged: true without resetting or editing the DID. Use the ordinary update endpoint for edits.

Responses include previous_tenant_id. For assignment to a tenant, supported DID fields and destination lists can accompany the request. A pool claim cannot change the number. If to_tenant is omitted, the selected tenant is used; with a global key that tenant parameter must identify one tenant exactly.

List Available Pool Numbers

curl --fail --show-error --request GET \
  --header "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/dids?available=yes&tenant=CANISTRACCI"

Tenant keys need DID storage enabled. The available list contains the ID and number fields without administrator comments or provider details.

Claim a Pool Number

curl --fail --show-error --request POST \
  --header "X-API-Key: TENANT_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "to_tenant": "CANISTRACCI",
  "from_tenant": "pool",
  "destination": [
    "EXT-201"
  ]
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/123/assign?tenant=CANISTRACCI"

Transfer Between Tenants

curl --fail --show-error --request POST \
  --header "X-API-Key: GLOBAL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "to_tenant": "TARGET_TENANT",
  "from_tenant": "CANISTRACCI"
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/123/assign?tenant=CANISTRACCI"

Release a Number

curl --fail --show-error --request POST \
  --header "X-API-Key: GLOBAL_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "to_tenant": "pool",
  "from_tenant": "CANISTRACCI"
}' \
  "https://pbx.example.com/pbx/openapi.php/dids/123/assign?tenant=CANISTRACCI"

The transfer/release examples require a global key. Replace sample IDs and tenant codes with real values. Assignment checks permissions, destination availability and target limits before committing. did_owner_changed and did_number_exists return 409; disabled DID storage returns did_storage_disabled. Inspect any returned warnings after a successful save.

Common Errors

ErrorMeaning
missing_api_keyNo API key was supplied in the query string, X-API-Key, or bearer token.
invalid_api_keyThe supplied key does not match the tenant or global API key.
tenant_requiredA tenant code is required for tenant-scoped writes or tenant-key reads.
read_only_api_keyThe key can read data but cannot create, update, or delete objects.
missing_required_fieldA required create field is missing.

Revision #21
Created 2026-06-06 07:32:11 UTC by Admin
Updated 2026-11-23 15:53:52 UTC by Admin