Skip to main content

Queue Agent Actions

The Queue Agent Actions endpoints log an extension or external agent into or out of one queue or across tenant queues, pause it with or without a reason, and unpause it. Each request changes only the selected agent's memberships; it does not replace or rebuild the other queue members.

Endpoints

ActionEndpoint
LoginPOST /queues/{queueId}/agents/{agentId}/login
LogoutPOST /queues/{queueId}/agents/{agentId}/logout
PausePOST /queues/{queueId}/agents/{agentId}/pause
UnpausePOST /queues/{queueId}/agents/{agentId}/unpause

Use the Queue Number

Use these routes to select a queue by its dialable number (qu_number) within the tenant:

ActionEndpoint
LoginPOST /queues/by-number/{queueNumber}/agents/{agentId}/login
LogoutPOST /queues/by-number/{queueNumber}/agents/{agentId}/logout
PausePOST /queues/by-number/{queueNumber}/agents/{agentId}/pause
UnpausePOST /queues/by-number/{queueNumber}/agents/{agentId}/unpause

Queue numbers are strings: 00700 and 700 are different numbers. A number must contain 1 to 40 characters without spaces, control characters, or slashes. URL-encode reserved characters; for example, send *70# as %2A70%23. These routes always look up qu_number; they never interpret it as an internal queue ID. The existing ID routes remain available.

The exact tenant is required even with a global key. A missing queue number in that tenant returns HTTP 404 (queue_not_found). Multiple matching queues in the same tenant return HTTP 409 (queue_number_ambiguous); use the internal ID route to select one. Neither error changes queue membership. On the /agents routes, the agent is selected by its internal extension ID (ex_id). Use the /external-agents routes below for external agent IDs.

Authentication and Identifiers

These endpoints require a writable full tenant or global API key. Read-only keys are rejected. The tenant query parameter is required and must exactly match the tenant code or tenant name; wildcard tenant selection is not accepted.

ValueRequiredDescription
queueIdFor ID routesThe queue's internal ID (qu_id), not its dialable queue number.
queueNumberFor by-number routesThe dialable queue number (qu_number) in the selected tenant. Leading zeros are preserved.
agentIdFor extension routesThe extension's internal ID (ex_id), not its extension number.
externalAgentIdFor external-agent routesThe external agent's internal ID (ea_externalagents.ea_id). Select an existing external agent belonging to the tenant.
tenantYesExact tenant code or tenant name.
keyNo, if using headersThe API key can be sent with X-API-Key, Authorization: Bearer, or the key query parameter.

Request Body

Login accepts an optional JSON body with penalty for extensions and external agents. External-agent login also accepts the options described below. Logout and unpause do not need a request body. A pause request accepts an optional JSON body:

{
  "reason": "Lunch"
}

The reason can contain up to 80 characters. Omit the body, send an empty object, or use an empty reason to pause without a reason. pausereason is accepted as a compatibility alias for reason; if both names are supplied, their values must match. A pause reason cannot be sent to the other actions.

Login with a Penalty

All extension and external-agent login routes accept an optional penalty. Send a JSON integer from 0 to 2147483647. Omit it to use 0 for a new membership. Negative values, quoted numbers, booleans, null, fractions, and values above the limit return HTTP 400 (invalid_penalty).

The requested penalty applies only when adding the agent. Repeating login preserves an existing membership's penalty, pause state, and other options and returns changed=false. To change the penalty through these endpoints, log the agent out and log it in again with the desired value. A penalty field on pause, unpause, or logout returns HTTP 400 (penalty_not_allowed).

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"penalty":5}' \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/agents/101/login?tenant=DEVEL"

This example logs extension internal ID 101 into queue number 700 with penalty 5. For an external agent use /queues/by-number/700/external-agents/42/login, where 42 is its ea_id. The same JSON field is supported when selecting the queue by internal ID.

The response reports the applied or existing penalty in members[].penalty. Queue event logging, audit entries, and PBX refresh behavior remain the same.

Examples

Log In

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/25/agents/101/login?tenant=CANISTRACCI"

Log In by Queue Number

Log extension ID 101 into queue number 700 in tenant DEVEL. No request body is required:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/agents/101/login?tenant=DEVEL"

Replace the final login with logout, pause, or unpause for the other actions. To pause with a reason:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Lunch"}' \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/agents/101/pause?tenant=DEVEL"

The response returns both the resolved internal queue.id and dialable queue.number. Login and logout remain idempotent, and the response retains the existing changed, pbx_refresh, and warnings fields.

Pause Without a Reason

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/25/agents/101/pause?tenant=CANISTRACCI"

