# API

Reference guide for the legacy ProxyAPI and the newer OpenAPI JSON endpoint, including authentication, object scope, request patterns, examples, and error handling.

# OpenAPI JSON endpoint reference and examples

## Overview and examples

`openapi.php` is the MiRTA PBX JSON API endpoint based on the OpenAPI Specification. It supports standard HTTP methods, JSON request bodies, API-key authentication, tenant scoping, and CRUD operations for many PBX configuration objects.

The OpenAPI Specification, often abbreviated as OAS, is a vendor-neutral and programming-language independent description format for HTTP APIs. An OpenAPI document describes the public contract of an API: available paths, supported operations, parameters, request and response bodies, authentication methods, examples, and general service metadata. The document is normally published as JSON or YAML, which makes it readable by people and directly usable by tools.

In MiRTA PBX, the OpenAPI document acts as a machine-readable map of the available API. It lets administrators and integrators inspect the supported endpoints, build repeatable integrations, and keep API usage aligned with the behavior exposed by the PBX server.

## Why Use OpenAPI

<table id="bkmrk-advantagedescription"><thead><tr><th>Advantage</th><th>Description</th></tr></thead><tbody><tr><td>Shared API contract</td><td>The specification provides one explicit description of what the API is expected to expose, independently from the language used to implement the server or the client.</td></tr><tr><td>Interactive documentation</td><td>OpenAPI-compatible tools can render the specification as browsable documentation where developers can inspect endpoints and, when enabled, try requests from the browser.</td></tr><tr><td>Client and server generation</td><td>Tooling can generate client libraries, SDKs, server stubs, and boilerplate request handling from the same API description.</td></tr><tr><td>Testing and validation</td><td>The API document can be used for contract tests, request and response validation, mock servers, and security checks against the declared API surface.</td></tr><tr><td>Better integration workflow</td><td>Integrators can import the specification into API clients, testing tools, gateways, and monitoring systems instead of manually recreating every endpoint and payload format.</td></tr></tbody></table>

## OpenAPI and Swagger

OpenAPI is the specification. Swagger refers to a family of tools built around that specification, such as Swagger UI for interactive documentation and Swagger Codegen for generating client libraries or server stubs. MiRTA PBX exposes the OpenAPI document; external OpenAPI or Swagger-compatible tools can consume it.

## Specification

The OpenAPI document is available from these endpoints:

```
GET /mirtapbx/openapi.php
GET /mirtapbx/openapi.php?spec=1
GET /mirtapbx/openapi.php/openapi.json
GET /mirtapbx/openapi.php/swagger.json
```

The response is an OpenAPI 3.0.3 JSON document.

## Authentication

Provide the API key as a query parameter, an `X-API-Key` header, or a bearer token. Tenant API keys require a tenant code. Global keys can list across tenants when no tenant is supplied.

```
curl -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/mirtapbx/openapi.php/extensions?tenant=TENANTCODE"

curl -H "Authorization: Bearer TENANT_API_KEY" \
  "https://pbx.example.com/mirtapbx/openapi.php/extension?number=100&tenant=TENANTCODE"
```

## API Key Scope

### Tenant API Key

When using a tenant-level API key, include the tenant parameter. The tenant can be supplied by tenant code or tenant name.

```
openapi.php/extensions?tenant=TENANTCODE&key=TENANT_API_KEY
```

### Global API Key

When using a global API key, the tenant parameter is optional. If tenant is provided, the request is scoped to that tenant. If tenant is omitted, list and get requests can return records across tenants where the object supports global access.

```
openapi.php/extensions?key=GLOBAL_API_KEY
```

Some objects can be edited at global level by adding `global=yes`. This is supported for global settings, global custom destinations, global media files, global music on hold, global caller ID blacklist entries, global cron jobs, global feature codes, and global short numbers.

The tenant, user, user profile, and routing profile objects require an Admin API key. Tenant API keys are rejected for these objects. For users, adding `tenant=TENANTCODE` with an Admin API key filters list and get requests to users assigned to that tenant.

```
openapi.php/featurecodes?global=yes&key=GLOBAL_API_KEY
```

## Endpoint Patterns

<table id="bkmrk-actionpattern-listge"><thead><tr><th>Action</th><th>Pattern</th></tr></thead><tbody><tr><td>List</td><td>`GET /openapi.php/extensions?tenant=TENANTCODE`</td></tr><tr><td>Get by ID</td><td>`GET /openapi.php/extension?id=ID&tenant=TENANTCODE`</td></tr><tr><td>Get extension by number</td><td>`GET /openapi.php/extensions/number/100?tenant=TENANTCODE`</td></tr><tr><td>Create</td><td>`POST /openapi.php/extensions?tenant=TENANTCODE`</td></tr><tr><td>Modify</td><td>`PATCH /openapi.php/extensions/ID?tenant=TENANTCODE`</td></tr><tr><td>Delete</td><td>`DELETE /openapi.php/extensions/ID?tenant=TENANTCODE`</td></tr></tbody></table>

## Quick Examples

```
# Create a PJSIP extension
curl -X POST -H "X-API-Key: TENANT_API_KEY" -H "Content-Type: application/json" \
  -d '{"number":"210","name":"API Demo","tech":"PJSIP","password":"change-this-secret"}' \
  "https://pbx.example.com/mirtapbx/openapi.php/extensions?tenant=TENANTCODE"

# Update a queue name
curl -X PATCH -H "X-API-Key: TENANT_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Accounting Support"}' \
  "https://pbx.example.com/mirtapbx/openapi.php/queues/12?tenant=TENANTCODE"

# Create a voice routing profile with a global key
curl -X POST -H "X-API-Key: GLOBAL_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Docs Demo Voice Routing","description":"Documentation example","type":"VOICE"}' \
  "https://pbx.example.com/mirtapbx/openapi.php/routingprofiles"

# Move a tenant to Post Paid and assign a routing profile
curl -X PATCH -H "X-API-Key: GLOBAL_API_KEY" -H "Content-Type: application/json" \
  -d '{"te_payment_type":"Post Paid","routing_profile_id":3}' \
  "https://pbx.example.com/mirtapbx/openapi.php/tenant?id=TENANT_ID"
```

## Supported Objects

The endpoint maps plural and singular paths for extensions, voicemails, tenants, users, user profiles, routing profiles, conditions, IVRs, custom destinations, hunt lists, DIDs, queues, settings, media files, music on hold, paging groups, conference rooms, flows, tenant variables, DISAs, caller ID blacklists, campaigns, campaign numbers, cron jobs, feature codes, short numbers, and provisioning phones.

## Errors

Errors are returned as JSON with an error code and message. Common errors include missing API key, invalid API key, tenant not found, invalid JSON, missing required field, unsupported method, and endpoint not found.

## External OpenAPI Resources

