Docs API

Recipes

Complete scripts for common tasks. Set RELAYDOCK_API_KEY, copy a script and run it. The curl versions need bash, jq and curl 7.76 or later, and stop at the first error.

Change an endpoint's agent

Send only the field you change. The response is the endpoint with provision_statepending while RelayDock updates the dispatch rule in LiveKit; once it is ready again, new calls go to the new agent.

curl -X PATCH "https://api.relaydock.io/api/v1/endpoints/3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a6c13" \
  -H "Authorization: Bearer $RELAYDOCK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_name": "support-agent"
  }'

The same request changes mode, outbound_numbers or enabled. See Update an endpoint for every field and how null resets a value.

Create an endpoint and wait until it is ready

Creating an endpoint returns right away with provision_state pending, or waiting_target if no LiveKit project is connected. This script creates a registration endpoint and reads it every 3 seconds until LiveKit setup has a result and, for a registration, the first registration attempt has one too.

set -euo pipefail
API=https://api.relaydock.io/api/v1
AUTH="Authorization: Bearer $RELAYDOCK_API_KEY"

ID=$(curl -sS --fail-with-body -X POST "$API/endpoints" -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"kind":"registration","provider":"telnyx","agent_name":"my-agent","registration":{"transport":"tcp","username":"SIP_USERNAME","password":"SIP_PASSWORD","number":"+12025550123"}}' | jq -r .id)

for attempt in $(seq 40); do
  ENDPOINT=$(curl -sS --fail-with-body "$API/endpoints/$ID" -H "$AUTH")
  echo "$ENDPOINT" | jq -c '{provision_state, provision_error, registration: .registration.state}'
  # Done when LiveKit setup is no longer pending and a registration has a result.
  if echo "$ENDPOINT" | jq -e '.provision_state != "pending"
      and ((.registration.state // "done") | . != "unknown" and . != "registering")' > /dev/null; then
    break
  fi
  sleep 3
done

A healthy endpoint ends with ready and registered. If not, diagnosis.key names the problem: see Troubleshooting.

Export calls as CSV

Export up to 31 days at a time; without from and to you get the last 30 days. A team can export 10 times an hour.

curl "https://api.relaydock.io/api/v1/calls/export?from=2026-11-01T00%3A00%3A00Z&to=2026-11-16T00%3A00%3A00Z" \
  -H "Authorization: Bearer $RELAYDOCK_API_KEY" \
  -o calls.csv

The file has one row per call, ordered by time, with the columns described in Export calls.

Run a test call and wait for the result

Starts an outbound test call through an endpoint and reads it every 2 seconds until it is completed or failed, then prints each step.

set -euo pipefail
API=https://api.relaydock.io/api/v1
AUTH="Authorization: Bearer $RELAYDOCK_API_KEY"
ENDPOINT_ID=3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a6c13

TEST_ID=$(curl -sS --fail-with-body -X POST "$API/endpoints/$ENDPOINT_ID/test-calls" -H "$AUTH" \
  -H "Content-Type: application/json" -d '{"to": "+12025550147"}' | jq -r .id)

for attempt in $(seq 100); do
  CALL=$(curl -sS --fail-with-body "$API/test-calls/$TEST_ID" -H "$AUTH")
  STATE=$(echo "$CALL" | jq -r .state)
  if [ "$STATE" = completed ] || [ "$STATE" = failed ]; then
    break
  fi
  sleep 2
done
echo "$CALL" | jq -r '.steps[] | [.key, .status, (.code // ""), (.detail // "")] | @tsv'
echo "$CALL" | jq -c '{state, result_code, error}'

What each step means is in Test calls.

Read every call in a time range

The call list returns up to 200 calls per page, newest first. Pass next_cursor back as cursor until it is null.

set -euo pipefail
API=https://api.relaydock.io/api/v1
AUTH="Authorization: Bearer $RELAYDOCK_API_KEY"
URL="$API/calls?since=2026-11-01T00:00:00Z&limit=200"

CURSOR=""
while : ; do
  PAGE=$(curl -sS --fail-with-body "$URL${CURSOR:+&cursor=$CURSOR}" -H "$AUTH")
  echo "$PAGE" | jq -c '.items[] | {invited_at, direction, caller, callee, duration_s, sip_code, reason}'
  CURSOR=$(echo "$PAGE" | jq -r '.next_cursor // empty')
  [ -n "$CURSOR" ] || break
done