Pause With a Reason

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Lunch"}' \
  "https://pbx.example.com/pbx/openapi.php/queues/25/agents/101/pause?tenant=CANISTRACCI"

Unpause and Log Out

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/25/agents/101/unpause?tenant=CANISTRACCI"

curl -X POST \
  -H "X-API-Key: TENANT_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/25/agents/101/logout?tenant=CANISTRACCI"

External Agents

These routes act on an existing external agent from ea_externalagents. Use its internal ea_id as externalAgentId. The configured ea_number supplies the destination number; requests cannot override that number. External agent IDs and extension IDs are separate identifiers. The routes select only the matching external agent, including when another agent shares its telephone number or an extension has the same numeric ID.

ActionQueue by internal IDQueue by dialable number
LoginPOST /queues/{queueId}/external-agents/{externalAgentId}/loginPOST /queues/by-number/{queueNumber}/external-agents/{externalAgentId}/login
LogoutPOST /queues/{queueId}/external-agents/{externalAgentId}/logoutPOST /queues/by-number/{queueNumber}/external-agents/{externalAgentId}/logout
PausePOST /queues/{queueId}/external-agents/{externalAgentId}/pausePOST /queues/by-number/{queueNumber}/external-agents/{externalAgentId}/pause
UnpausePOST /queues/{queueId}/external-agents/{externalAgentId}/unpausePOST /queues/by-number/{queueNumber}/external-agents/{externalAgentId}/unpause

A writable full tenant or global API key and an exact tenant code or name are required. Both the queue and the external agent must belong to that tenant. Read-only and dial-only keys cannot perform these actions. The queue number route preserves leading zeros and uses the same missing/ambiguous queue rules as the extension routes.

Login Options

Login accepts optional penalty, confirm, and monitor_state. With no body it uses penalty=0, confirm=false, and monitor_state=true. Send an integer for penalty and actual JSON booleans for the other options, not quoted strings.

OptionDefaultBehavior
penalty0JSON integer from 0 to 2147483647 for a new membership. An existing membership retains its penalty on repeated login.
confirmfalseSet to true to require the external agent to confirm answering a queue call.
monitor_statetrueMonitor the configured external number using its Custom device state. Set to false for the queue page's no-state-monitoring mode. The queue's Ring Offline setting disables the state interface even when this option is true.

Options apply when creating a membership. Repeating login preserves an existing membership's mode, pause state, and penalty, and returns changed=false. Log out and log in again to change penalty, confirmation, or monitoring. New memberships use the queue's Agent Identification and Allow Call Optimization settings, start unpaused, and use the requested penalty (default 0).

New logins honor the tenant's EXTERNALAGENTS setting, matching the queue page: an unset/empty value or EA allows external agents; another selection such as CU returns HTTP 409 (external_agents_disabled). Existing memberships can still be paused, unpaused, or logged out after the setting changes.

Log In an External Agent

Log external agent ID 42 into queue number 700 in tenant DEVEL, with penalty 5, confirmation enabled, and state monitoring disabled:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"penalty":5,"confirm":true,"monitor_state":false}' \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/external-agents/42/login?tenant=DEVEL"

For default login behavior, omit the body and its Content-Type header. To select queue internal ID 25 instead, use /queues/25/external-agents/42/login.

Pause, Unpause, and Log Out

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Lunch"}' \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/external-agents/42/pause?tenant=DEVEL"

curl -X POST -H "X-API-Key: YOUR_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/external-agents/42/unpause?tenant=DEVEL"

curl -X POST -H "X-API-Key: YOUR_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/by-number/700/external-agents/42/logout?tenant=DEVEL"

Pause accepts an optional reason (or pausereason) of up to 80 characters. Omit the body to pause without a reason. Unpause clears the reason. Pause and unpause return HTTP 409 (agent_not_logged_in) when the external agent has no membership in the selected queue. Login options are accepted only by login; unsupported fields return HTTP 400 (invalid_external_agent_option).

Response

The response uses the same queue_agent_action object and includes changed, the resolved queue.id and queue.number, members, pbx_refresh, and warnings. Its agent object identifies the external agent:

"agent": {
  "type": "external",
  "id": 42,
  "number": "+14155550100",
  "name": "External Agent",
  "peer": "+14155550100"
}

Changed actions write the corresponding queue event and activity audit entry and request a live PBX queue refresh. Login and logout are idempotent; repeated requests still request a refresh. A failed refresh returns the saved database state with pbx_refresh=failed and a warning, so the request can be retried.

All-Queues Actions

