Agents
Create a managed RCS agent (draft)
POST
/agents
x-api-key
Creates a draft agent row and — when the required field set is already complete — the Google draft agent under an implicitly-managed brand resolved by display name. NO field is required at create: an incomplete body stores the row with `google_agent_id: null`, `persist_state: "pending"` and the flat `missing_persist_fields` list, and the Google create fires automatically on the row write that completes the set; a complete body returns `google_agent_id` with `persist_state: "persisted"` inline. A Google rejection at the persist step earns 422/502 and the row stays stored and unpersisted — the next PATCH retries the create. Agent `status` stays `draft` through the persist. Secured by an x-api-key. The completing save performs ONE Google agent-resource write per save: the create itself carries the full row mirror (every supplied branding and contact-pair field — nothing re-sends it afterwards; the agent resource has no questionnaire fields). As soon as the brand-contact trio (`brand_contact_name` / `brand_contact_email` / `brand_website_url`) is complete, the verification contact is persisted via `requestVerification` — one write of NEW data (the contact is a Google sub-resource that cannot ride any agent-resource write), NOT a second persist of the agent; it does NOT trigger the Google review. The launch questionnaire and the carrier choice are stored locally on the agent row only: the relay never fires `requestLaunch` — the operator console sends the questionnaire to Google at launch time. `requestVerification` fires at the persist moment, on completing PATCHes, and at POST /agents/{agent_id}/validate, while the review itself only starts operator-side from the open-rcs-manager console. A Google rejection of the verification contact surfaces 422 with `rejected_fields` plus the row identity (`agent_id`, `google_agent_id`, `persist_state: "persisted"`); the row stays persisted. Recovery is surgical: a later PATCH re-sends the contact only when the PATCH touches the brand-contact trio; POST /agents/{agent_id}/validate re-mirrors the whole row. After the create, the relay registers the account's Google RBM webhook for the agent on the brands.agents.integrations sub-resource (`agentWebhookIntegration`, best-effort; a later PATCH reconciles).
Parameters
| Name | In | Type | Required | Description |
x-api-key |
header |
string |
yes |
The relay API key (x-api-key header). |
Request body
| Field | Type | Required | Description |
brand |
string |
no |
Optional at create; required to persist the draft to Google. Brand display name. NOT reserved, owned, or exclusive per account — multiple accounts may use the same display name independently. At the persist moment the relay resolves the name against Google: a previously recorded brand id is verified by one GET and reused while it is alive and matches the name; otherwise the brand is created, and a rejected create reuses the existing same-name brand (possibly created by another account). The resolved identity (new or reused) is recorded in the account's brands table and never deleted. PATCHable until the agent is persisted to Google, immutable after.
|
name |
string |
no |
Optional at create; required to persist the draft to Google. Agent display name (forwarded to Google as displayName).
|
use_case |
string |
no |
Optional at create; required to persist the draft to Google. Google RBM `agentUseCase` enum. Closed value set — exactly promotional / transactional / otp / multi use — the server rejects anything outside this list. PATCHable until the agent is persisted to Google; create-only (422) after.
|
billing_category |
string |
no |
Optional at create; required to persist the draft to Google. Google RBM `billingConfig.billingCategory` enum. Closed value set — the server rejects anything outside this list; BASIC is not a real Google BillingCategory (the live API rejects it at draft creation). PATCHable until the agent is persisted to Google; create-only (422) after.
|
additional_info |
object |
no |
Branding + launch fields. Create stores the whole map on the agent row, so EVERY sub-key below is writable at create and belongs in the default body. Five of the branding keys (`agent_description`, `agent_logo_url`, `agent_banner_url`, `agent_tos_url`, `agent_pp_url`; `agent_color` is NOT among them) are required to persist the draft to Google, not for draft creation: supply them now or via PATCH, and the Google create fires automatically on the row write that completes the set. Those five are the branding keys Google requires at agent-create and rejects a persist whose branding is absent. The remaining sub-keys (agent display identity, contact modes, spv_* launch data) are stored on the row for later validation/launch — supply them now or refine any subset later via PATCH. Any field you supply is format-checked (a bad value earns a 400); non-blank branding values are forwarded to Google at the persist step, blanks are omitted. Contact pairs (value + label) must be supplied COMPLETE: a half-filled pair is rejected with 422 naming the blank side, because it could never reach Google. `google_required` IS accepted at create: the supplied map is stored on the row and blank-checked exactly like on PATCH; at the persist step the brand-contact trio rides `requestVerification`, while the questionnaire keys are stored locally on the agent row — the agent resource has no questionnaire fields, and the relay never fires `requestLaunch` (the operator console sends the questionnaire to Google at launch time).
|
google_required |
object |
no |
Google review fields, accepted at create exactly like on PATCH: the supplied map is stored on the row (partial maps are legal, they complete over several saves) and every supplied value is format-checked. At the persist step the brand-contact trio rides `requestVerification` as soon as the trio is complete; the questionnaire keys are stored locally on the agent row — never on the agent resource (it has no questionnaire fields), and the relay never fires `requestLaunch`: the operator console sends the questionnaire to Google at launch time. Blank values are omitted, never sent to Google as empty fields.
|
Responses
| Status | Description |
200 |
Draft agent row created. A complete field set runs the Google create inline; an incomplete one returns the pending shape with the still-blank field names.
|
400 |
Missing or invalid request body field. |
422 |
Half-filled contact pair (`errors` names the blank side), unfetchable logo/hero media URL pre-flight, or a Google-side rejection at the deferred persist step (`errors` decoded per Google field; the row remains stored and unpersisted, the next PATCH retries the create), or a Google rejection of the verification contact that the completing save persists via `requestVerification` (reported under `rejected_fields` with the persisted row identity — the row stays persisted).
|
401 |
Missing or invalid API key. |
502 |
Google Business Communications error — two postures. At the deferred persist step 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"`).
|