- [OpenAPI Initiative: What is OpenAPI?](https://www.openapis.org/what-is-openapi)
- [OpenAPI Initiative: Getting Started introduction](https://learn.openapis.org/introduction.html)
- [Swagger Docs: What is OpenAPI?](https://swagger.io/docs/specification/v3_0/about/)

## List Extensions

### Endpoint

```
GET openapi.php/extensions
```

Alternative compatibility format:

```
openapi.php?object=extension&action=list
```

### Parameters

<table id="bkmrk-namerequireddescript"><thead><tr><th>Name</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>Yes, unless using header authentication</td><td>Full or read-only API key</td></tr><tr><td>tenant</td><td>Required for tenant keys</td><td>Tenant code or tenant name</td></tr></tbody></table>

### Example Request

```
curl "https://pbx.example.com/openapi.php/extensions?tenant=TENANTCODE&key=APIKEY"
```

Using header authentication:

```
curl \
  -H "X-API-Key: APIKEY" \
  "https://pbx.example.com/openapi.php/extensions?tenant=TENANTCODE"
```

Using bearer authentication:

```
curl \
  -H "Authorization: Bearer APIKEY" \
  "https://pbx.example.com/openapi.php/extensions?tenant=TENANTCODE"
```

### Example Response

```
[
  {
    "id": 101,
    "number": "100",
    "name": "Reception",
    "tech": "PJSIP"
  },
  {
    "id": 102,
    "number": "101",
    "name": "Office",
    "tech": "SIP"
  }
]
```

## Response Fields

<table id="bkmrk-fieldtypedescription"><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>integer</td><td>Extension internal ID</td></tr><tr><td>number</td><td>string</td><td>Extension number</td></tr><tr><td>name</td><td>string</td><td>Extension display name</td></tr><tr><td>tech</td><td>string</td><td>Extension technology, for example SIP, PJSIP, VIRTUAL, or CUSTOM</td></tr></tbody></table>

## Get Extension Information

This endpoint returns detailed information for one extension.

The extension can be selected by internal extension ID or by extension number.

When using the global full API key, the response also includes the extension password when a password exists for the extension technology.

Tenant API keys and read-only API keys do not return the extension password.

### Endpoints

Get an extension by ID:

```
GET openapi.php/extension?id=EXTENSION_ID
```

Alternative path format:

```
GET openapi.php/extensions/EXTENSION_ID
```

Get an extension by number:

```
GET openapi.php/extension?number=EXTENSION_NUMBER
```

Alternative path format:

```
GET openapi.php/extensions/number/EXTENSION_NUMBER
```

Alternative compatibility format:

```
openapi.php?object=extension&action=info&id=EXTENSION_ID
openapi.php?object=extension&action=info&number=EXTENSION_NUMBER
```

### Parameters

<table id="bkmrk-namerequireddescript-1"><thead><tr><th>Name</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>Yes, unless using header authentication</td><td>Full or read-only API key</td></tr><tr><td>tenant</td><td>Required for tenant keys</td><td>Tenant code or tenant name</td></tr><tr><td>id</td><td>Required if number is not provided</td><td>Extension internal ID</td></tr><tr><td>number</td><td>Required if id is not provided</td><td>Extension number</td></tr></tbody></table>

Use either id or number, not both.

When using a global API key without the tenant parameter, selecting by extension number can match more than one tenant. In that case the request returns an error and the request should be repeated using the tenant parameter or the extension ID.

### Example Requests

Get by ID:

```
curl "https://pbx.example.com/openapi.php/extension?id=101&tenant=TENANTCODE&key=APIKEY"
```

Get by number:

```
curl "https://pbx.example.com/openapi.php/extension?number=100&tenant=TENANTCODE&key=APIKEY"
```

Using header authentication:

```
curl \
  -H "X-API-Key: APIKEY" \
  "https://pbx.example.com/openapi.php/extension?number=100&tenant=TENANTCODE"
```

### Example Response

The response includes all fields from the extension table, the normalized fields id, number, name, and tech, the current state when available, the technology username, technology-specific details, and related records.

Related records are returned in the related object. Depending on the extension configuration, this can include state information, registrations, PJSIP contacts, call groups, pickup groups, destinations, queue membership, allowed queue membership, user profile, routing profiles, client rate, caller ID regex, music on hold, parking lot, conditions, media files, and associated phones.

The me\_data binary field from media files is not returned in this response.

```
{
  "ex_id": "101",
  "ex_te_id": "1",
  "ex_name": "Reception",
  "ex_number": "100",
  "ex_tech": "PJSIP",
  "ex_tech_id": "55",
  "tenant_code": "TENANTCODE",
  "tenant_name": "Tenant Name",
  "id": 101,
  "number": "100",
  "name": "Reception",
  "tech": "PJSIP",
  "username": "100",
  "state": "NOT_INUSE",
  "st_state": "NOT_INUSE",
  "tech_details": {
    "endpoint": {
      "id": "100",
      "tech_id": "55",
      "te_id": "1"
    },
    "aor": {
      "id": "100",
      "max_contacts": "99"
    },
    "auth": {
      "id": "100",
      "username": "100"
    }
  },
  "related": {
    "state": {
      "st_extension": "100",
      "st_state": "NOT_INUSE"
    },
    "callgroups": [],
    "pickupgroups": [],
    "destinations": [],
    "referenced_by_destinations": [],
    "queue_members": [],
    "allowed_queue_members": [],
    "userprofile": {
      "up_id": "3",
      "up_name": "Basic user panel"
    },
    "routing_profile": {
      "rp_id": "1",
      "rp_name": "Default"
    },
    "sms_routing_profile": false,
    "client_rate": false,
    "callerid_regex": false,
    "callerid_regex_rules": [],
    "music_on_hold": false,
    "parkinglot": false,
    "conditions": [],
    "mediafiles": [],
    "phones": []
  }
}
```

When the global full API key is used, the response can also include:

```
{
  "password": "extension_password"
}
```

## Create Extension

This endpoint creates one extension. A full API key is required. Read-only API keys are rejected.

The request is checked against the installed license before the extension is created.

### Endpoint

```
POST openapi.php/extensions
```

Alternative compatibility format:

```
POST openapi.php?object=extension&action=add
POST openapi.php?object=extension&action=create
```

### Parameters

<table id="bkmrk-namerequireddescript-2"><thead><tr><th>Name</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>Yes, unless using header authentication</td><td>Full API key</td></tr><tr><td>tenant</td><td>Yes</td><td>Tenant code or tenant name</td></tr></tbody></table>

### Request Body

The body is JSON. The API accepts the extension table fields used by the web page, such as ex\_number, ex\_name, ex\_tech, and the technology table fields for sipfriends, ps\_endpoints, ps\_aors, ps\_auths, ce\_customextensions, and ve\_virtualextensions.

Short aliases are also accepted:

<table id="bkmrk-aliasfield-numberex_"><thead><tr><th>Alias</th><th>Field</th></tr></thead><tbody><tr><td>number</td><td>ex\_number</td></tr><tr><td>name</td><td>ex\_name</td></tr><tr><td>tech</td><td>ex\_tech</td></tr><tr><td>password</td><td>SIP secret or PJSIP auth password</td></tr><tr><td>username</td><td>Technology username</td></tr><tr><td>sipusername</td><td>Technology username, matching the web page field</td></tr><tr><td>mailbox</td><td>ex\_mailbox and PJSIP mailboxes</td></tr></tbody></table>

Supported technologies are SIP, PJSIP, CUSTOM, and VIRTUAL. If tech is omitted, PJSIP is used.

### Example Request

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"number":"100","name":"Reception","tech":"PJSIP","password":"secret-password"}' \
  "https://pbx.example.com/openapi.php/extensions?tenant=TENANTCODE"
```

Nested technology fields can also be supplied:

```
{
  "ex_number": "100",
  "ex_name": "Reception",
  "ex_tech": "PJSIP",
  "ps_aors": {
    "max_contacts": 99
  },
  "ps_endpoints": {
    "allow": "alaw:20;ulaw:20"
  },
  "ps_auths": {
    "password": "secret-password"
  }
}
```

### Example Response

The response is the same detailed extension object returned by the get endpoint, with HTTP status 201.

## Modify Extension

This endpoint modifies an existing extension. A full API key is required. Read-only API keys are rejected.

The extension can be selected by internal ID or extension number. Use either id or number, not both.

### Endpoints

```
PUT openapi.php/extension?id=EXTENSION_ID
PATCH openapi.php/extension?id=EXTENSION_ID
PATCH openapi.php/extensions/EXTENSION_ID
```

Alternative compatibility format:

```
PUT openapi.php?object=extension&action=update&objectid=EXTENSION_ID
PATCH openapi.php?object=extension&action=modify&objectid=EXTENSION_ID
```

### Request Body

The body is JSON and can contain the same table fields accepted by the create endpoint. Only fields included in the body are updated.

Changing the extension technology is not supported. To change technology, delete and recreate the extension.

### Example Request

```
curl \
  -X PATCH \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"ex_name":"Reception Desk","ex_callgroup":"1,2","ex_pickupgroup":"1,2"}' \
  "https://pbx.example.com/openapi.php/extension?id=101&tenant=TENANTCODE"
```

## Delete Extension

This endpoint deletes an extension and its related technology rows. A full API key is required. Read-only API keys are rejected.

### Endpoints

```
DELETE openapi.php/extension?id=EXTENSION_ID
DELETE openapi.php/extensions/EXTENSION_ID
```

Alternative compatibility format:

```
DELETE openapi.php?object=extension&action=delete&objectid=EXTENSION_ID
```

### Example Request

```
curl \
  -X DELETE \
  -H "X-API-Key: APIKEY" \
  "https://pbx.example.com/openapi.php/extension?id=101&tenant=TENANTCODE"
```

### Example Response

```
{
  "deleted": true,
  "id": 101,
  "number": "100"
}
```

## Extension Busy Destination

The busy destination for an extension can be set with the onbusy alias.

Destination values use the same TYPE-ID format returned in related.destinations. For example, use VOICEMAIL-12 for voicemail ID 12 or EXT-45 for extension internal ID 45. Extension destinations use the extension internal ID, not the extension number.

To send busy calls to an existing voicemail:

```
curl \
  -X PATCH \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"onbusy":["VOICEMAIL-12"]}' \
  "https://pbx.example.com/openapi.php/extension?id=101&tenant=TENANTCODE"