Use all in place of a queue ID to apply an action for one agent across queues in one tenant. A full writable key and an exact tenant code or name are required. Use the extension's ex_id on the /agents routes or the external agent's ea_id on /external-agents. The queue number route /queues/by-number/all/... continues to look up a queue whose number is literally all; it is not a bulk route.

ActionExtensionExternal agent
LoginPOST /queues/all/agents/{agentId}/loginPOST /queues/all/external-agents/{externalAgentId}/login
LogoutPOST /queues/all/agents/{agentId}/logoutPOST /queues/all/external-agents/{externalAgentId}/logout
PausePOST /queues/all/agents/{agentId}/pausePOST /queues/all/external-agents/{externalAgentId}/pause
UnpausePOST /queues/all/agents/{agentId}/unpausePOST /queues/all/external-agents/{externalAgentId}/unpause

Which Queues Are Affected?

  • Login targets every queue in the selected tenant. The allowed-agent list does not limit this route. It adds only missing memberships, using each queue's naming, call-optimization, and Ring Offline settings. Existing memberships retain their penalty, pause state, and mode.
  • Logout removes the selected agent from every queue in this tenant where it is currently logged in.
  • Pause and unpause change only the agent's existing memberships in this tenant. They do not add memberships.
  • Other tenants, other agents, allowed-agent lists, and extension/external-agent records are unaffected. External agent matching uses its object type and ID, independently of agents sharing a phone number or an extension with the same ID.
  • No matching queues returns HTTP 200 with success=true, zero totals, and an empty results array. Login also returns this empty result when the tenant has no queues. The agent must still exist in the selected tenant.

Request Options

Login accepts the same optional body as the single-queue route: penalty is an integer from 0 to 2147483647, default 0. External-agent login also accepts JSON booleans confirm (default false) and monitor_state (default true). These values apply to new memberships only. External-agent login honors the tenant's EXTERNALAGENTS setting for each new membership.

Pause accepts an optional reason or pausereason of up to 80 characters and applies it to every matched membership. Omit the body to pause without a reason. Unpause clears the reason. Logout and unpause require no body. Supplying penalty to an action other than login returns HTTP 400 (penalty_not_allowed).

Authentication, exact tenant, agent identity, and request options are checked before queue changes begin. Invalid requests return the usual HTTP error response. The queue list is then collected and processed in internal ID order, including queues hosted on different PBX nodes.

Examples

Log extension ID 101 into every queue in tenant DEVEL with penalty 5:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"penalty":5}' \
  "https://pbx.example.com/pbx/openapi.php/queues/all/agents/101/login?tenant=DEVEL"

Log external agent ID 42 into every queue with confirmation enabled, state monitoring disabled, and penalty 5:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"penalty":5,"confirm":true,"monitor_state":false}' \
  "https://pbx.example.com/pbx/openapi.php/queues/all/external-agents/42/login?tenant=DEVEL"

Pause the extension in all its current tenant queue memberships, then unpause or log out:

curl -X POST \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Lunch"}' \
  "https://pbx.example.com/pbx/openapi.php/queues/all/agents/101/pause?tenant=DEVEL"

curl -X POST -H "X-API-Key: YOUR_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/all/agents/101/unpause?tenant=DEVEL"

curl -X POST -H "X-API-Key: YOUR_API_KEY" \
  "https://pbx.example.com/pbx/openapi.php/queues/all/agents/101/logout?tenant=DEVEL"

For the same pause, unpause, or logout actions on an external agent, use /queues/all/external-agents/42/ followed by the action.

Bulk Response and Partial Failures

A valid bulk request returns HTTP 200 with a queue_agent_bulk_action response even when individual queue actions fail. Inspect success, summary, and every entry in results. Each queue is handled independently: a failure is reported for that queue and processing continues. Successful actions are not rolled back. If a membership is removed concurrently, pause/unpause can report agent_not_logged_in for that queue.

FieldMeaning
successTrue when there are no per-queue action failures. PBX refresh failures are reported separately.
changedTrue when at least one successful queue action changed membership or pause state.
summary.totalNumber of queues selected at the start of the operation.
summary.changedNumber of successful queue actions that changed state.
summary.unchangedNumber of successful queue actions whose requested state was already in effect.
summary.failedNumber of failed queue actions. Their results include error.status, error.code, and error.message.
summary.pbx_refresh_failedSuccessful database actions whose live PBX refresh could not be confirmed. Their results retain the saved state, pbx_refresh=failed, and warnings.

