Preview a hosted page or email in a branding
/api/v1/branding/previewRenders one hosted page, in one of its states, or one customer email, in the Environment's branding with the unsaved changes in branding laid over it, so a branding change can be checked before it is saved. Nothing is saved, and no session or person is involved: the page shows sample data. page and state are ids from the preview list, and scheme renders a page in its light or its dark look whatever the color scheme. Returns the whole HTML document, which works without scripts. Returns 400 (branding.preview_page_unknown) for a page or state that does not exist, or validation for a malformed branding value, and 403 (plan_feature_unavailable) when the Account's plan does not include hosted page customization. language renders it in one of the languages Canopy writes the pages in, with the wording text_overrides holds for that language; left out, English.
Authentication
Authorization Option A JWT access token. Never send alongside X-API-Key: a request carrying both is refused.
X-API-Key Option B API key for management-tier access. Never send alongside an Authorization header: a request carrying both is refused.
branding.viewBrandingView the Environment's hosted-page branding. A scoped API key must hold it as a scope; a full-access key holds every scope within its Environment except the named-only and account scopes; a developer's token needs the Console capability that covers it. A credential without it is refused with 403.
Headers
X-Canopy-EnvironmentThe id of the Environment this request acts in. Required with an account API key, which belongs to the Account and names its Environment per request; an Environment key may send it only to name its own Environment. A missing header for an account key answers `400` (`api_key.environment_required`), one naming no Environment of the key's Account `400` (`api_key.environment_not_found`), and one naming another Environment than an Environment key's own `400` (`api_key.environment_mismatch`).
Request body
application/json
pagestring Required The hosted page or email to render, by the `id` the preview list returns.
statestring Required One of that page's states, by the `id` the preview list returns. An email has a single state, `default`.
brandingobject Optional Unsaved branding to render with, in the shape of a branding change: each field set here replaces the saved value, `null` clears it, and a field left out keeps the saved value. Leave it out to preview the saved branding.
schemeenum Optional The look to render a hosted page in, whatever the branding's `color_scheme`: the way to see both looks of a `system` scheme, which otherwise follows the device showing the preview. Leave it out to render the page as it is served. An email is always light.
languageenum Optional The language to render the page or email in, with the wording `text_overrides` holds for it. Leave it out to render it in English.
Responses
application/json
data *BrandingPreviewResponseDto
application/json
error *ApiErrorBodyDto
application/json
error *ApiErrorBodyDto
application/json
error *ApiErrorBodyDto
Errors
When the request can't be completed, the response body includes a stable error code you can branch on, and a correlation_id (also sent as the X-Correlation-Id header). Quote the correlation id when you contact support: it identifies the exact request in Canopy's logs. A request refused by an authorization check answers 403 with the code authorization.denied, and its data names the denial_reason and the permission checked.
authorization.deniedForbiddenThe credential does not hold the permission this operation checks: a scoped API key without the scope, a developer without the Console capability that covers it, or a permission granted somewhere other than the node the request targets. The error's data names the permission.
Add the permission named in the Authentication section to the key's scopes, or ask an account administrator to grant the covering capability, then retry. For a node-scoped operation, make sure the grant reaches the node you are acting on.
Returned object
curl -X POST "https://auth.canopy-io.com/api/v1/branding/preview" \ -H "X-Canopy-Environment: value" \ -H "X-API-Key: $CANOPY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "page": "login", "state": "WrongPassword", "branding": { "product_name": "string", "logo_url": "string", "logo_dark_url": "string", "logo_kind": "full", "favicon_url": "string", "color_scheme": "light", "primary_color": "#B93C0C", "background_color": "#0B1F3A", "text_color": "#1F2937", "surface_color": "#FFFDF8", "primary_dark_color": "#FDBA74", "background_dark_color": "#0B0B0F", "text_dark_color": "#F4F4F5", "surface_dark_color": "#18181B", "layout": "card", "background_style": "color", "gradient_start_color": "#EEF2FF", "gradient_end_color": "#C7D2FE", "gradient_start_dark_color": "#0B1020", "gradient_end_dark_color": "#111827", "background_image_url": "https://cdn.example.com/brand/background-image.jpg", "background_image_dark_url": "https://cdn.example.com/brand/background-image-dark.jpg", "panel_heading": "string", "panel_text": "string", "panel_image_url": "https://cdn.example.com/brand/panel-image.jpg", "panel_image_dark_url": "https://cdn.example.com/brand/panel-image-dark.jpg", "corner_radius": "none", "card_style": "border", "card_shadow": "none", "heading_font": "inter", "body_font": "https://cdn.example.com/fonts/brand.woff2", "support_url": "string", "terms_url": "string", "privacy_url": "string", "header_html": "<p>Need a hand? <a href=\"https://acme.example/help\">Ask us</a>.</p>", "notice_html": "<p>Need a hand? <a href=\"https://acme.example/help\">Ask us</a>.</p>", "footer_html": "<p>Need a hand? <a href=\"https://acme.example/help\">Ask us</a>.</p>", "custom_css": ":root { --hp-field-height: 52px; }\n[data-page=\"register\"] .hp-card { padding: 40px; }", "page_template": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n{{canopy:head}}\n</head>\n<body>\n<header>Acme</header>\n{{canopy:form}}\n</body>\n</html>", "page_template_sources": "https://cdn.acme.example\nhttps://analytics.acme.example", "text_overrides": { "en": { "authHosted.login.signInHeading": "Sign in to Acme" } } }, "scheme": "light", "language": "es" }'
{ "data": { "kind": "page", "title": "Sign in", "html": "string" } }
Tell us how we can improve this guide.