```

The same destination can also be supplied with the explicit destination type:

```
{
  "destinations": {
    "EXT-BUSY": ["VOICEMAIL-12"]
  }
}
```

To use the extension same-number voicemail and create it automatically when missing:

```
{
  "onbusy": ["SAMENUMBERVM"]
}
```

Sending an empty array clears the busy destination:

```
{
  "onbusy": []
}
```

## Additional Configuration Objects

The following objects use the same authentication and HTTP behavior as extensions.

<table id="bkmrk-objectlist-endpoints"><thead><tr><th>Object</th><th>List Endpoint</th><th>Single Endpoint</th><th>ID Field</th><th>Main Table</th></tr></thead><tbody><tr><td>voicemail</td><td>GET openapi.php/voicemails</td><td>openapi.php/voicemail?id=ID</td><td>uniqueid</td><td>voicemail</td></tr><tr><td>tenant</td><td>GET openapi.php/tenants</td><td>openapi.php/tenant?id=ID</td><td>te\_id</td><td>te\_tenants</td></tr><tr><td>user</td><td>GET openapi.php/users</td><td>openapi.php/user?id=ID</td><td>us\_id</td><td>us\_users</td></tr><tr><td>userprofile</td><td>GET openapi.php/userprofiles</td><td>openapi.php/userprofile?id=ID</td><td>up\_id</td><td>up\_userprofiles</td></tr><tr><td>routingprofile</td><td>GET openapi.php/routingprofiles</td><td>openapi.php/routingprofile?id=ID</td><td>rp\_id</td><td>rp\_routingprofiles</td></tr><tr><td>condition</td><td>GET openapi.php/conditions</td><td>openapi.php/condition?id=ID</td><td>co\_id</td><td>co\_conditions</td></tr><tr><td>ivr</td><td>GET openapi.php/ivrs</td><td>openapi.php/ivr?id=ID</td><td>iv\_id</td><td>iv\_ivrs</td></tr><tr><td>customdestination</td><td>GET openapi.php/customdestinations</td><td>openapi.php/customdestination?id=ID</td><td>cu\_id</td><td>cu\_customs</td></tr><tr><td>huntlist</td><td>GET openapi.php/huntlists</td><td>openapi.php/huntlist?id=ID</td><td>hu\_id</td><td>hu\_huntlists</td></tr><tr><td>did</td><td>GET openapi.php/dids</td><td>openapi.php/did?id=ID</td><td>di\_id</td><td>di\_dids</td></tr><tr><td>queue</td><td>GET openapi.php/queues</td><td>openapi.php/queue?id=ID</td><td>qu\_id</td><td>qu\_queues</td></tr><tr><td>setting</td><td>GET openapi.php/settings</td><td>openapi.php/setting?id=ID</td><td>se\_id</td><td>se\_settings</td></tr><tr><td>mediafile</td><td>GET openapi.php/mediafiles</td><td>openapi.php/mediafile?id=ID</td><td>me\_id</td><td>me\_mediafiles</td></tr><tr><td>musiconhold</td><td>GET openapi.php/musiconholds</td><td>openapi.php/musiconhold?id=ID</td><td>mu\_id</td><td>mu\_musiconholds</td></tr><tr><td>paginggroup</td><td>GET openapi.php/paginggroups</td><td>openapi.php/paginggroup?id=ID</td><td>pa\_id</td><td>pa\_paginggroups</td></tr><tr><td>conferenceroom</td><td>GET openapi.php/conferencerooms</td><td>openapi.php/conferenceroom?id=ID</td><td>cr\_id</td><td>cr\_conferencerooms</td></tr><tr><td>flow</td><td>GET openapi.php/flows</td><td>openapi.php/flow?id=ID</td><td>fl\_id</td><td>fl\_flows</td></tr><tr><td>tenantvariable</td><td>GET openapi.php/tenantvariables</td><td>openapi.php/tenantvariable?id=ID</td><td>tv\_id</td><td>tv\_tenantvariables</td></tr><tr><td>disa</td><td>GET openapi.php/disas</td><td>openapi.php/disa?id=ID</td><td>ds\_id</td><td>ds\_disas</td></tr><tr><td>calleridblacklist</td><td>GET openapi.php/calleridblacklists</td><td>openapi.php/calleridblacklist?id=ID</td><td>bl\_id</td><td>bl\_blacklists</td></tr><tr><td>campaign</td><td>GET openapi.php/campaigns</td><td>openapi.php/campaign?id=ID</td><td>ca\_id</td><td>ca\_campaigns</td></tr><tr><td>campaignnumber</td><td>GET openapi.php/campaignnumbers</td><td>openapi.php/campaignnumber?id=ID</td><td>cn\_id</td><td>cn\_campaignnumbers</td></tr><tr><td>cronjob</td><td>GET openapi.php/cronjobs</td><td>openapi.php/cronjob?id=ID</td><td>cr\_id</td><td>cr\_cronjobs</td></tr><tr><td>featurecode</td><td>GET openapi.php/featurecodes</td><td>openapi.php/featurecode?id=ID</td><td>fe\_id</td><td>fe\_features</td></tr><tr><td>shortnumber</td><td>GET openapi.php/shortnumbers</td><td>openapi.php/shortnumber?id=ID</td><td>sn\_id</td><td>sn\_shortnumbers</td></tr><tr><td>provisioningphone</td><td>GET openapi.php/provisioningphones</td><td>openapi.php/provisioningphone?id=ID</td><td>ph\_id</td><td>ph\_phones</td></tr></tbody></table>

### Generic Endpoints

Use the plural path for list and create operations:

```
GET openapi.php/voicemails
POST openapi.php/voicemails
GET openapi.php/tenants
POST openapi.php/tenants
GET openapi.php/users
POST openapi.php/users
GET openapi.php/userprofiles
POST openapi.php/userprofiles
GET openapi.php/routingprofiles
POST openapi.php/routingprofiles
GET openapi.php/conditions
POST openapi.php/conditions
GET openapi.php/ivrs
POST openapi.php/ivrs
GET openapi.php/customdestinations
POST openapi.php/customdestinations
GET openapi.php/huntlists
POST openapi.php/huntlists
GET openapi.php/dids
POST openapi.php/dids
GET openapi.php/queues
POST openapi.php/queues
GET openapi.php/settings
POST openapi.php/settings
GET openapi.php/mediafiles
POST openapi.php/mediafiles
GET openapi.php/musiconholds
POST openapi.php/musiconholds
GET openapi.php/paginggroups
POST openapi.php/paginggroups
GET openapi.php/conferencerooms
POST openapi.php/conferencerooms
GET openapi.php/flows
POST openapi.php/flows
GET openapi.php/tenantvariables
POST openapi.php/tenantvariables
GET openapi.php/disas
POST openapi.php/disas
GET openapi.php/calleridblacklists
POST openapi.php/calleridblacklists
GET openapi.php/campaigns
POST openapi.php/campaigns
GET openapi.php/campaignnumbers
POST openapi.php/campaignnumbers
GET openapi.php/cronjobs
POST openapi.php/cronjobs
GET openapi.php/featurecodes
POST openapi.php/featurecodes
GET openapi.php/shortnumbers
POST openapi.php/shortnumbers
GET openapi.php/provisioningphones
POST openapi.php/provisioningphones
```

Use either the singular endpoint with an id parameter or the plural path with the ID:

```
GET openapi.php/voicemail?id=ID
PATCH openapi.php/voicemail?id=ID
DELETE openapi.php/voicemail?id=ID