Each successful queue result contains the ordinary queue_agent_action response plus success=true. Each failed result contains success=false, the queue ID/number/name, and an error. Results are ordered by internal queue ID. Changed states write the usual per-queue event and audit entry, and successful actions request a refresh on the queue's hosting node. Retrying the same request is idempotent; memberships and saved states may already have changed before a later error occurs.

Example partial result for a pause request:

{
  "object": "queue_agent_bulk_action",
  "action": "pause",
  "agent": {
    "id": 101,
    "number": "103",
    "name": "Reception",
    "peer": "101"
  },
  "success": false,
  "changed": true,
  "summary": {
    "total": 2,
    "changed": 1,
    "unchanged": 0,
    "failed": 1,
    "pbx_refresh_failed": 0
  },
  "results": [
    {
      "object": "queue_agent_action",
      "action": "pause",
      "status": "paused",
      "changed": true,
      "queue": {
        "id": 25,
        "number": "700",
        "name": "Support"
      },
      "agent": {
        "id": 101,
        "number": "103",
        "name": "Reception",
        "peer": "101"
      },
      "members": [
        {
          "membername": "103",
          "interface": "Local/AG-000-NF-101@fromotherpbx/n",
          "state_interface": "Custom:101",
          "member_device": "101",
          "penalty": 5,
          "paused": true,
          "pause_reason": "Lunch"
        }
      ],
      "pbx_refresh": "confirmed",
      "warnings": [],
      "success": true
    },
    {
      "success": false,
      "queue": {
        "id": 27,
        "number": "701",
        "name": "Sales"
      },
      "error": {
        "status": 409,
        "code": "agent_not_logged_in",
        "message": "The agent is not logged into this queue."
      }
    }
  ],
  "warnings": [
    "Some queue actions failed. Inspect results before retrying."
  ]
}

Response

{
  "object": "queue_agent_action",
  "action": "pause",
  "status": "paused",
  "changed": true,
  "queue": {
    "id": 25,
    "number": "700",
    "name": "Support"
  },
  "agent": {
    "id": 101,
    "number": "100",
    "name": "Reception",
    "peer": "101"
  },
  "members": [
    {
      "membername": "100",
      "interface": "Local/AG-000-NF-101@fromotherpbx/n",
      "state_interface": "Custom:101",
      "member_device": "101",
      "penalty": 0,
      "paused": true,
      "pause_reason": "Lunch"
    }
  ],
  "pbx_refresh": "confirmed",
  "warnings": []
}

changed is false when the requested state was already active. Login and logout are idempotent. Pause and unpause are also idempotent after the agent is logged in; attempting either operation for an extension that is not a member of the queue returns HTTP 409.

pbx_refresh reports whether the live Asterisk refresh was confirmed. If the database action succeeds but the refresh cannot be confirmed, the request still returns the saved state with pbx_refresh set to failed and an explanation in warnings. Retrying the same action is safe and requests another refresh.

Behavior

  • Login uses the queue's Agent Identification, Allow Call Optimization, and Ring Offline settings when constructing the member.
  • A changed state writes the matching LOGIN, LOGOUT, PAUSE, or UNPAUSE queue log event and an activity audit entry.
  • Unpause clears the stored pause reason.
  • The final database state is checked before a successful response is returned.

Relevant Errors

HTTP statusCodeDescription
400exact_tenant_requiredThe tenant was omitted, does not exactly match the authenticated tenant, or uses a wildcard.
400invalid_pause_reasonThe pause reason is invalid or longer than 80 characters.
400conflicting_pause_reasonreason and pausereason contain different values.
400pause_reason_not_allowedA reason was sent to login, logout, or unpause.
400invalid_queue_numberThe by-number value is invalid or exceeds 40 characters.
400invalid_penaltyPenalty is not a JSON integer from 0 to 2147483647.
400penalty_not_allowedPenalty was supplied to an action other than login.
400invalid_external_agent_optionAn external-agent request contains an unsupported field or a login option is not a JSON boolean.
404external_agent_not_foundThe external agent does not exist in the selected tenant.
404queue_not_foundThe queue does not exist in the selected tenant.
409queue_number_ambiguousMore than one queue in the selected tenant has this number. Use the internal ID route.
409external_agents_disabledThe tenant EXTERNALAGENTS setting does not allow a new external-agent membership.
409agent_not_logged_inPause or unpause was requested before the extension was logged into the queue.
409agent_peer_unavailableThe extension does not have a valid queue member device, or the external agent has no valid configured destination number.
409queue_agent_state_changedA concurrent change prevented the requested final state from being confirmed; retry the request.
500queue_agent_update_failedThe membership database operation failed.