Agents
Update an agent
PATCH
/agents/{agent_id}
x-api-key
Updates agent fields and syncs to Google via PATCH. While the agent is not yet persisted to Google (`google_agent_id: null`), `brand`, `use_case` and `billing_category` are accepted and consumed by the deferred Google create (`use_case`/`billing_category` still enum-validated → 400); no Google PATCH call happens for an unpersisted row. Once persisted, `brand` mutation is rejected with 422 (immutable) and `use_case`/`billing_category` answer 422 create-only. After the Google patch, the relay reconciles the agent's webhook on the brands.agents.integrations sub-resource (best-effort — never fails the PATCH). Questionnaire fields (the launch descriptions, the agent access instructions, `spv_video_url` and the `spv_*` compliance set) are stored locally on the agent row only; the agent resource carries no questionnaire fields, so a questionnaire-only PATCH performs no Google write at all — the relay never fires `requestLaunch` (the operator console sends the questionnaire to Google at launch time). When the PATCH touches the brand-contact trio and the merged row completes it, the verification contact is persisted via `requestVerification` right after the patch — early persistence that does NOT trigger the Google review until the agent launches. Secured by an x-api-key.
Parameters
| Name | In | Type | Required | Description |
x-api-key |
header |
string |
yes |
The relay API key (x-api-key header). |
agent_id |
path |
string |
yes |
The rcs-relay agent identifier (ULID). |
Request body
| Field | Type | Required | Description |
name |
string |
no |
Optional. Agent display name; when supplied it is persisted to the local agent row and sent to Google as `displayName` (leading the writable-only `updateMask`). Omit it to leave the name untouched.
|
brand |
string |
no |
Conditionally accepted: PATCHable while the agent is not yet persisted to Google (consumed by the deferred create), but 422-immutable once persisted — any PATCH that includes `brand` on a persisted agent is rejected with 422 before any Google call.
|
use_case |
string |
no |
PATCHable only while the agent is not yet persisted to Google — the value is consumed by the deferred Google create. Once persisted it is create-only: a PATCH carrying it is rejected with 422. Enum-validated when supplied (closed value set — a bad value earns a 400).
|
billing_category |
string |
no |
PATCHable only while the agent is not yet persisted to Google — the value is consumed by the deferred Google create. Once persisted it is create-only: a PATCH carrying it is rejected with 422. Enum-validated when supplied (closed value set — a bad value earns a 400).
|
additional_info |
object |
no |
Agent branding + launch data. Every sub-key is merged into the existing row; the six branding keys below are also forwarded to Google under their rcsBusinessMessagingAgent path, the rest are stored locally and read by the validation engine. Each sub-key's description states whether it is mandatory or optional for validation and launch. None is mandatory to send in a PATCH (partial update); a malformed value earns a 400.
|
google_required |
object |
no |
Google review fields required for validation. Every sub-key below is MANDATORY for validation — AgentValidation#check_google_required rejects the draft → validation transition unless all eight are present (plus an email-format check on brand_contact_email and a URL-format check on brand_website_url). They are writable via PATCH: a supplied sub-map is merged into the existing row (partial overlay preserves untouched keys), so a tenant can fill them in before launch. They feed the Google requestVerification contact and the launch questionnaire; the questionnaire keys are stored locally on the agent row — never on the agent resource, and the relay never fires `requestLaunch` (the operator console sends the questionnaire to Google at launch time).
|
Responses
| Status | Description |
200 |
Agent updated; the body reports the persist state.
|
401 |
Missing or invalid API key. |
404 |
Agent not found. |
400 |
Missing or invalid request body field — invalid JSON, a wrong-typed or malformed value, or an invalid `use_case`/`billing_category` enum value while the agent is not yet persisted to Google.
|
422 |
Brand mutation rejected once the agent is persisted to Google (immutable), `use_case`/`billing_category` rejected with 422 create-only once persisted, a PATCH leaving a touched contact pair half-filled after the row merge (`errors` names the still-blank side), or the deferred persist-step Google rejection (decoded per-field `errors`; the local updates are already persisted, the row stays unpersisted and the next PATCH retries the create), or a Google rejection of the persisted-row patch/mirror that names refused fields — those surface as `rejected_update_mask` (patch) or `rejected_fields` (verification contact) plus the persisted row identity (`agent_id`, `google_agent_id`, `persist_state: "persisted"`). Recovery is surgical: a later PATCH re-sends a refused field only when it touches it (or the brand-contact trio for `rejected_fields`); POST /agents/{agent_id}/validate re-mirrors the whole row.
|
502 |
Google Business Communications error — two postures. At the persist moment the row is kept stored and unpersisted (no identity keys). After a clean persist, a failure of the verification-contact leg answers the same 502 with the row persisted: the body merges the identity triple (`agent_id`, `google_agent_id`, `persist_state: "persisted"`). The persisted-row patch and its verification leg keep a plain 502-only body (no identity keys).
|