GET openapi.php/voicemails/ID
PATCH openapi.php/voicemails/ID
DELETE openapi.php/voicemails/ID
```

The same pattern applies to all generic objects listed in the table above.

Alternative compatibility format:

```
openapi.php?object=voicemail&action=list
openapi.php?object=voicemail&action=info&id=ID
openapi.php?object=voicemail&action=create
openapi.php?object=voicemail&action=modify&id=ID
openapi.php?object=voicemail&action=delete&id=ID
```

### Generic Request Body

The body is JSON. Fields can be supplied using the database column names used by the web pages.

For the user object, password, \_password, and us\_password are treated as clear text input and are stored using the same SHA-256 hash used by the web page. To provide a precomputed hash, use password\_hash or us\_password\_hash.

Short aliases are supported where they are unambiguous:

<table id="bkmrk-objectaliasfield-voi"><thead><tr><th>Object</th><th>Alias</th><th>Field</th></tr></thead><tbody><tr><td>voicemail</td><td>number</td><td>mailbox</td></tr><tr><td>voicemail</td><td>name</td><td>fullname</td></tr><tr><td>tenant</td><td>name</td><td>te\_name</td></tr><tr><td>tenant</td><td>code</td><td>te\_code</td></tr><tr><td>user</td><td>username</td><td>us\_username</td></tr><tr><td>user</td><td>password</td><td>us\_password</td></tr><tr><td>user</td><td>profile\_id</td><td>us\_up\_id</td></tr><tr><td>userprofile</td><td>name</td><td>up\_name</td></tr><tr><td>userprofile</td><td>reserved</td><td>up\_reserved</td></tr><tr><td>routingprofile</td><td>name</td><td>rp\_name</td></tr><tr><td>routingprofile</td><td>type</td><td>rp\_type</td></tr><tr><td>condition</td><td>name</td><td>co\_name</td></tr><tr><td>condition</td><td>type</td><td>co\_type</td></tr><tr><td>ivr</td><td>name</td><td>iv\_name</td></tr><tr><td>customdestination</td><td>name</td><td>cu\_name</td></tr><tr><td>huntlist</td><td>name</td><td>hu\_name</td></tr><tr><td>huntlist</td><td>number</td><td>hu\_number</td></tr><tr><td>did</td><td>number</td><td>di\_number</td></tr><tr><td>queue</td><td>name</td><td>qu\_name</td></tr><tr><td>setting</td><td>code</td><td>se\_code</td></tr><tr><td>setting</td><td>value</td><td>se\_value</td></tr><tr><td>mediafile</td><td>name</td><td>me\_name</td></tr><tr><td>mediafile</td><td>data\_base64</td><td>me\_data</td></tr><tr><td>musiconhold</td><td>name</td><td>mu\_name</td></tr><tr><td>musiconhold</td><td>custom</td><td>mu\_custom</td></tr><tr><td>paginggroup</td><td>number</td><td>pa\_number</td></tr><tr><td>paginggroup</td><td>name</td><td>pa\_name</td></tr><tr><td>conferenceroom</td><td>name</td><td>cr\_name</td></tr><tr><td>conferenceroom</td><td>number</td><td>cr\_number</td></tr><tr><td>flow</td><td>name</td><td>fl\_name</td></tr><tr><td>flow</td><td>variable\_name</td><td>fl\_variable\_name</td></tr><tr><td>tenantvariable</td><td>variable\_id</td><td>tv\_al\_id</td></tr><tr><td>tenantvariable</td><td>value</td><td>tv\_value</td></tr><tr><td>disa</td><td>name</td><td>ds\_name</td></tr><tr><td>calleridblacklist</td><td>callerid</td><td>bl\_callerid</td></tr><tr><td>campaign</td><td>name</td><td>ca\_name</td></tr><tr><td>campaign</td><td>state</td><td>ca\_state</td></tr><tr><td>campaignnumber</td><td>campaign\_id</td><td>cn\_ca\_id</td></tr><tr><td>campaignnumber</td><td>number</td><td>cn\_number</td></tr><tr><td>cronjob</td><td>name</td><td>cr\_name</td></tr><tr><td>cronjob</td><td>run</td><td>cr\_run</td></tr><tr><td>featurecode</td><td>code</td><td>fe\_code</td></tr><tr><td>shortnumber</td><td>number</td><td>sn\_number</td></tr><tr><td>provisioningphone</td><td>name</td><td>ph\_name</td></tr><tr><td>provisioningphone</td><td>mac</td><td>ph\_mac</td></tr></tbody></table>

### Destinations

Objects that use destinations accept a destinations object. Each destination item can be either a string in TYPE-ID format or an object with type and id.

```
{
  "di_number": "390212345678",
  "di_comment": "Main number",
  "destinations": {
    "DID": ["EXT-101"],
    "DID-UNCONDITIONAL": [
      { "type": "VOICEMAIL", "id": 10 }
    ]
  }
}
```

Supported destination keys:

<table id="bkmrk-objectdestination-ke"><thead><tr><th>Object</th><th>Destination Keys</th></tr></thead><tbody><tr><td>voicemail</td><td>VOICEMAIL-OPERATOR, VOICEMAIL-FOLLOW, VOICEMAIL-BROADCAST</td></tr><tr><td>condition</td><td>CONDITION, NOTCONDITION, and CONDITION1 through CONDITION20</td></tr><tr><td>ivr</td><td>IVR\_1 through IVR\_9, IVR\_0, IVR\_STAR, IVR\_SHARP, IVR\_WRONG, IVR\_TIMEOUT, IVR\_HANGUP, IVR\_FEATURE, IVR\_EXTENSION, IVR\_MEDIAFILE, IVR\_OPTIONSMEDIAFILE, and custom keys beginning with CUSTOMIVR\_</td></tr><tr><td>customdestination</td><td>PRIVACY-DONTCALL, PRIVACY-TORTURE, CTONANSWER, CALLBACK-CONNECTED, CTONCALLERHANGUP, SPLITCHANNELACTION-CALLER, SPLITCHANNELACTION-CALLED, and RANDOMDESTINATION keys</td></tr><tr><td>musiconhold</td><td>MUSICONHOLD. Plain numeric values are treated as media file IDs.</td></tr><tr><td>paginggroup</td><td>PAGING. Plain numeric values are treated as extension IDs.</td></tr><tr><td>huntlist</td><td>HUNTLIST, HUNTLIST-TIMEOUT</td></tr><tr><td>did</td><td>DID, DID-UNCONDITIONAL, DID-SMS, DID-FAXSUCCESS</td></tr><tr><td>queue</td><td>QUEUE-FULL, QUEUE-TIMEOUT, QUEUE-EXITKEY, QUEUE-ONCALLBACK, QUEUE-NOBODYHOME, QUEUE-NOFREEMEMBER, QUEUE-PERIODICANNOUNCE, QUEUE-BEFORERINGING, QUEUE-ONAUTOPAUSE, QUEUE-ONABANDONEDCALL</td></tr><tr><td>flow</td><td>FLOW</td></tr><tr><td>campaign</td><td>CAMPAIGN-ONCONNECT and CAMPAIGN-DONOTCALL. Plain numeric values for CAMPAIGN-DONOTCALL are treated as do-not-call IDs.</td></tr><tr><td>cronjob</td><td>CRONJOB</td></tr><tr><td>featurecode</td><td>FEATURE</td></tr></tbody></table>

### Related Records

Get responses include a related object when the object has related configuration.

For users, related.profile contains the selected main user profile. related.tenants, related.routing\_profiles, related.allowed\_userprofiles, related.client\_rates, and the restriction lists show the assignments used by the user page. Create and modify requests can replace these assignments by sending tenants, routingprofiles, allowed\_userprofiles, clientrates, queue\_restrictions, extension\_restrictions, or provider\_restrictions as arrays of IDs.

For user profiles, related.privileges contains the assigned privilege rows. Create and modify requests can replace the assigned privileges by sending privileges as an array of privilege IDs or objects containing ug\_id and optional param1 through param5.

For conditions, related.extended\_infos contains rows from ce\_conditions\_extended. Create and modify requests can replace these rows by sending extended\_infos.

For queues, related.realtime contains the realtime queue row. Create and modify requests can send realtime queue fields either at the top level or nested under queue or realtime. Queue members can be replaced by sending members, queue\_member, or queue\_members. Allowed queue members can be replaced by sending allowed\_members, aq\_allowed\_queue\_member, or allowed\_queue\_members.

For hunt lists, create and modify requests update the matching follow-me records used by the dialplan.

For custom destinations, related.extended\_infos contains rows from ce\_customs\_extended and related.binary\_files lists stored binary records without returning the binary payload.

For music on hold, related.realtime contains the linked musiconhold row and related.entries contains the generated playlist entries. Create and modify requests can send mediafiles as media file IDs or MEDIAFILE-ID strings. Sending entries replaces the raw musiconhold\_entry rows directly.

For conference rooms, related.meetme contains the linked realtime conference row. Creating a conference room also creates the linked meetme row, and deleting it removes that row.

For flows, sending status, state, or st\_state updates the matching st\_states row when the flow has a number.

For campaigns, related.numbers\_count, related.numbers\_by\_disposition, and related.binary\_files summarize linked campaign number and fax file records. Campaign fax files can be replaced by sending binary\_files with name and data\_base64. Campaign numbers are managed through the separate campaignnumber object. The list endpoint accepts campaign\_id or caid to limit numbers to one campaign.

For cron jobs, setting run to yes schedules a run in the same way as setting cr\_run.

For provisioning phones, related.button\_layouts and related.phonebooks contain the linked phone layout and phonebook rows.

### Examples

Create a voicemail:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"mailbox":"200","fullname":"Sales","password":"1234","email":"sales@example.com"}' \
  "https://pbx.example.com/openapi.php/voicemails?tenant=TENANTCODE"
```

Modify a DID destination:

```
curl \
  -X PATCH \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"destinations":{"DID":["EXT-101"]}}' \
  "https://pbx.example.com/openapi.php/did?id=25&tenant=TENANTCODE"
```

Create a queue with realtime fields:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"qu_name":"Support","qu_number":"700","queue":{"strategy":"ringall","timeout":20},"members":[{"membername":"100","interface":"Local/AG-000-NF-101@fromotherpbx/n","state_interface":"Custom:100","member_device":"100","penalty":0,"paused":0}]}' \
  "https://pbx.example.com/openapi.php/queues?tenant=TENANTCODE"
```

Create a global feature code:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: GLOBAL_APIKEY" \
  -d '{"code":"*56","comment":"Pickup"}' \
  "https://pbx.example.com/openapi.php/featurecodes?global=yes"
```

Create a conference room:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"name":"Weekly Meeting","number":"900","pin":"1234","adminpin":"4321","maxusers":10}' \
  "https://pbx.example.com/openapi.php/conferencerooms?tenant=TENANTCODE"
