# Branding document

Source: https://www.pontive.com/docs/api-reference/management/branding-document

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## Export the branding document

```http
GET https://api.{region}.pontive.com/v1/branding/document
```

The instance's branding as one branding/v1 document (api-route-review D47): the brand's published tokens and theme, the localization settings, the instance's own published widget definitions, the brand's per-widget layouts, styles and copy, the custom blueprints, and the files the brand uploaded, inlined so the document works in another instance. Only the published state is exported; drafts stay in the dashboard. Everything is named by a key, never an id, and the output is deterministic: two exports of the same state are byte-identical, and the ETag is the hash of the bytes. Send it as If-None-Match to get 304 when nothing changed. Import the document into another instance with POST /v1/branding/document/import. Needs sys:brand:read and sys:widget:read.

Operation ID: `GetBrandingDocument`

### Responses

- `200` A branding/v1 document: BrandingDocument
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `500` Internal Server Error: ErrResponse

## Import a branding document

```http
POST https://api.{region}.pontive.com/v1/branding/document/import
```

Plans importing a branding/v1 document into this instance and, with dry_run false, applies the plan (api-route-review D47). The brand is replaced: its tokens, theme, localization settings and every per-widget customization take the document's values, and a customization the instance has and the document lacks is reset and listed as changed. Widget definitions and blueprints are merged by key: a new key is created, a differing one replaced (a published definition's markup never changes, so a different one is a conflict), and one the document lacks is listed as absent and left alone. Nothing is deleted. With publish true (the default) the import publishes one new branding version and the theme; with publish false it writes drafts for review in the dashboard. Re-importing an instance's own export plans every entry unchanged and writes nothing. The dry run's ETag fingerprints the instance's branding: send it as If-Match on the apply to be refused 412 precondition_failed if anything changed since. An apply with conflicts is 409 import_conflict, one detail per conflict, field <kind>.<key>.<field>, and applies nothing. A document the format refuses (not JSON, a member it does not define, a pontive_document it does not read) is 422 field_invalid_format; one over 5 MB is 422 field_too_long. X-Idempotency-Key makes an apply safe to retry; the same key with another request is 422 idempotency_key_reused. Needs sys:brand:manage and sys:widget:manage, and sys:settings:manage when the localization settings change.

Operation ID: `ImportBrandingDocument`

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `If-Match` | string |  | The dry run's ETag: the apply is refused 412 precondition_failed if the instance's branding changed since |
| `X-Idempotency-Key` | string |  | Idempotency key, read on an apply |

### Request body (`application/json`, required): ImportBrandingRequest

The document and how to import it

### Responses

