Skip to Content
Outbound calls

Schedule an outbound job

Permissioncalls:place-outboundRetriesIdempotency-Key requiredAuthentication
POST
/outbound-jobs

Resolves and snapshots contact hours, retry policy, deployed agent version, destination, and caller-ID route in one transaction. Exactly one of number_pool_id or phone_number_id is required; exactly one of contact_id or to_number is sufficient. Use Idempotency-Key for safe retries. On acceptance, wait for Retry-After and poll Location until the status is terminal.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Use a Voice API key or connected-app OAuth access token. Authentication.

Header Parameters

Idempotency-Key*string

Required. Reuse the same key to retry this write safely. Retries and idempotency.

Match^[A-Za-z0-9!#$%&'*+.^_`|~-]+$
Length1 <= length <= 255

Request Body

application/json
  1. body

Maximum encoded body size is 262144 bytes. max_attempts is a compatibility shorthand for policy_overrides.max_attempts; supplying both with different values is rejected.

agent_id*string
Formatuuid
agent_version?string

Which of the agent's versions the call runs. production (the default) dials the deployed version; staging dials the version last promoted to staging so a change can be heard on a real call before it is deployed, and fails 409 no_staging_version when the agent has none. The resolved version id is stored on the job, so a later promote or deploy does not change what it dials. staging is only accepted with agent_id.

Default"production"
Value in"production""staging"
flow_id?string

Schedule the job against a flow instead of a single agent. The flow's start agent is resolved at create time and stored as the job's agent_id, with flow_id kept alongside as the annotation the dialer forwards at placement. Exactly one of agent_id and flow_id is required. Requires the flows entitlement, and the flow must be dispatchable now or the create fails 422 on flow_id.

Formatuuid
group_id?string

Schedule the job against a group of agents. One member is picked at create time for the destination number (the contact's stored number when contact_id is given) using the group's routing strategy. It is stored as the job's agent_id, with group_id and group_member_id alongside; placement and every retry dial that member, always on its production version (agent_version staging is rejected with 422 unsupported_with_group). Exactly one of agent_id, flow_id and group_id is required (422 exactly_one_required on group_id). Requires the groups entitlement, and the group must have a member that can take calls now or the create fails 422 on group_id (not_found, archived, no_members).

Formatuuid
contact_id*string
Formatuuid
to_number?OutboundE164

A dial target: an E.164 number, a bare internal number/extension of 1 to 20 [0-9*#] characters (e.g. 103, 2770124), or a sip:/sips: URI (e.g. sip:103@pbx.example.com).

Match^(\+[1-9][0-9]{7,14}|[0-9*#]{1,20}|sips?:[^@\s]+@[A-Za-z0-9._-]+(:[0-9]{1,5})?(;\S*)?)$
number_pool_id*string
Formatuuid
phone_number_id?string
Formatuuid
trunk_id?string

Optional route constraint. A forced phone number must belong to this trunk; a pool must have an eligible member on it.

Formatuuid
transport?OutboundTransport
Value in"livekit_sip""twilio_media_streams"
scheduled_at?string

Requested schedule instant. Past values are accepted and evaluated from the current instant for contact hours.

Formatdate-time
contact_timezone?string

Legacy per-call IANA timezone override. Prefer policy_overrides for new clients.

expires_at?string

Explicit expiry must be after scheduled_at and the next permitted contact-hours instant, and no more than 90 days after scheduled_at. When omitted, the policy TTL is added to the current evaluation instant for a past schedule, or to scheduled_at for a future schedule.

Formatdate-time
max_attempts?integer
Range1 <= value <= 10
policy_overrides?

Per-job overrides. The organization policy may disable all overrides, and overridden windows must fit inside organization guardrails. timezone is accepted only with timezone_mode=custom; custom mode requires it.

priority?integer

Higher values are claimed first among otherwise-due jobs.

Range-100 <= value <= 100
Default0
variables?
Propertiesproperties <= 50
metadata?
dncr?

Response Body

Outbound job durably accepted. Poll the Location resource for state changes.

application/json
  1. response
id*string
Formatuuid
status*OutboundJobStatus
Value in"scheduled""queued""claimed""reserving""dialing""ringing""active""retry_wait""completed""failed""canceled""expired""provider_unknown"
scheduled_at*string
Formatdate-time
not_before*string

Earliest instant after applying contact hours. Capacity may delay execution further.

Formatdate-time
expires_at*string
Formatdate-time
contact_timezone*string
policy_context*

Immutable contact-hours decision stored on a job at creation time.

retry_policy*

Immutable retry decision stored on a job at creation time. Capacity waits never consume a call attempt. A carrier or route failure (a SIP 5xx, or a call that could not be placed on the route) first gets a few retries that do not consume an attempt, with growing waits; we redial at once only when another trunk that has not yet failed this job is available. After that, each route failure consumes an attempt, so the job ends at max_attempts. A carrier's Retry-After is honored as the minimum wait, up to one hour.

max_attempts*integer
Range1 <= value <= 10
dncr?|
Example Request
curl -X POST 'https://api.kejue.co/v1/outbound-jobs' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "status": "scheduled",  "scheduled_at": "2019-08-24T14:15:22Z",  "not_before": "2019-08-24T14:15:22Z",  "expires_at": "2019-08-24T14:15:22Z",  "contact_timezone": "string",  "policy_context": {    "schema_version": 1,    "source": "organization",    "org_policy_version": 0,    "timezone": "string",    "windows": [      {        "weekdays": [          1        ],        "start": "09:00",        "end": "17:00"      }    ]  },  "retry_policy": {    "version": 1,    "source": "organization",    "org_policy_version": 0,    "destination_busy_backoff_seconds": [      1    ],    "destination_unavailable_backoff_seconds": [      1    ],    "destination_declined_backoff_seconds": [      1    ],    "retry_declined": true,    "capacity_retry": {      "minimum_seconds": 1,      "maximum_seconds": 1,      "jitter": true    },    "ambiguous_provider_result": "reconcile_before_retry"  },  "max_attempts": 1,  "dncr": {    "schema_version": 1,    "requested": {      "mode": "inherit",      "connection_id": "d3547de1-d1f2-4344-b4c2-17169b7526f9"    },    "enabled": true,    "enforced": true,    "connection_id": "d3547de1-d1f2-4344-b4c2-17169b7526f9",    "policy_version": 0,    "source": "organization"  }}