```

Create a music on hold playlist:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"name":"Support Hold","mediafiles":[12,15],"default":"on"}' \
  "https://pbx.example.com/openapi.php/musiconholds?tenant=TENANTCODE"
```

Create a campaign number:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"campaign_id":5,"number":"390212345678","description":"Lead A"}' \
  "https://pbx.example.com/openapi.php/campaignnumbers?tenant=TENANTCODE"
```

Run a cron job:

```
curl \
  -X PATCH \
  -H "Content-Type: application/json" \
  -H "X-API-Key: APIKEY" \
  -d '{"run":"yes"}' \
  "https://pbx.example.com/openapi.php/cronjob?id=8&tenant=TENANTCODE"
```

Create a user and assign tenants, routing profiles, and allowed user profiles:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: GLOBAL_APIKEY" \
  -d '{"username":"operator","password":"change-me","profile_id":3,"tenants":[1],"routingprofiles":[2,4],"allowed_userprofiles":[5]}' \
  "https://pbx.example.com/openapi.php/users"
```

Create a user profile with privileges:

```
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-Key: GLOBAL_APIKEY" \
  -d '{"name":"Helpdesk","description":"Helpdesk operators","privileges":[12,18,25]}' \
  "https://pbx.example.com/openapi.php/userprofiles"
```

## Change Logging

Create, modify, and delete operations write a process log entry and a user activity log entry using the OpenAPI user label. Related destination, user assignment, user profile privilege, condition, queue member, and queue realtime changes are also logged where applicable.

### Additional Error Responses

#### Missing Identifier

```
{
  "error": {
    "code": "missing_identifier",
    "message": "Provide an extension id or number."
  }
}
```

#### Invalid Identifier

```
{
  "error": {
    "code": "invalid_identifier",
    "message": "Use either id or number, not both."
  }
}
```

#### Extension Not Found

```
{
  "error": {
    "code": "extension_not_found",
    "message": "Extension not found."
  }
}
```

#### Multiple Extensions Found

```
{
  "error": {
    "code": "multiple_extensions_found",
    "message": "Multiple extensions match the requested number. Use the tenant parameter or the extension id."
  }
}
```

## Error Responses

Errors are returned as JSON.

### Missing API Key

```
{
  "error": {
    "code": "missing_api_key",
    "message": "Missing API key."
  }
}
```

### Invalid API Key

```
{
  "error": {
    "code": "invalid_api_key",
    "message": "Invalid API key."
  }
}
```

### Tenant Not Found

```
{
  "error": {
    "code": "tenant_not_found",
    "message": "Tenant not found."
  }
}
```

### Endpoint Not Found

```
{
  "error": {
    "code": "not_found",
    "message": "Endpoint not found."
  }
}
```

### Method Not Allowed

Supported methods are GET, POST, PUT, PATCH, and DELETE.

```
{
  "error": {
    "code": "method_not_allowed",
    "message": "Supported methods are GET, POST, PUT, PATCH and DELETE."
  }
}
```

## Notes

- Read-only API keys are allowed for list and get endpoints.
- A full API key is required for create, modify, and delete endpoints.
- Sensitive fields such as passwords, API keys, tokens, and media binary data are hidden unless the global full API key is used.
- The endpoint does not create a web session.
- Responses are always JSON.
- CORS is enabled with Access-Control-Allow-Origin: \*.
- OPTIONS requests return HTTP 204 for browser preflight support.

# Old ProxyAPI Legacy proxy API reference and examples.

## Overview and Examples

`proxyapi.php` is the legacy MiRTA PBX HTTP API. It is still useful for integrations that already depend on query-string based requests, plain text responses, CDR exports, queue operations, voicemail actions, phonebook operations, fax handling, and the older `MANAGEDB` object/action interface.

The API is controlled with the `reqtype` parameter. Most calls also require `key`; tenant-scoped calls normally require `tenant`. Several read operations accept `format=json`, `format=xml`, or `format=csv`. Write operations that update PBX records commonly send JSON in a POST field named `jsondata`.

## Common Parameters

<table id="bkmrk-parameterdescription"><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td>`reqtype`</td><td>Main request family, such as INFO, DND, QUEUE, VOICEMAIL, FAX, CDR, or MANAGEDB.</td></tr><tr><td>`key`</td><td>Tenant or admin API key. Use read-only keys when the integration does not need to change data.</td></tr><tr><td>`tenant`</td><td>Tenant code. Optional only for operations that allow an administrator key to act globally.</td></tr><tr><td>`format`</td><td>Optional output format. Common values are plain, json, xml, and csv, depending on the request.</td></tr><tr><td>`callback`</td><td>Optional JSONP callback name for cross-domain script integrations using JSON.</td></tr><tr><td>`language`</td><td>Optional language used by requests that support translated data.</td></tr><tr><td>`cache`</td><td>Set to no to bypass SQL or AMI cache for supported requests.</td></tr></tbody></table>

## Request Types

<table id="bkmrk-reqtypepurposecountp"><thead><tr><th>reqtype</th><th>Purpose</th></tr></thead><tbody><tr><td>`COUNTPEERS`</td><td>Count peers by node and optionally by tenant.</td></tr><tr><td>`COUNTCHANNELS`</td><td>Count active channels globally, by node, or by tenant.</td></tr><tr><td>`CHANSIPPEERS`</td><td>Return registered chan\_sip peers across the cluster.</td></tr><tr><td>`BLFS`</td><td>Return BLF status for peers and flows.</td></tr><tr><td>`DND`</td><td>Get or set do-not-disturb for an extension.</td></tr><tr><td>`FLOWS`</td><td>Read flow state.</td></tr><tr><td>`CHANNEL`</td><td>Read details for one channel.</td></tr><tr><td>`CHANNELS`</td><td>List active channels.</td></tr><tr><td>`GETCURRENTCALLS`</td><td>Show current calls for a phone or tenant.</td></tr><tr><td>`PHONEBOOKS`</td><td>List available phonebooks.</td></tr><tr><td>`PHONEBOOK`</td><td>Query, add, delete, clean, or dump phonebook records.</td></tr><tr><td>`INFO`</td><td>Read status, CDRs, recordings, DIDs, queues, agents, variables, flows, and other reporting data.</td></tr><tr><td>`AGENT`</td><td>Pause, unpause, list, add, or remove queue agents.</td></tr><tr><td>`ATXTRANSFER`</td><td>Perform attended transfer for a channel.</td></tr><tr><td>`CAMPAIGN`</td><td>Start, stop, pause, resume, or maintain campaign numbers.</td></tr><tr><td>`DIAL`</td><td>Originate a call from a source and connect it to a destination.</td></tr><tr><td>`FAX`</td><td>Send, list, or download faxes.</td></tr><tr><td>`HANGUP`</td><td>Hang up a channel or extension.</td></tr><tr><td>`MEDIAFILE`</td><td>Download media-file audio.</td></tr><tr><td>`QUEUE`</td><td>List, add, remove, clean, or log queue members.</td></tr><tr><td>`QUEUERESET`</td><td>Reset queue statistics.</td></tr><tr><td>`REBOOT`</td><td>Reboot one or more peers.</td></tr><tr><td>`RESPONSEPATH`</td><td>Read response-path results.</td></tr><tr><td>`SETFLOW`</td><td>Set a flow state or variable value.</td></tr><tr><td>`SMS`</td><td>Send an SMS.</td></tr><tr><td>`TRANSFER`</td><td>Transfer a channel.</td></tr><tr><td>`UNREGISTER`</td><td>Unregister one or more peers.</td></tr><tr><td>`USERGROUP`</td><td>Manage tenants and users assigned to user groups.</td></tr><tr><td>`VIRTUALEXT`</td><td>Manage members of a virtual extension.</td></tr><tr><td>`VOICEMAIL`</td><td>List mailboxes, list messages, download messages, mark read/unread, or delete messages.</td></tr><tr><td>`SETTING`</td><td>Get or set tenant settings.</td></tr><tr><td>`COUNTCALLS`</td><td>Count running calls.</td></tr><tr><td>`LICENSEDAYS`</td><td>Return days before license expiration.</td></tr><tr><td>`BALANCE`</td><td>Add or subtract tenant balance.</td></tr><tr><td>`CDR`</td><td>Get or update fields on a CDR row.</td></tr><tr><td>`MANAGEDB`</td><td>Read or change supported PBX database objects through object/action parameters.</td></tr><tr><td>`CHECKAUTH`</td><td>Validate a username and password and return privilege information.</td></tr><tr><td>`AUTHTOKEN`</td><td>Generate or reset one-time or expiring authentication tokens.</td></tr><tr><td>`GETWEBRTCAUTH`</td><td>Authenticate an extension user and return WebRTC details.</td></tr></tbody></table>

## Using POST jsondata

For `MANAGEDB`, phonebook, destination, and similar write requests, send the object fields as JSON in the POST field `jsondata`. The examples below show the URL and the JSON payload separately instead of wrapping every case in a PHP cURL script.

