Skip to content

Queue & Fanout

Use POST /v1/calls/batch to queue up to 500 outbound PSTN recipients in one request. The endpoint creates a single call session and enqueues one PSTN participant per recipient.

You can also use the primary Calls API directly by sending multiple pstn participants to POST /v1/calls.

Queue Batch

http
POST /v1/calls/batch

Request Body

FieldTypeRequiredDefaultDescription
agent_iduuidYesAgent persona to dial with
tostring[]Yes (unless recipients)Recipient phone numbers in E.164 format (e.g., ["+15559990001", "+15559990002"])
recipientsRecipient[]Yes (unless to)Recipient objects with per-recipient overrides
from_numberstringNoTenant defaultShared caller ID in E.164 format. If omitted, Rymi resolves your default number
batch_idstringNoAuto-generatedCaller-supplied batch identifier for tracking
metadataobjectNo{}Metadata stored on the call record
variablesobjectNo{}Shared variables passed into queued telephony jobs
post_callPost-call objectNoAgent defaultPer-batch post-call intelligence override

Recipient Object

Use recipients instead of to when you need per-recipient caller ID or metadata.

FieldTypeRequiredDefaultDescription
to or identitystringYesRecipient phone number in E.164 format
from_numberstringNoBatch-level from_numberPer-recipient caller ID override
metadataobjectNo{}Per-recipient metadata

Example — Simple Batch

bash
curl -X POST https://api.rymi.live/v1/calls/batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "to": ["+15559990001", "+15559990002"],
    "from_number": "+15559990000",
    "metadata": { "batch_label": "promo-q1" },
    "variables": { "campaign": "spring-offer" }
  }'

Example — Per-Recipient Metadata

bash
curl -X POST https://api.rymi.live/v1/calls/batch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "recipients": [
      {
        "to": "+15559990001",
        "from_number": "+15559990000",
        "metadata": { "name": "Alice", "plan": "Gold" }
      },
      {
        "to": "+15559990002",
        "metadata": { "name": "Bob", "plan": "Silver" }
      }
    ],
    "from_number": "+15559990000",
    "batch_id": "promo-q1-2026",
    "variables": { "campaign": "spring-offer" }
  }'

Response 202

json
{
  "id": "call_abc123",
  "room_name": "call_call_abc123",
  "status": "queued",
  "batch_id": "promo-q1-2026",
  "queued": 2,
  "participants": [
    {
      "id": "participant_1",
      "transport": "pstn",
      "identity": "+15559990001",
      "status": "queued",
      "telephony_leg_id": "leg_1",
      "job_id": "job_1"
    },
    {
      "id": "participant_2",
      "transport": "pstn",
      "identity": "+15559990002",
      "status": "queued",
      "telephony_leg_id": "leg_2",
      "job_id": "job_2"
    }
  ]
}

Errors

StatusMeaning
400Validation error (missing agent_id, empty to/recipients, exceeds 500 limit, invalid E.164 numbers)
401Missing or invalid API key
402Insufficient credits
403Publishable keys cannot use batch API
404Agent not found for this tenant
409One or more recipients are on the DNC list (rejected before queueing)

Direct Participant Fanout

If you need mixed WebRTC/PSTN rooms or participant-specific metadata, send multiple participants directly to POST /v1/calls:

json
{
  "agent_id": "550e8400-e29b-41d4-a716-446655440000",
  "participants": [
    {
      "transport": "pstn",
      "identity": "+15559990001",
      "from_number": "+15559990000",
      "metadata": { "name": "Alice", "plan": "Gold" }
    },
    {
      "transport": "pstn",
      "identity": "+15559990002",
      "from_number": "+15559990000",
      "metadata": { "name": "Bob", "plan": "Silver" }
    }
  ],
  "variables": { "campaign": "spring-offer" }
}

Queue Stats

Check the health and current status of your queued batch calling worker.

http
GET /v1/calls/queue/stats

Response 200

json
{
  "waiting": 150,
  "active": 10,
  "completed": 45,
  "failed": 2
}
FieldTypeDescription
waitingintegerJobs waiting to be processed
activeintegerJobs currently being processed
completedintegerSuccessfully completed jobs
failedintegerJobs that failed

Queue Status Flow

Each queued PSTN participant progresses independently:

text
queued → dialing → in_progress → completed
                                → failed

DNC Filtering

Contacts on your DNC registry are rejected during request validation and are never queued. See Compliance.