Agents
Run the pre-launch validation rules engine
POST
/agents/{agent_id}/validate
x-api-key
Runs `RcsRelay::AgentValidation` against the agent's `google_required` + kept `additional_info` fields. A pre-persist guard runs FIRST: an agent row with no `google_agent_id` yet returns 422 `{"error": "agent not persisted to Google"}` before the launch-rules check and before the draft → validation transition. On pass, flips status `draft → validation` locally, stamps `validation_requested_at` and mirrors the whole persisted row to Google: a `patch_agent` carrying every supplied branding and contact field (one explicit update mask; the agent resource has no questionnaire fields), then `requestVerification` persisting the verification contact when the brand-contact trio is complete — early persistence that does NOT trigger the review. The questionnaire and the carrier choice persist on the local agent row only — the relay never fires `requestLaunch`. The Google + carrier review is operator-side, run from the open-rcs-manager console. On fail, returns 422 with the failure list and leaves the row untouched. A non-draft agent yields 409 (illegal transition). With the optional `carriers` body the selection is stored locally: `launch_targets` stores the selection and the carrier map is stamped selected → `pending` / unselected → `disabled`. On an agent already in `validation` a selection merges additively — `launch_targets` unions and only the new regions flip to `pending` (no Google call; the operator console's send action covers the union when it fires), existing carrier entries and the original `validation_requested_at` are preserved — and an already-known selection is an idempotent 200 no-op (no write); a bare body on `validation` (or any status beyond draft) still yields 409.
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 |
carriers |
["array", "null"] |
no |
The selected carrier region keys (seeded regions only). |
{
"carriers": [
"/v1/regions/orange-france",
"/v1/regions/sfr"
]
}
Responses
| Status | Description |
200 |
Agent validated; status moved to `validation` after the whole row was mirrored to Google (patch_agent + requestVerification when the brand-contact trio is complete). With a selection, `launch_targets` is the persisted (seed-ordered, deduped) carrier selection; a no-op re-selection returns the row unchanged.
|
401 |
Missing or invalid API key. |
404 |
Agent not found for this tenant. |
409 |
Agent is not in the `draft` state (illegal transition). |
422 |
One or more validation rules failed; the agent row is unchanged. Each entry in `errors` names the field and the rule it broke (e.g. "agent_color: must be a hex colour (#rrggbb or #rgb)"). The full rule set — every field and check the engine enforces before the `draft → validation` transition — is catalogued in docs/agent-validation-rules.md. `errors` is an array of human-readable strings (no structured `codes`). Distinct guard body: when the row is not yet persisted to Google the route answers 422 `{"error": "agent not persisted to Google"}` before the launch-rules check and before the draft → validation transition — fill the persist trigger set via PATCH and retry. With an invalid `carriers` selection — non-array, empty, or non-seed keys such as the Legos denylist) the same 422 body carries one error entry per offending key (e.g. `carriers: "/v1/regions/legos-carrier-fr" is not a seeded carrier region`). A Google rejection of the full-info mirror answers 422 too, with the refused paths under `rejected_update_mask` (or `rejected_fields` for the verification contact) plus the row identity (`agent_id`, `google_agent_id`, `persist_state: "persisted"`); the row stays `draft` (retry-safe). Recovery is surgical: a later PATCH re-sends a refused path only when it touches it, while a retry of this route re-mirrors the whole row.
|
502 |
Google Business Communications error while syncing the agent's full info to Google — Google's error payload is relayed in the body, merged with the row identity (`agent_id`, `google_agent_id`, `persist_state: "persisted"`; the PATCH Branch-A 502 carries no identity keys).
|
200 example
{
"agent_id": "01H...",
"status": "validation",
"validation_requested_at": "2026-07-19T12:00:00Z",
"launch_targets": [
"/v1/regions/orange-france",
"/v1/regions/sfr"
]
}