```
curl -X POST \
  --data-urlencode 'jsondata={"field":"value"}' \
  "https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=MANAGEDB&object=OBJECT&action=add"
```

## Examples

## INFO - SIMPLECDRS / Get the list of calls

Get the list of calls.

Use the date range and phone filters to narrow the returned call history. The phone filter searches the relevant caller, dialed, and answered number fields.

This uses the simplified call-history source and supports filters such as caller ID number and date range.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=SIMPLECDRS&tenant=TENANTCODE&calleridnum=103,104&start=2020-01-01&end=2020-12-31
```

## INFO - CDRS / Get the list of calls

Get the list of calls.

Use the date range and phone filters to narrow the returned call history. The phone filter searches the relevant caller, dialed, and answered number fields.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=CDRS&tenant=TENANTCODE&phone=103,104&start=2019-12-01&end=2022-12-31
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=CDRS&tenant=TENANTCODE&phone=103,104&start=2019-12-01&end=2022-12-31&format=xml&template=Test_CSV
```

Sample output or template:

```
{row_loop}{$uniqueid},{$ID},{$te_id},{$realsrc},{$lastdst},{$start},{$duration},{$answer},{$direction},{$direction},{$disposition}
{/row_loop}
```

## INFO - DIDS / Get the list of DIDs for one tenant

Get the list of DIDs for one tenant.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=DIDS&tenant=TENANTCODE
```

## INFO - DIDS / Get the list of DIDs for all tenants

Get the list of DIDs for all tenants.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=DIDS
```

## INFO - Flow / Get the state of a flow

Get the state of a flow.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=FLOW&id=61&tenant=TENANTCODE
```

## INFO - Extension / Get the state of a extension

Get the state of a extension.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=EXTSTATE&ext=500&tenant=TENANTCODE
```

## INFO - Extensions / Get the list of extensions

Get the list of extensions.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=EXTENSIONS&tenant=TENANTCODE
```

## INFO - Extensions / Get an extension by id

Get an extension by id.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=EXTENSIONS&tenant=TENANTCODE&id=36979
```

## INFO - Extensions / Get an extension by number

Get an extension by number.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=EXTENSIONS&tenant=TENANTCODE&number=100
```

## INFO - IVR Logs / Get the IVR logs

Get the IVR logs.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=INFO&info=IVRLOGS&format=json&start=2023-01-01&end=2024-12-31
```

## INFO - Variable / Get the value of a variable

Get the value of a variable.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=variable&id=61&tenant=TENANTCODE
```

## DND / Get the DND for an extension

Get the DND for an extension.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=DND&action=get&number=100
```

## DND /Set the DND for an extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=DND&action=set&number=100&value=on
```

## DIAL / Call an extension and then dial a number

Call an extension and then dial a number.

The originate response includes an ID that can later be used to query call status or retrieve the recording. Extra variables can be passed with the var parameter.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=DIAL&source=402&dest=9922323232&tenant=TENANTCODE&account=402-TENANTCODE
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=recording&id=15a4cfe6429054
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=DIAL&source=402&dest=9922323232&tenant=TENANTCODE&account=402-TENANTCODE&var=callid=453131
```

## HANGUP / Hangup a call by extension

Hangup a call by extension.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=HANGUP&extension=103-TENANTCODE&tenant=TENANTCODE
```

## AGENT / Pause agent from queue

Pause agent from queue.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=AGENT&action=PAUSE&queue=281&extension=104-TENANTCODE&tenant=TENANTCODE&pausereason=Breakfast
```

## AGENT / Get info for agent in all the queues

Get info for agent in all the queues.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=AGENT&action=LISTQUEUES&extension=104-TENANTCODE&tenant=TENANTCODE&format=json
```

## MEDIAFILE / Retrieve a media file by its ID

Retrieve a media file by its ID.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MEDIAFILE&tenant=TENANTCODE&id=19&action=GETAUDIO&objectid=3619
```

## QUEUE / Get the list of agents

Get the list of agents.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=QUEUE&tenant=TENANTCODE&action=list&number=9200
```

## QUEUE / Add an agent to a queue

Add an agent to a queue.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=QUEUE&tenant=TENANTCODE&action=add&number=9200&extension=103
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=QUEUE&tenant=TENANTCODE&action=add&number=781&extension=107&paused=1&penalty=4
```

## SETTING

### Get a tenant setting

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?tenant=TENANTCODE&key=APIKEY&reqtype=SETTING&action=GET&code=VMAUTORECOVER
```

### Set a tenant setting

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?tenant=TENANTCODE&key=APIKEY&reqtype=SETTING&action=SET&code=VMAUTORECOVER&value=no
```

## VOICEMAIL

### Get all voicemails for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=VOICEMAIL&tenant=TENANTCODE&action=list
```

### Get info about voicemails in a mailbox

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=VOICEMAIL&tenant=TENANTCODE&mailbox=102&action=messages
```

### Get the binary audio for a message

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=VOICEMAIL&tenant=TENANTCODE&mailbox=102&action=message&msgid=1475685709-00000004
```

### Mark a message as read

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=VOICEMAIL&tenant=TENANTCODE&mailbox=1000&action=markread&msgid=1543267778-00000007
```

### Mark a message as not read

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=VOICEMAIL&tenant=TENANTCODE&action=markunread&mailbox=1000&msgid=1543267778-00000007
```

## COUNTCALLS / Count the calls on a system

Count the calls on a system.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=COUNTCALLS
```

## RECORDINGS / Get or play a recording

Get or play a recording.

Use info=recording to download the file, or info=playrecording when the browser should play it inline.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=recording&id=srv02-1531779475.48&tenant=TENANTCODE
```

## TRANSCRIPT / Get the transcript for a recording

Get the transcript for a recording.

Use info=transcript with the recording unique ID to retrieve the generated transcript when transcription is enabled.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=transcript&id=srv02-1695552000.1043&tenant=TENANTCODE
```

## PHONEBOOKS

### Search for an entry

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=PHONEBOOK&subreqtype=query&tenant=TENANTCODE&phonebook=Default&field=name&value=Ben
```

### Add an entry

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=PHONEBOOK&subreqtype=add&phonebook=Default&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "NAME": "Ross",
  "PHONE1": "3564732920"
}
```

## FAX

### Send a fax

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=FAX&action=send&number=99397654321&source_number=123412345&tenant=TENANTCODE
```

Multipart upload example:

```
curl -F "filename=@/path/to/fax.pdf" "https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=FAX&action=send&tenant=TENANTCODE&source_number=15551230000&dest_number=15551239999"
```

### List faxes

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?tenant=TENANTCODE&key=APIKEY&reqtype=FAX&action=list
```

### Get a fax binary

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?tenant=TENANTCODE&key=APIKEY&reqtype=FAX&action=download&id=63095
```

## INFO

### Get the cdr for a tenant in CSV format

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=CDRS&format=csv&tenant=TENANTCODE&start=2017-01-01&end=2017-02-01
```

### Get the cdr for all tenants in CSV format

For one tenant, the tenant CSV template is used. With tenant=% across tenants, the admin CSV format is used.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=CDRS&format=csv&tenant=%&start=2017-01-01&end=2017-02-01
```

### Get the queue log for a tenant in CSV format

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=INFO&info=QUEUELOGS&format=csv&tenant=TENANTCODE&start=2017-10-01&end=2017-12-01
```

## Getting response paths results

Response Path results can be filtered by queue, answering extension, or unique ID and can be returned as plain text or XML.

### Getting the latest one for a given Response Path

Response Path results can be filtered by queue, answering extension, or unique ID and can be returned as plain text or XML.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=RESPONSEPATH&tenant=TENANTCODE&id=19&action=GETLAST
```

Sample output or template:

```
UniqueID|Type|Type ID|Value|Type Name|Value Name
srv02-1509806457.625|START|0|2017-11-04 15:41:01||
srv02-1509806457.625|CALLERID|0|Susan <1132555678>||
srv02-1509806457.625|VARIABLE|85|36985||
srv02-1509806457.625|VARIABLE|144|56896||
srv02-1509806457.625|QUEUE|281|||
srv02-1509806457.625|ANSWER|0|105-TENANTCODE||
srv02-1509806457.625|HANGUP|0|||
```

### Getting the latest one for a given Response Path for agent 104-TENANTCODE

Response Path results can be filtered by queue, answering extension, or unique ID and can be returned as plain text or XML.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=RESPONSEPATH&tenant=TENANTCODE&id=19&action=GETLAST&filter=ANSWER&filterdata=104-TENANTCODE
```

### Getting the latest one for a given Response Path for agent 104-TENANTCODE in xml format

