OpenRCS API reference · v1 ← Back to console Swagger UI
Messaging

Send one RCS message

POST /send x-api-key

Sends one message directly over HTTPS. The relay authenticates the API key, checks the agent and destination phone number, verifies RBM capability, forwards the Google RBM `contentMessage` unchanged, then writes events and stats. Depending on the deployment configuration, processing after those checks is synchronous or asynchronous; every client-fixable rejection (401/402/400/403, 422 not_capable, duplicate `message_id` returning the stored original outcome) stays synchronous and identical in both modes. Asynchronous processing answers `200 {"event_id": "send-<message_id>", "status": "SENT", "google_response": null}` — `SENT` means accepted for sending, not delivered. `event_id` is `send-<message_id>` only when the request supplied a `message_id`; otherwise it is null (the synchronous path mints an id). The final `SENT`/`FAILED` outcome lands in `GET /events` (except the no-event-row classes below) — Google delivery receipts continue to reach user webhooks via Google's event forwarding, like the synchronous path (the relay itself forwards no send outcome to webhooks). Caveats: `google_response` is null at acceptance time; a Google send-time rejection returns the same 200 `SENT` and becomes a `FAILED` event; transport errors or timeouts (the synchronous 504 class) are retried, then dropped with no event row — nothing ever reaches `GET /events` for them; when the balance drops below the message's real cost between acceptance and processing (the processing step recomputes the conversational window and the exact cost — a balance-0 in-window conversational send passes at cost 0), the message is dropped with no event row — treat prolonged absence from `GET /events` as a failure signal.

Parameters

NameInTypeRequiredDescription
x-api-key header string yes

Request body

FieldTypeRequiredDescription
agent_id string yes Registered agent identifier allowed for this API key. Both the short form (`abc123`) and the fully-qualified form (`abc123@rbm.goog`) are accepted; Google receives the form you send, while stored event rows keep the canonical short form.
phone_number string yes Destination number; spaces, dashes and an optional leading plus sign are accepted, then normalized to E.164. Destinations outside configured allowed prefixes are rejected.
tracking string yes Client tracking id copied to event rows and stats.
message yes The Google RBM contentMessage (AgentContentMessage) — the full message content tree: text, files, rich cards, media, suggestion chips and native actions. The relay validates only that this is a JSON object and forwards it verbatim to Google as `contentMessage`; Google enforces the content rules at send time (a violation surfaces as a 422 or 502 response, or as a FAILED delivery event in `GET /events`).
message_id string no Optional client idempotency key (1-128 characters, no control characters). When supplied, the relay uses it as Google's message id and builds the deterministic event id by prefixing it with `send-`. Retrying the same `message_id` reuses stored event data and does not double-count stats.
ttl integer no Optional top-level message TTL in seconds. If omitted, the relay uses DEFAULT_MESSAGE_TTL (86400 seconds by default). `ttl` is not read from inside `message`.

Plain text message

{
  "agent_id": "agent_a",
  "phone_number": "+33612345678",
  "tracking": "campaign-123",
  "message": {
    "text": "Hello from rcs-relay"
  }
}

Rich card with media and suggestions

{
  "agent_id": "agent_a",
  "phone_number": "+33612345678",
  "tracking": "campaign-123",
  "message": {
    "suggestions": [
      {
        "reply": {
          "text": "Book a table",
          "postbackData": "book-table"
        }
      },
      {
        "action": {
          "text": "Call us",
          "postbackData": "call-us",
          "dialAction": {
            "phoneNumber": "+33612345678"
          }
        }
      }
    ],
    "richCard": {
      "standaloneCard": {
        "cardOrientation": "VERTICAL",
        "cardContent": {
          "title": "Autumn menu",
          "description": "Seasonal dishes from our chef.",
          "media": {
            "height": "MEDIUM",
            "contentInfo": {
              "fileUrl": "https://cdn.example.com/menu.jpg"
            }
          },
          "suggestions": [
            {
              "action": {
                "text": "View menu",
                "postbackData": "view-menu",
                "openUrlAction": {
                  "url": "https://example.com/menu",
                  "application": "BROWSER"
                }
              }
            }
          ]
        }
      }
    }
  }
}

Responses

StatusDescription
200 The send was accepted. `status` is `SENT`; `google_response` contains the parsed Google response body, or null when processing is asynchronous. `event_id` is `send-<message_id>` only when the request supplied a `message_id` — otherwise it is null (the synchronous path mints an id).
400 Bad request — invalid JSON, invalid phone format, non-object `message`, invalid `message_id`, or request-model validation failure.
401 Unauthorized — missing or invalid API key.
402 Insufficient credit: the balance in integer euro-cents is below the exact cost of this send. No Google call is made and nothing is charged. The cost is computed at request time: 4/6 for non-conversational agents, and for conversational agents 0 while a 24h window is open or 10 for an opener — so a zero-balance account CAN send an in-window conversational message.
403 Forbidden — the agent is not allowed for the API key, or the phone prefix is not allowed.
413 Payload too large — the serialized request envelope (the entire client request body plus envelope fields) exceeds 250 KB (256,000 bytes). Only returned when the deployment processes sends asynchronously; rejected before acceptance.
503 Send temporarily unavailable — only returned when the deployment processes sends asynchronously: the send could not be accepted for asynchronous processing (transient infrastructure error, such as throttling or access denial). Retryable; the message was not accepted (no event row, no Google delivery-receipt webhook), so clients should retry with the same `message_id`.
422 Not capable — the destination is not RCS-capable for the requested message. A FAILED event and FAILED stats counter are recorded. `google_response.reason` is `not_capable` and includes `required_feature` and `features`.
502 Google rejected the send with a non-2xx response. A FAILED event and FAILED stats counter are recorded, preserving Google's parsed error body when it is JSON.
504 Transport error — timeout or network failure while checking capability or sending to Google. A FAILED event and FAILED stats counter are recorded, with `google_response` set to null.

200 example

{
  "event_id": "send-client-send-001",
  "status": "SENT",
  "google_response": {
    "name": "phones/+33612345678/agentMessages/client-send-001"
  }
}

402 example

{
  "error": "insufficient_credit",
  "balance_cents": 3,
  "cost_cents": 4,
  "rate_card": {
    "NON_CONVERSATIONAL": {
      "basic_cpt_eur": 40,
      "rich_card_cpt_eur": 60
    },
    "CONVERSATIONAL": {
      "first_message_24h_cpt_eur": 100
    }
  }
}

413 example

{
  "error": "message too large for sendings queue"
}

503 example

{
  "error": "sendings queue unavailable"
}

422 example

{
  "event_id": "01HZXAMPLE",
  "status": "FAILED",
  "google_response": {
    "reason": "not_capable",
    "required_feature": "RICHCARD_CAROUSEL",
    "features": [
      "RICHCARD_STANDALONE"
    ]
  }
}