# Integrations

> Server-side conversions to Meta and GA4

Source: https://rcms-tickets-test.web.app/docs/reference/integrations

Every operation below is also in [the OpenAPI document](https://rcms-tickets-test.web.app/v1/openapi.yaml). One that names an MCP tool can be called through [the MCP server](https://rcms-tickets-test.web.app/docs/mcp.md); one that names none cannot.

## Meta and GA4 settings

`GET /v1/integrations`

Operation id `listIntegrations`. MCP tool `list_integrations`. SDK `tickets.integrations.list`.

The Meta and GA4 conversion integrations that are set up, with whether each is on, its ids, and `secret_set`. A token is never shown, to any key or person. `problem` is given while sending is paused: the platform refused the token or cannot use the settings, or the saved token cannot be read.

**Who may call it.** Any one of: An API key with scope `full`, `read`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `integrations.manage` (owner, admin).

**Answers 200.** The integrations set up.

**Fields**

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "list" |  |
| `data` * | array of Integration | This page, newest first. |
| `has_more` * | boolean | True when there is another page: pass the last id as starting_after. |
| `url` * | "/v1/integrations" | The path this list came from (/v1/integrations). |

\* required

## Set up Meta or GA4

`PUT /v1/integrations/{kind}`

Operation id `upsertIntegration`. MCP tool `upsert_integration`. SDK `tickets.integrations.save`.

Sets up, or changes, Meta (`pixel_id`, `access_token`, `test_event_code`) or GA4 (`measurement_id`, `api_secret`) for server-side purchases. `kind` is `meta` or `ga4`. The first save needs the id and the secret; later saves change only what you send. The secret is sealed and never shown again, and a new one (or, unless the token cannot be read, a new id) lifts a pause and sends what it held back. Any save lifts a `setup_rejected` pause. We choose the hosts we call: you cannot. The first save leaves it off until `enabled` is true, so a test can come first. An order is sent when its buyer said yes to ad tracking, or said nothing and `send_when_consent_unknown` is on (it is off until you turn it on); never when they said no, and never for an order with no attribution or a door, dashboard or guest-list sale. Changing the pixel or measurement id emails the owners. Owner or admin, or a `full` key.

**Who may call it.** Any one of: An API key with scope `full`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `integrations.manage` (owner, admin).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `kind` * | path | IntegrationKind | meta: the Conversions API; ga4: the Measurement Protocol. |

**Request body** (`UpsertIntegrationInput`)

| Field | Type | Description |
| --- | --- | --- |
| `enabled` | boolean |  |
| `pixel_id` | string |  |
| `access_token` | string | Meta: written, never read back. |
| `test_event_code` | string \| null |  |
| `measurement_id` | string |  |
| `api_secret` | string | GA4: written, never read back. |
| `send_when_consent_unknown` | boolean |  |

```json
{
  "enabled": true,
  "measurement_id": "G-ABC123XYZ",
  "api_secret": "EXAMPLEapisecret"
}
```

**Answers 200.** Saved (secrets are never shown again).

**Fields** (`Integration`)

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "integration" |  |
| `id` * | string | An id starting with int_. |
| `mode` * | Mode | test or live, decided by the key (rt_test_… or rt_live_…). Test and live data never mix. |
| `kind` * | IntegrationKind | meta: the Conversions API; ga4: the Measurement Protocol. |
| `enabled` * | boolean | Whether real purchases go. Off until someone turns it on, so a test can come first. |
| `pixel_id` * | string \| null | Meta. |
| `test_event_code` * | string \| null | Meta: only the test purchase uses it. Real purchases go to the real pixel. |
| `measurement_id` * | string \| null | GA4 (G-…). |
| `secret_set` * | boolean | The access token (Meta) or API secret (GA4) is stored. It is never returned. |
| `send_when_consent_unknown` * | boolean | Send for an order whose ad consent is unknown (default false; turning it on is audited). Denied is never sent, and neither is an order with no attribution or a door, dashboard or guest-list sale, whatever this says. |
| `problem` | object | Given only while sending is paused: token_rejected (the platform refused the token), setup_rejected (it can't use the id or the token together), token_unreadable (we can't open the saved token). Nothing is sent, and no… |
| `created_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `updated_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |

\* required

## Send a test conversion

`POST /v1/integrations/{kind}/test`

Operation id `testIntegration`. MCP tool `test_integration`. SDK `tickets.integrations.test`.

Sends one test purchase and records it in the log. Meta: to your Test Events tab, with the saved `test_event_code` (refused without one, so a test never reaches your real pixel). GA4: to Google's validation endpoint, which keeps it out of reports and does not check your API secret. Leave `order` out to send a made-up sale; name a test-mode order to send that one. A few a minute.

**Who may call it.** Any one of: An API key with scope `full`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `integrations.manage` (owner, admin).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `kind` * | path | IntegrationKind | meta: the Conversions API; ga4: the Measurement Protocol. |

**Request body** (`TestIntegrationInput`)

| Field | Type | Description |
| --- | --- | --- |
| `order` | string | A test-mode order to send (default: a made-up one). |

```json
{}
```

**Answers 201.** Sent with Meta's test_event_code or to GA4's debug endpoint.

**Fields** (`ConversionDelivery`)

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "conversion_delivery" |  |
| `id` * | string | An id starting with cvd_. |
| `mode` * | Mode | test or live, decided by the key (rt_test_… or rt_live_…). Test and live data never mix. |
| `integration` * | IntegrationKind | meta: the Conversions API; ga4: the Measurement Protocol. |
| `order` * | string \| null | An id starting with ord_. |
| `event_name` * | "Purchase" \| "Refund" |  |
| `event_id` * | string | The order's tracking_event_id. |
| `status` * | "pending" \| "retrying" \| "sent" \| "failed" \| "skipped" | pending (its first try is queued), retrying (a try failed, another is booked: next_attempt_at), sent, failed (it did not arrive: every retry was used, or sending is paused, and a paused one goes again after a save), ski… |
| `skip_reason` * | "ad_consent_denied" \| "ad_consent_unknown" \| "comp" \| "test_mode" \| "disabled" \| "no_client_id" \| "refunded" \| null | ad_consent_denied; ad_consent_unknown (nobody was asked: consent unknown with the switch off, no attribution, or a door, dashboard or guest-list sale); comp (a free order is no purchase); test_mode (a test order to a li… |
| `test` * | boolean |  |
| `attempts` * | integer |  |
| `next_attempt_at` * | string \| null | While retrying: the next try. |
| `response_status` * | integer \| null |  |
| `error` * | string \| null |  |
| `created_at` * | string (date-time) | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |
| `sent_at` * | string \| null | An instant in ISO 8601 with its zone, e.g. 2027-07-17T20:00:00Z. Answers are always UTC. |

\* required

**Errors of its own.** [`feature_disabled`](https://rcms-tickets-test.web.app/docs/errors.md#feature_disabled). The errors every operation can answer are on [the errors page](https://rcms-tickets-test.web.app/docs/errors.md).

## The conversion delivery log

`GET /v1/integrations/{kind}/deliveries`

Operation id `listConversionDeliveries`. MCP tool `list_conversion_deliveries`. SDK `tickets.integrations.deliveries`.

The log of purchases and refunds sent to one platform, newest first: `status` (pending, retrying, sent, failed, skipped), the reason when skipped, the attempts and the platform's answer. Never a buyer's details. Filter by one of `order`, `status` or `skip_reason`. Page forward with `starting_after`.

**Who may call it.** Any one of: An API key with scope `full`, `read`. Any other scope answers `insufficient_scope`; A signed-in dashboard member whose role has `integrations.manage` (owner, admin).

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `kind` * | path | IntegrationKind | meta: the Conversions API; ga4: the Measurement Protocol. |
| `limit` | query | integer | How many to return, 1 to 100 (default 20). |
| `starting_after` | query | string | An id from the page before: the page after it. |
| `ending_before` | query | string | An id from the page after: the page before it. A list read from the database offers it as the list comes and filtered by event alone, in the default order, and answers parameter_invalid to any other… |
| `order` | query | string | An id starting with ord_. |
| `status` | query | "pending" \| "retrying" \| "sent" \| "failed" \| "skipped" |  |
| `skip_reason` | query | "ad_consent_denied" \| "ad_consent_unknown" \| "comp" \| "test_mode" \| "disabled" \| "no_client_id" \| "refunded" |  |

**Answers 200.** A page of deliveries.

**Fields**

| Field | Type | Description |
| --- | --- | --- |
| `object` * | "list" |  |
| `data` * | array of ConversionDelivery | This page, newest first. |
| `has_more` * | boolean | True when there is another page: pass the last id as starting_after. |
| `url` * | string | The path this list came from (/v1/integrations/{kind}/deliveries). |

\* required