Response Path results can be filtered by queue, answering extension, or unique ID and can be returned as plain text or XML.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=RESPONSEPATH&tenant=TENANTCODE&id=19&action=GETLAST&filter=ANSWER&filterdata=105-TENANTCODE&format=xml
```

Sample output or template:

```
<?xml version="1.0">
<Result>
<Agent>105-TENANTCODE</Agent>
<Status>NOT ACTIVE</Status>
<Queue>supportQ</Queue>
<ClientID>1234</MemberNumber>
<OrderNumber>11223344</MemberNumber>
<Caller>Manuel <7171345678></Caller>
<VoiceFile>3619</VoiceFile>
</Result>
```

## ManageDB / Custom Destination Types

Custom Destination Types.

### Getting the custom destination type list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CUSTOMTYPES&tenant=TENANTCODE&action=list
```

## ManageDB / Custom Destinations

Custom Destinations.

### Getting the custom destination list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CUSTOM&tenant=TENANTCODE&action=list
```

### Getting info for a custom destination

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CUSTOM&tenant=TENANTCODE&action=get&objectid=67
```

### Creating a custom destination

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=custom&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "cu_name": "Boss phone",
  "cu_ct_id": 1,
  "cu_param1": "3564732920",
  "cu_param2": "INCOMINGDID",
  "cu_param3": "30"
}
```

### Updating a custom destination

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=custom&tenant=TENANTCODE&objectid=286
```

Payload sent as `jsondata`:

```
{
  "cu_name": "Boss private phone",
  "cu_id": 286,
  "cu_param1": "0636287454"
}
```

## CDR / Get the userfield

Get the userfield.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=CDR&action=GET&field=userfield&uniqueid=srv02-1701011773.4670
```

## CDR / Update the userfield

Update the userfield.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=CDR&action=UPDATE&field=userfield&uniqueid=srv02-1701011773.4670&value=
```

## ManageDB / Tenants

Tenants.

### Getting the tenant list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=TENANT&action=list
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=TENANT&action=list&filter=te_disabled='on'
```

### Getting info for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=TENANT&action=get&objectid=1
```

### Creating a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=tenant
```

Payload sent as `jsondata`:

```
{
  "te_code": "RELAX",
  "te_name": "Relax & entertainment",
  "pk_start": 800,
  "pk_end": 810
}
```

### Updating a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=tenant&objectid=460
```

Payload sent as `jsondata`:

```
{
  "te_name": "Relax and entertainment",
  "pk_end": 820
}
```

## ManageDB / Phones

Phones.

### Getting the phones list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=PHONE&action=list&tenant=TENANTCODE
```

### Getting info for a phone

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=PHONE&action=get&objectid=182&tenant=TENANTCODE
```

### Creating a phone

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=phones&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "ph_name": "George Basement",
  "ph_mac": "AA:BB:CC:DD:EE:FF:00:11",
  "ph_pm_id": 5
}
```

### Updating a phone

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=phone&objectid=207&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "ph_name": "George Lower Basement"
}
```

## Manage DB / media files

media files.

ManageDB requests require an administrator API key. Most write operations send the record fields as a jsondata POST value.

### Getting the media file list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=MEDIAFILE&action=list&tenant=TENANTCODE
```

### Getting info for a media file

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=MEDIAFILE&action=get&objectid=1063&tenant=TENANTCODE
```

### Getting the binary part of a media file

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=MEDIAFILE&action=getbinary&objectid=1063&tenant=TENANTCODE
```

### Updating a media file

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=mediafile&objectid=10&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "me_name": "Beep"
}
```

### Updating the binary part of a media file

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=MEDIAFILE&action=updatebinary&objectid=247&tenant=TENANTCODE
```

## ManageDB / Hunt Lists

Hunt Lists.

### Getting the hunt lists list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=HUNTLIST&action=get&objectid=323&tenant=TENANTCODE
```

### Getting the hunt lists extension list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=HUNTLIST&action=getextensions&objectid=323&tenant=TENANTCODE
```

### Setting the hunt lists extension list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=setextensions&object=huntlist&objectid=26&tenant=TENANTCODE
```

## ManageDB / Extensions

Extensions.

### Getting the extension list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=list&object=extension&tenant=TENANTCODE
```

### Getting the details for an extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=get&object=extension&objectid=1701&tenant=TENANTCODE
```

### Deleting an extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=delete&object=extension&objectid=6016&tenant=TENANTCODE
```

### Updating the security for an extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=extension&objectid=1695&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "ex_callallowed": "all"
}
```

### Adding a SIP extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=extension&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "ex_number": "1100",
  "ex_name": "Test extension",
  "ex_tech": "SIP",
  "secret": "hackmeifyoucan",
  "ex_pickupgroup": "1,5,6",
  "ex_callgroup": "1,7,9"
}
```

### Adding a PJSIP extension

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=extension&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "ex_number": "1100",
  "ex_name": "Test PJSIP extension",
  "password": "hackmeifyoucan",
  "ex_tech": "PJSIP"
}
```

## ManageDB / Users

Users.

### Getting the user list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=user&action=list
```

### Getting the details for an user

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=user&action=get&objectid=3635
```

### Creating an user

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=user
```

Payload sent as `jsondata`:

```
{
  "us_username": "Leandro71",
  "us_password": "sha256(change-me)",
  "us_up_id": 1
}
```

## ManageDB / Conferences

Conferences.

### Creating a conference

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=conference&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
{
  "cr_number": "887",
  "cr_name": "Test conference",
  "pin": "5678"
}
```

## ManageDB / Providers

Providers.

### Getting the provider list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=provider&action=list
```

### Getting the details for a provider (SIP)

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=provider&action=get&objectid=1027
```

### Update a provider

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=provider&objectid=1027
```

Payload sent as `jsondata`:

```
{
  "pr_peername": "test_extradevel",
  "pr_name": "Test extradevel"
}
```

### Insert a provider

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=provider
```

Payload sent as `jsondata`:

```
{
  "pr_peername": "new_provider",
  "pr_name": "New Provider",
  "pr_tech": "SIP",
  "pr_userealtime": "on",
  "allow": "'alaw:20",
  "host": "172.16.1.100"
}
```

## ManageDB / Routing Profiles

Routing Profiles.

### Getting the routing profiles list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=routingprofile&action=list
```

### Getting the details for a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=routingprofile&action=get&objectid=99
```

### Getting the list of routes for a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=routingprofile&action=listroutes&objectid=99
```

### Adding a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=routingprofile
```

Payload sent as `jsondata`:

```
{
  "rp_name": "Only National",
  "rp_type": "VOICE"
}
```

### Update a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=routingprofile&objectid=275
```

## ManageDB / Routes

Routes.

### Getting the route list

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=route&action=list
```

### Getting the route list for a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=route&routingprofileid=1&action=list
```

### Getting the details for a route

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=route&action=get&objectid=69
```

### Adding a route to a routing profile

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&object=route
```

Payload sent as `jsondata`:

```
{
  "dl_rp_id": "1",
  "dl_name": "Free Numbers",
  "dl_regex": "^800.*",
  "dl_pr_id": "89"
}
```

### Update a route

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=route&objectid=69
```

Payload sent as `jsondata`:

```
{
  "dl_emergencyroute": "",
  "dl_usepin": "on"
}
```

## ManageDB / DIDs

DIDs.

### Listing the DIDs for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DID&action=LIST&tenant=TENANTCODE
```

### Getting more info for a DID

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DID&action=GET&objectid=27699&tenant=TENANTCODE
```

### Updating a DID

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=update&object=did&objectid=27699
```

Payload sent as `jsondata`:

```
{
  "di_comment": "Test DID",
  "di_recording": "yes"
}
```

## ManageDB / Destinations

Destinations.

### Getting the destinations for a DID

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=LIST&typesrc=DID&typeidsrc=27699&tenant=TENANTCODE
```

### Getting the destinations for a Condition (true)

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=LIST&typesrc=CONDITION&typeidsrc=20&tenant=TENANTCODE
```

### Getting the destinations for a Condition (false)

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=LIST&typesrc=NOTCONDITION&typeidsrc=20&tenant=TENANTCODE
```