- `200` OK: BrandingImportPlan
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` instance_unclaimed: the instance is unclaimed; claim this instance to customize its branding (pontive-spec 47): ErrResponse
- `409` import_conflict: the plan has conflicts, one detail each; nothing was applied: ErrResponse
- `412` precondition_failed: the branding changed since the dry run: ErrResponse
- `422` field_invalid_format, field_too_long, missing_required_field or idempotency_key_reused: ErrResponse
- `500` Internal Server Error: ErrResponse

## Schemas

### BrandingDocument

Document is a branding/v1 document, passed to branding-svc as the
bytes it was sent. At most 5 MB.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `assets` | Record<string, BrandingDocumentAsset> |  | Assets are the uploaded files the tokens reference as asset:sha256-<hex>, keyed sha256-<hex>. A URL the customer hosts stays a URL. |
| `blueprints` | BrandingDocumentBlueprint[] |  | Blueprints are the instance's custom blueprints, by id. |
| `brand` | BrandingDocumentBrand |  |  |
| `localization` | BrandingDocumentLocalization |  |  |
| `pontive_document` | "branding/v1" |  | PontiveDocument is the document type. An import reads the current and the previous major version. |
| `pontkit` | string |  | Pontkit is the pontkit release the document was exported against. Informational: an import checks markup and the theme against the target's own release. |
| `widget_customizations` | BrandingDocumentCustomization[] |  | WidgetCustomizations are the brand's per-widget layouts, styles and copy, by the definition's key. The brand is a singleton: an import resets a customization the target has and the document lacks. |
| `widgets` | DocumentWidgetDefinition[] |  | Widgets are the instance's own published widget definitions (keys starting custom_). Built-ins are the same everywhere and never travel. |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### ImportBrandingRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `discard_unpublished` | boolean |  | DiscardUnpublished lets the import overwrite a draft with unpublished changes, which is otherwise a conflict. |
| `document` | BrandingDocument |  | Document is a branding/v1 document, passed to branding-svc as the bytes it was sent. At most 5 MB. |
| `dry_run` | boolean |  | DryRun returns the plan and writes nothing. True when omitted: send false to apply. |
| `publish` | boolean |  | Publish publishes what the import changes. True when omitted; false writes drafts for review in the dashboard. |
| `secrets` | Record<string, string> |  | Secrets are the values of the document's {"$secret": "<name>"} placeholders, by name; never inside the document, and never echoed back. A placeholder with no value here or in the target is a conflict. |

### BrandingImportPlan

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `absent` | PlanEntry[] |  |  |
| `changed` | PlanEntry[] |  |  |
| `conflicts` | PlanIssue[] |  |  |
| `created` | PlanEntry[] |  |  |
| `dry_run` | boolean |  | DryRun is true when nothing was written. |
| `object` | "branding_import_plan" |  |  |
| `publish` | boolean |  | Publish says whether the changes are published, or left as drafts. |
| `unchanged` | PlanEntry[] |  |  |
| `warnings` | PlanIssue[] |  |  |

### BrandingDocumentAsset

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `content_type` | string |  |  |
| `data` | string (byte) |  | Data is the file's bytes, base64-encoded. |

### BrandingDocumentBlueprint

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `document` | object |  | Document is the fragment: its nodes and edges, the widgets named by blueprint-local refs. |
| `id` | string |  |  |
| `name` | string |  |  |
| `open_events` | string[] |  |  |
| `widgets` | Record<string, WidgetSpec> |  |  |

### BrandingDocumentBrand

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `theme` | object |  | Theme is the published pont theme, its shape pontkit-core's, in the key order it was saved with. |
| `tokens` | object |  | Tokens is the token tree: reference ramps, semantic roles, component overrides and assets. Fonts are font catalog keys; an uploaded file is asset:sha256-<hex>. |

### BrandingDocumentLocalization

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `default_locale` | string |  |  |
| `enabled_locales` | string[] |  |  |

### BrandingDocumentCustomization

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `layout` | string |  | Layout is the brand's own arrangement of the definition's markup. |
| `styles` | BrandingDocumentStyles |  |  |
| `translations` | Record<string, Record<string, string>> |  | Translations maps a locale to the copy overlay's entries, <element id>.<attribute> to text. |
| `widget_key` | string |  | WidgetKey is the definition's key: a built-in's (signin) or the instance's (custom_…). |

### DocumentWidgetDefinition

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `key` | string |  |  |
| `markup` | string |  | Markup is the definition's pontkit markup. |
| `name` | string |  |  |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### PlanEntry

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fields` | string[] |  | Fields are the document fields that differ, for a changed object. |
| `key` | string |  | Key is the object's key in the document: a flow's or a blueprint's id, a definition's key, a customization's widget_key, an asset's sha256-<hex>, or "" for a singleton (brand, theme, localization). |
| `kind` | string |  | Kind is what the object is. |

### PlanIssue

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code says why. A conflict's: invalid, immutable, retired, missing_reference, unpublished_changes, missing_secret or assets_not_available. A warning's: instance_specific_id, unknown_connection, locale_not_enabled, unused_asset, unused_secret or validation. |
| `field` | string |  | Field is the document field it is about, "" for the whole object. The whole path is <kind>.<key>.<field>, the field a 409 import_conflict detail names. |
| `key` | string |  |  |
| `kind` | string |  |  |
| `message` | string |  |  |

### WidgetSpec

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `from_key` | string |  |  |
| `markup` | string |  |  |
| `name` | string |  | Name is the new widget's name in the flow; its id is minted from it. |

### BrandingDocumentStyles

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `instances` | Record<string, Record<string, any>> |  |  |
| `tokens` | object |  |  |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |
