Docs
/
/

Email layouts mAPI reference

Complete reference documentation for the Email layouts resource.

Email layouts

#

Email layouts wrap email message templates to share consistent design components between the email notifications that your recipients receive.

You can create and update email layouts in your development environment, as well as retrieve or list all layouts in a given environment.

List email layouts

#

Returns a paginated list of email layouts available in a given environment.

Endpoint

GET/v1/email_layouts

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

hide_uncommitted_changes
boolean

Whether to hide uncommitted changes. When true, only committed changes will be returned. When false, both committed and uncommitted changes will be returned.

after
string

The cursor to fetch entries after.

before
string

The cursor to fetch entries before.

limit
integer

The number of entries to fetch per-page.

Returns

PaginatedEmailLayoutResponse

A paginated list of EmailLayout. Contains a list of entries and page information.

A list of entries.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

created_at
string(date-time)
Required

The timestamp of when the email layout was created.

environment
string

The environment of the email layout.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string
Required

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

key
string
Required

The unique key for this email layout.

name
string
Required

The human-readable name of this email layout.

sha
string
Required

The SHA of the email layout.

text_layout
string
Required

The complete plaintext content of the email layout.

updated_at
string(date-time)

The timestamp of when the email layout was last updated.

page_info

The information about a paginated result.

after
string

The cursor to fetch entries after. Will only be present if there are more entries to fetch.

before
string

The cursor to fetch entries before. Will only be present if there are more entries to fetch before the current page.

page_size
integer

The number of entries to fetch per-page.

Get email layout

#

Retrieve an email layout by its key, in a given environment.

Endpoint

GET/v1/email_layouts/{email_layout_key}

Path parameters

email_layout_key
string

The key of the email layout to show.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

hide_uncommitted_changes
boolean

Whether to hide uncommitted changes. When true, only committed changes will be returned. When false, both committed and uncommitted changes will be returned.

Returns

A versioned email layout used within an environment.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

created_at
string(date-time)

The timestamp of when the email layout was created.

environment
string

The environment of the email layout.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

key
string

The unique key for this email layout.

name
string

The human-readable name of this email layout.

sha
string

The SHA of the email layout.

text_layout
string

The complete plaintext content of the email layout.

updated_at
string(date-time)

The timestamp of when the email layout was last updated.

Upsert email layout

#

Updates an email layout, or creates a new one if it does not yet exist.

Note: this endpoint only operates in the "development" environment.

Endpoint

PUT/v1/email_layouts/{email_layout_key}

Path parameters

email_layout_key
string

The key of the email layout to upsert.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

force
boolean

When set to true, forces the upsert to override existing content regardless of environment restrictions. This bypasses the development-only environment check and origin environment checks.

commit
boolean

Whether to commit the resource at the same time as modifying it.

commit_message
string

The message to commit the resource with, only used if commit is true.

allow_empty
boolean

When used with commit, creates a new version with identical content and commits it if there are no unpublished changes.

Request body

email_layout

A request to update or create an email layout.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string
Required

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

name
string
Required

The friendly name of this email layout.

text_layout
string
Required

The complete plain text content of the email layout.

Returns

WrappedEmailLayoutResponse

Wraps the EmailLayout response under the email_layout key.

email_layout

A versioned email layout used within an environment.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

created_at
string(date-time)

The timestamp of when the email layout was created.

environment
string

The environment of the email layout.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

key
string

The unique key for this email layout.

name
string

The human-readable name of this email layout.

sha
string

The SHA of the email layout.

text_layout
string

The complete plaintext content of the email layout.

updated_at
string(date-time)

The timestamp of when the email layout was last updated.

Validate email layout

#

Validates an email layout payload without persisting it.

Note: this endpoint only operates in the "development" environment.

Endpoint

PUT/v1/email_layouts/{email_layout_key}/validate

Path parameters

email_layout_key
string

The key of the email layout to validate.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

Request body

email_layout

A request to update or create an email layout.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string
Required

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

name
string
Required

The friendly name of this email layout.

text_layout
string
Required

The complete plain text content of the email layout.

Returns

WrappedEmailLayoutResponse

Wraps the EmailLayout response under the email_layout key.

email_layout

A versioned email layout used within an environment.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

created_at
string(date-time)

The timestamp of when the email layout was created.

environment
string

The environment of the email layout.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

key
string

The unique key for this email layout.

name
string

The human-readable name of this email layout.

sha
string

The SHA of the email layout.

text_layout
string

The complete plaintext content of the email layout.

updated_at
string(date-time)

The timestamp of when the email layout was last updated.

Preview an email layout

#

Renders an email layout preview, without requiring a layout to be persisted within Knock. This is useful for previewing layouts in isolation, before saving them.

Endpoint

POST/v1/email_layouts/preview

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

Request body

The actor to reference in the preview.

data
object(any)

The data to pass to the layout for rendering.

email_layout

A request to update or create an email layout.

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string
Required

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

name
string
Required

The friendly name of this email layout.

text_layout
string
Required

The complete plain text content of the email layout.

recipient
2 possible types
Required

A recipient reference, used when referencing a recipient by either their ID (for a user), or by a reference for an object.

tenant
string

The tenant to associate with the preview. Must not contain whitespace.

workflow
object

Optional workflow context for variable hydration. When provided, recipient/actor/tenant are resolved via Knock.

categories
string[]

Workflow categories.

key
string
Required

The workflow key.

Returns

PreviewEmailLayoutResponse

A response to an email layout preview request.

errors
object[]

A list of errors encountered during rendering. Present when result is "error".

field
string

The layout field that caused the error, if available.

line
integer

The line number where the error occurred, if available.

message
string
Required

A human-readable description of the error.

layout
object

The rendered email layout, ready to be previewed.

html_body
string

The fully rendered HTML body of the email layout.

text_body
string

The fully rendered plain text body of the email layout.

result
enum(string)

The result of the preview.

successerror

EmailLayout

#

A versioned email layout used within an environment.

Attributes

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

created_at
string(date-time)

The timestamp of when the email layout was created.

environment
string

The environment of the email layout.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

key
string

The unique key for this email layout.

name
string

The human-readable name of this email layout.

sha
string

The SHA of the email layout.

text_layout
string

The complete plaintext content of the email layout.

updated_at
string(date-time)

The timestamp of when the email layout was last updated.

EmailLayoutRequest

#

A request to update or create an email layout.

Attributes

branding_overrides

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

footer_links
object[]

A list of one or more items to show in the footer of the email layout.

text
string
Required

The text to display as the link.

url
string
Required

The URL to link to.

html_layout
string

The complete HTML or MJML content of the email layout.

is_mjml
boolean

Whether this layout uses MJML format. When true, html_layout must contain <mjml> tags.

name
string

The friendly name of this email layout.

text_layout
string

The complete plain text content of the email layout.

BrandingOverrides

#

Overrides to apply against account branding variables in an email layout, including dark mode-specific values.

Attributes

dark_icon_url
string

A URL for a dark mode icon override.

dark_logo_url
string

A URL for a dark mode logo override.

dark_primary_color
string

The dark mode primary brand color in hex format.

dark_primary_color_contrast
string

The dark mode contrast color for the primary brand color in hex format.

icon_url
string

A URL for a light mode icon override.

logo_url
string

A URL for a light mode logo override.

primary_color
string

The light mode primary brand color in hex format.

primary_color_contrast
string

The light mode contrast color for the primary brand color in hex format.

primary_text_color
string

The light mode primary text color in hex format.

secondary_text_color
string

The light mode secondary text color in hex format.

New chat