### Replace the destinations for a DID

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=replace&typesrc=CONDITION&typeidsrc=20&tenant=TENANTCODE
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=replace&typesrc=NOTCONDITION&typeidsrc=20&tenant=TENANTCODE
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=replace&typesrc=IVR_1&typeidsrc=3634&tenant=TENANTCODE
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=DESTINATION&action=replace&typesrc=DID&typeidsrc=27699&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
[
  "PLAYBACK-60",
  "EXT-29379"
]
```

### Destination Tags

Destination replacement uses values in `TYPE-ID` form. The following tags are supported by the legacy destination examples and the current destination lookup code.

<table id="bkmrk-tagdestinationextdia"><thead><tr><th>Tag</th><th>Destination</th></tr></thead><tbody><tr><td>`EXT`</td><td>Dial an extension</td></tr><tr><td>`SMS`</td><td>Send a SMS to an extension</td></tr><tr><td>`PLAYBACK`</td><td>Play a media file</td></tr><tr><td>`RERECORD`</td><td>Rerecord a media file</td></tr><tr><td>`CLEARRECORDING`</td><td>Clear the media from a media file</td></tr><tr><td>`RERECORDSILENT`</td><td>Rerecord a media file without playing an intro</td></tr><tr><td>`CONDITION`</td><td>Follow to a condition</td></tr><tr><td>`VOICEMAIL`</td><td>Call a voicemail</td></tr><tr><td>`IVR`</td><td>Call an IVR</td></tr><tr><td>`DISA`</td><td>Call a DISA</td></tr><tr><td>`PAGING`</td><td>Call a Paging group</td></tr><tr><td>`HUNTLIST`</td><td>Call a Huntlist</td></tr><tr><td>`FLOW`</td><td>Call a Flow</td></tr><tr><td>`PARK`</td><td>Park the call</td></tr><tr><td>`SPECIAL`</td><td>Execute a special destination (check the sp\_specials table for the id)</td></tr><tr><td>`MEETME`</td><td>Join a conference</td></tr><tr><td>`QUEUE`</td><td>Dial a Queue</td></tr><tr><td>`RESETQUEUESTATS`</td><td>Reset the stats for a Queue</td></tr><tr><td>`STARTCAMPAIGN`</td><td>Start a campaign</td></tr><tr><td>`REDIALNOTANSWEREDCAMPAIGN`</td><td>Redial the calls not answered for a campaign</td></tr><tr><td>`STOPCAMPAIGN`</td><td>Stop a campaign</td></tr><tr><td>`PAUSECAMPAIGN`</td><td>Pause a campaign</td></tr><tr><td>`UNPAUSECAMPAIGN`</td><td>Unpause a campaign</td></tr><tr><td>`REMOVEFROMCAMPAIGN`</td><td>Remove called number from campaign</td></tr><tr><td>`REMOVECALLERFROMCAMPAIGN`</td><td>Remove caller number from campaign</td></tr><tr><td>`ADDLATESTDIALEDOUTTOCAMPAIGN`</td><td>Add latest dialed out number to campaign</td></tr><tr><td>`ADDLATESTDIALEDINTOCAMPAIGN`</td><td>Add latest dialed in number to campaign</td></tr><tr><td>`ADDTODNCLIST`</td><td>Add called number to Do Not Call list</td></tr><tr><td>`LOGINQUEUE`</td><td>Login caller to Queue</td></tr><tr><td>`TOGGLELOGINQUEUE`</td><td>Toggle Login/Logout caller to Queue</td></tr><tr><td>`LOGINADQUEUE`</td><td>Login caller to Queue</td></tr><tr><td>`TOGGLELOGINADQUEUE`</td><td>Toggle Login/Logout caller to Queue</td></tr><tr><td>`TOGGLEPAUSEQUEUE`</td><td>Toggle Pause/Unpause caller to Queue</td></tr><tr><td>`LOGOUTALLAGENTSFROMQUEUE`</td><td>Logout all agents from Queue</td></tr><tr><td>`LOGOUTQUEUE`</td><td>Logout caller from Queue</td></tr><tr><td>`PAUSEQUEUE`</td><td>Pause caller from Queue</td></tr><tr><td>`UNPAUSEQUEUE`</td><td>Unpause caller from Queue</td></tr><tr><td>`PAUSEALLAGENTSINQUEUE`</td><td>Pause all agents in Queue</td></tr><tr><td>`UNPAUSEALLAGENTSINQUEUE`</td><td>Unpause all agents in Queue</td></tr><tr><td>`CUSTOM`</td><td>Use a custom destination</td></tr><tr><td>`PHONEBOOK`</td><td>Route by Phone Book using regex</td></tr><tr><td>`EXACTPHONEBOOK`</td><td>Route by Phone Book not using regex</td></tr><tr><td>`SETUNCONDITIONALDID`</td><td>Set unconditional forwarding for a DID</td></tr><tr><td>`ENABLEUNCONDITIONALDID`</td><td>Enable the unconditional forwarding for a DID</td></tr><tr><td>`DISABLEUNCONDITIONALDID`</td><td>Disable the unconditional forwarding for a DID</td></tr><tr><td>`TOGGLEUNCONDITIONALDID`</td><td>Toggle the unconditional forwarding for a DID</td></tr><tr><td>`CLIDNAMEBYPHONEBOOK`</td><td>Set Caller ID Name by Phone Book</td></tr><tr><td>`CALLERIDMOD`</td><td>Alter Caller ID based on rule</td></tr><tr><td>`MUSICONHOLD`</td><td>Set Music On Hold to</td></tr><tr><td>`RINGMUSICONHOLD`</td><td>Ring extension using Music On Hold</td></tr><tr><td>`RESPONSEPATH`</td><td>Start Response Path</td></tr><tr><td>`SAMENUMBERVM`</td><td>Voicemail same number</td></tr></tbody></table>

## ManageDB / IVRs

IVRs.

### Listing the IVRs for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=IVR&action=LIST&tenant=TENANTCODE
```

### Getting more info for a IVR

The IVR media-file references are stored as destinations; use the destination examples to change them.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=IVR&action=GET&tenant=TENANTCODE&objectid=322
```

### Getting the destinations for the IVR, including the media files

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=IVR&action=GETDESTINATIONS&tenant=TENANTCODE&objectid=3634
```

## ManageDB / Conditions

Conditions.

### Listing the Conditions for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CONDITION&action=LIST&tenant=TENANTCODE
```

### Listing the destinations for a Condition

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CONDITION&action=GETDESTINATIONS&tenant=TENANTCODE&objectid=20&format=json
```

### Getting info and more info for a Condition

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CONDITION&action=GET&tenant=TENANTCODE&objectid=20&format=json
```

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CONDITION&action=GETEXTENDEDINFOS&tenant=TENANTCODE&objectid=20&format=json
```

### Replacing extended info for a Condition

Weektime and calendar conditions use extended-info rows; replace the extended-info list when changing their schedules.

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=CONDITION&action=replaceextendedinfos&objectid=20&tenant=TENANTCODE
```

Payload sent as `jsondata`:

```
[
  {
    "param1": "1",
    "param2": "8:00",
    "param3": "13:00"
  },
  {
    "param1": "1",
    "param2": "15:00",
    "param3": "19:00"
  },
  {
    "param1": "2",
    "param2": "8:00",
    "param3": "13:00"
  },
  {
    "param1": "2",
    "param2": "15:00",
    "param3": "19:00"
  }
]
```

## ManageDB / Voicemails

Voicemails.

### Listing the Voicemails for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=VOICEMAIL&action=LIST&tenant=TENANTCODE
```

### Listing the Voicemails message for a voicemail

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=VOICEMAIL&action=LISTMESSAGES&tenant=TENANTCODE&mailboxuser=001&mailbox=INBOX
```

### Get a message recording for a voicemail id

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=VOICEMAIL&action=GETMESSAGERECORDING&id=4963&tenant=TENANTCODE
```

### Add a voicemail box

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&tenant=TENANTCODE&object=voicemail
```

Payload sent as `jsondata`:

```
{
  "mailbox": "9000",
  "password": "1234567",
  "fullname": "This is a test",
  "email": "test@mirtapbx.com"
}
```

### Delete a voicemail box

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=VOICEMAIL&action=DELETE&objectid=32259&tenant=TENANTCODE
```

## ManageDB / Phone phonebooks

Phone phonebooks.

### Listing the Phone phonebooks for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=MANAGEDB&object=PHONEPHONEBOOK&action=LIST
```

### Get the detail of a phone phone book

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&tenant=TENANTCODE&reqtype=MANAGEDB&object=PHONEPHONEBOOK&action=GET&objectid=1332
```

## ManageDB / Queues

Queues.

### Listing the Queues for a tenant

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=QUEUE&action=LIST&tenant=TENANTCODE
```

### Add a Queue

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&action=add&tenant=TENANTCODE&object=queue
```

Payload sent as `jsondata`:

```
{
  "qu_name": "Support Line",
  "strategy": "RINGALL",
  "timeout": "30"
}
```

### Delete a queue

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=MANAGEDB&object=QUEUE&action=DELETE&objectid=7027&tenant=TENANTCODE
```

## Token Authentication

Use `reqtype=AUTHTOKEN` to generate a one-time or expiring login token for a user. The returned token can be used as the password in the normal web login URL.

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=AUTHTOKEN&action=generate&validity=ONCE&user=adrian
```

```
https://pbx.example.com/mirtapbx/login.php?username=adrian&password=AUTH_TOKEN
```

Request example:

```
https://pbx.example.com/mirtapbx/proxyapi.php?key=APIKEY&reqtype=AUTHTOKEN&action=generate&validity=ONCE&user=adrian
```

## Security Notes

- Use tenant read-only keys for reporting integrations whenever possible.
- Use administrator keys only for global reporting or `MANAGEDB` actions that require them.
- Do not store production keys in browser-side scripts.
- Prefer the OpenAPI endpoint for new integrations unless an existing integration requires the legacy ProxyAPI format.