Skip to main content
This document provides a guide and overview for the InsertSurface RPC, which allows you to register a Surface directly via API. A Surface must exist before it can be referenced by name in InsertTreatmentType or UpdateTreatmentType, so this endpoint removes the manual console step from an otherwise API-driven treatment type integration.

API Definition

InsertSurface requires a Treatment Management API key, passed in the x-api-key header. A key without Treatment Management permissions is rejected with 403 PERMISSION_DENIED. The key is validated against the projectId in the request: a key issued for one project cannot create a Surface on another.

Entities

SurfacePb

InsertSurface

API to register a Surface

Surface name rules

InsertSurface is idempotent on (project_id, surface_name). Calling it again with the same project and name returns the existing Surface without creating a duplicate or returning an error. Retrying after a network timeout is therefore always safe, and there is no need to track which Surfaces have already been created - call it unconditionally before referencing a Surface by name.
:::caution Surfaces cannot be deleted. Creating one also provisions the per-Surface event schemas and data fields behind it. Validate the name on your side before calling, since a typo results in a permanent Surface. :::

Sample cURL Request

Sample Response

Errors

Registering a Surface and a Treatment Type together

InsertTreatmentType and UpdateTreatmentType validate that every Surface named in surfaces already exists for the project, and reject the request with 400 otherwise:
Call InsertSurface first for each Surface name, then reference those names in the treatment type request:
  1. POST /v1/InsertSurface for each Surface the treatment type will use
  2. POST /v1/InsertTreatmentType with surfaces: [{ "surfaceName": "IN_APP_CONTENT" }]
  3. POST /v1/InsertTreatment to add content to the treatment type
Because step 1 is idempotent, it is safe to run on every treatment type creation rather than only the first time a Surface is used.