Graine AI
API referencePhone numbers

Re-point an inbound agent

Point an existing inbound agent at a different agent of yours.

Point an existing inbound agent at a different agent of yours.

This rewrites the application's call-handling endpoints so that incoming calls are answered by agent_id instead. It is the supported way to swap the agent behind a live phone number without re-provisioning the number, and it takes effect on the next inbound call.

Both ends are checked against your organisation before anything is written: an application_sid that is not yours answers 404, and so does an agent_id that is not yours. The webhook URLs themselves are derived server-side and are not accepted as input.

Rate limit: 1000 requests per minute per organization (bucket default). Exceeding it returns 429 with Retry-After; the X-RateLimit-* response headers report your remaining allowance on every call.

PUT
/v2/inbound-agents/{application_sid}/webhooks
/v2/inbound-agents/817361cd-2a13-4937-b465-686d3f58eddd/webhooks

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Your Graine API key. Create one in the dashboard under Developers, or via POST /v2/api-keys. Send it as Authorization: Bearer <key>.

In: header

Request Body

application/jsonRequired

agent_id
Required
Agent Id

The agent that should answer calls routed here. Must belong to your organisation.

Path Parameters

application_sid
Required
Application Sid

The inbound application to update, from GET /v2/inbound-agents.

Query Parameters

organization_idOrganization Id

Must match the organisation the API key belongs to.

Response Body

200

The application and the agent that now answers it.

application_sid
Required
Application Sid

The application that was updated.

agent_id
Required
Agent Id

The agent that now answers calls routed here.

updatedUpdated

Always true; a failure is reported as an error envelope.

Default: true

400

1000 — malformed or contradictory input (bad transfer target, bad timeout).

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

401

1100 — missing, unknown or inactive API key. 1101 — a browser session token was presented.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

402

1400 — the organisation has insufficient credits for this request.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

403

1102 — the key is valid but lacks the scope this endpoint requires, or names another organisation. GET /v2/scopes reports which scopes the key holds.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

404

1200 — no such resource in this organisation. Cross-tenant reads answer 404, never 403.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

422

1001 — the body or query failed validation; the message names the first offending field.

error
Required
integer

Stable integer code from the error table. Branch on this, not on the message.

message
Required
string

One human-readable sentence. Wording may change; the code will not.

429

1300 — per-organisation rate limit exceeded. Carries Retry-After.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

503

1501 — the telephony service is unreachable or returned a 5xx.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

504

1502 — the telephony service did not respond in time.

error
Required
Error

Stable integer code from the /v2 error table.

message
Required
Message

Human-readable single sentence.

curl -X PUT "https://api.graine.ai/v2/inbound-agents/817361cd-2a13-4937-b465-686d3f58eddd/webhooks?organization_id=string" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "85598652-87ce-4585-93e3-e03a42259796"
  }'

The application and the agent that now answers it.

{
  "application_sid": "817361cd-2a13-4937-b465-686d3f58eddd",
  "agent_id": "6c6f4cc3-f56c-479d-8422-7f76694daa29",
  "updated": true
}