Skip to main content

Queue Agent Actions

The Queue Agent Actions endpoints log an extension into or out of one queue, pause it with or without a reason, and unpause it. Each request changes only the selected extension's membership; 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. The agent is still selected by its internal extension ID (ex_id).

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.
agentIdYesThe extension's internal ID (ex_id), not its extension number.
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, 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.

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"

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.
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.
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.
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.