Management API Reference

🚨
Note: the Knock management API only provides access to the resources managed in the Knock dashboard, such as workflows, templates, translations and commits.

All other concepts within the Knock notification engine are accessed through the Knock API, which you use to trigger workflows, identify users, and manage preferences.

The Knock management API provides you with a programmatic way to interact with the resources you create and manage in your Knock dashboard, including workflows, templates, layouts, translations and commits. It's separate from the Knock API and only provides access to a limited subset of resources.

You can use the Knock management API to:

  • Create, update, and manage your Knock workflows and the notification templates within those workflows.
  • Create, update and manage your email layouts.
  • Create and manage the translations used by your notification templates.
  • Create, update, and manage your partials.
  • Commit and promote changes between your Knock environments.

Authentication

The management API authenticates with a Bearer authentication mechanism using a service token generated on your account.

Note: environment-level API keys should never be used to authenticate with the management API. To authenticate with the management API, generate a service token.

Errors

Knock uses standard HTTP response codes to indicate the success or failure of your API requests.

  • 2xx success status codes confirm that your request worked as expected.
  • 4xx error status codes indicate an error caused by incorrect or missing request information (e.g. providing an incorrect API key).
  • 5xx error status codes indicate a Knock server error.

Postman

You can use our Management API Postman collection to quickly get started testing our Management API.

Environments

Knock uses the concept of environments to ensure logical separation of your data. Dashboard resources are created in your development environment and promoted to higher environments.

Endpoints
GET/v1/environments
GET/v1/environments/{environment_slug}

List environments

Returns a paginated list of environments. The environments will be returned in order of their index, with the development environment first.

Endpoint

GET/v1/environments

Query parameters

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

PaginatedEnvironmentResponse

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

Get an environment

Returns a single environment by the environment_slug.

Endpoint

GET/v1/environments/{environment_slug}

Path parameters

environment_slug
string

The slug of the environment to retrieve.

Returns

An environment object.

Environment

An environment object.

Attributes

created_at
string(date-time)

The timestamp of when the environment was created.

deleted_at
string(date-time)

The timestamp of when the environment was deleted.

hide_pii_data
boolean

Whether PII data is hidden from the environment. Read more in the data obfuscation docs.

label_color
string

The color of the environment label to display in the dashboard.

last_commit_at
string(date-time)

The timestamp of the most-recent commit in the environment.

name
string

A human-readable name for the environment. Cannot exceed 255 characters.

order
integer

The order of the environment. The lowest number is the first environment, the highest number is the last environment. The order will not always be sequential.

owner
enum(string)

The owner of the environment.

slug
string

A unique slug for the environment. Cannot exceed 255 characters.

updated_at
string(date-time)

The timestamp of when the environment was last updated.

Channels

Channels are the delivery mechanisms for your notifications.

Endpoints
GET/v1/channels

List channels

Returns a paginated list of channels. Note: the list of channels is across the entire account, not scoped to an environment.

Endpoint

GET/v1/channels

Query parameters

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

PaginatedChannelResponse

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

Channel

A configured channel, which is a way to route messages to a provider.

Attributes

archived_at
string(date-time)

The timestamp of when the channel was deleted.

created_at
string(date-time)

The timestamp of when the channel was created.

custom_icon_url
string

Optional URL to a custom icon for the channel. Only used for display purposes in the dashboard.

description
string

Optional description of the channel's purpose or usage.

key
string

Unique identifier for the channel within a project (immutable once created).

name
string

The human-readable name of the channel.

provider
string

The ID of the provider that this channel uses to deliver messages. Learn more about the providers available in our documentation.

type
enum(string)

The type of channel, determining what kind of messages it can send.

updated_at
string(date-time)

The timestamp of when the channel was last updated.

ChatChannelSettings

Chat channel settings. Only used as configuration as part of a workflow channel step.

Attributes

email_based_user_id_resolution
boolean

Whether to resolve chat provider user IDs using a Knock user's email address. Only relevant for Slack channels for the time being.

link_tracking
boolean

Whether to track link clicks on chat notifications.

EmailChannelSettings

Email channel settings. Only used as configuration as part of a workflow channel step.

Attributes

bcc_address
string

The BCC address on email notifications. Supports liquid.

cc_address
string

The CC address on email notifications. Supports liquid.

from_address
string

The email address from which this channel will send. Supports liquid.

from_name
string

The name from which this channel will send. Supports liquid.

json_overrides
string

A JSON template for any custom overrides to merge into the API payload that is sent to the email provider. Supports liquid.

link_tracking
boolean

Whether to track link clicks on email notifications.

open_tracking
boolean

Whether to track opens on email notifications.

reply_to_address
string

The Reply-to address on email notifications. Supports liquid.

to_address
string

The email address to which this channel will send. Defaults to recipient.email. Supports liquid.

PushChannelSettings

Push channel settings. Only used as configuration as part of a workflow channel step.

Attributes

token_deregistration
boolean

Whether to deregister a push-token when a push send hard bounces. This is to prevent the same token from being used for future pushes.

SmsChannelSettings

SMS channel settings. Only used as configuration as part of a workflow channel step.

Attributes

link_tracking
boolean

Whether to track link clicks on SMS notifications.

InAppFeedChannelSettings

In-app feed channel settings. Only used as configuration as part of a workflow channel step.

Attributes

link_tracking
boolean

Whether to track link clicks on in-app feed notifications.

Workflows

To define a logical flow for your notifications, you create a workflow consisting of steps. Workflow steps can be functions or channels, and can have conditional logic that determines whether to execute that step when the workflow is triggered.

You can retrieve, update, or create a workflow as well as list all workflows in a given environment. Workflows are identified by their unique workflow key.

Endpoints
GET/v1/workflows
GET/v1/workflows/{workflow_key}
PUT/v1/workflows/{workflow_key}
PUT/v1/workflows/{workflow_key}/activate
PUT/v1/workflows/{workflow_key}/run
PUT/v1/workflows/{workflow_key}/validate

List workflows

Returns a paginated list of workflows available in a given environment. The workflows are returned alphabetically by key.

Endpoint

GET/v1/workflows

Query parameters

environment
string

The environment slug.

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.

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

PaginatedWorkflowResponse

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

Get a workflow

Retrieve a workflow by its key in a given environment.

Endpoint

GET/v1/workflows/{workflow_key}

Path parameters

workflow_key
string

The key of the workflow to retrieve.

Query parameters

environment
string

The environment slug.

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 workflow object.

Upsert a workflow

Updates a workflow of a given key, or creates a new one if it does not yet exist.

Note: this endpoint only operates on workflows in the development environment.

Endpoint

PUT/v1/workflows/{workflow_key}

Path parameters

workflow_key
string

The key of the workflow.

Query parameters

environment
string

The environment slug.

annotate
boolean

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

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.

Request body

workflow
WorkflowRequest
Required

A workflow request for upserting a workflow.

Returns

WrappedWorkflowResponse

Wraps the Workflow response under the workflow key.

Activate a workflow

Activates (or deactivates) a workflow in a given environment. Read more in the docs.

Note: This immediately enables or disables a workflow in a given environment without needing to go through environment promotion.

Endpoint

PUT/v1/workflows/{workflow_key}/activate

Path parameters

workflow_key
string

The key of the workflow.

Query parameters

environment
string

The environment slug.

Request body

status
boolean
Required

Whether to activate or deactivate the workflow. Set to true by default, which will activate the workflow.

Returns

WrappedWorkflowResponse

Wraps the Workflow response under the workflow key.

Run a workflow

Runs the latest version of a committed workflow in a given environment using the params provided.

Endpoint

PUT/v1/workflows/{workflow_key}/run

Path parameters

workflow_key
string

The key of the workflow.

Query parameters

environment
string

The environment slug.

Request body

actor
RecipientReference

The actor to reference in the the workflow run.

cancellation_key
string

A key to cancel the workflow run.

data
object(any)

A map of data to be used in the workflow run.

recipients
RecipientReference[]
Required

A list of recipients to run the workflow for.

tenant
string

The tenant to associate the workflow run with.

Returns

RunWorkflowResponse

A response to a run workflow request.

Validate a workflow

Validates a workflow payload without persisting it. Some read-only fields will be empty as they are generated by the system when persisted.

Note: Validating a workflow is only done in the development environment context.

Endpoint

PUT/v1/workflows/{workflow_key}/validate

Path parameters

workflow_key
string

The key of the workflow.

Query parameters

environment
string

The environment slug.

Request body

workflow
WorkflowRequest
Required

A workflow request for upserting a workflow.

Returns

WrappedWorkflowResponse

Wraps the Workflow response under the workflow key.

Steps

Methods that operate on the individual steps within a workflow. Steps are referenced by their ref, which is unique within a workflow.

Endpoints
POST/v1/workflows/{workflow_key}/steps/{step_ref}/preview_template

Preview a workflow template

Generates a rendered template for a given channel step in a workflow.

Endpoint

POST/v1/workflows/{workflow_key}/steps/{step_ref}/preview_template

Path parameters

workflow_key
string

The key of the workflow.

step_ref
string

The reference key of the channel step in the workflow to preview.

Query parameters

environment
string

The environment slug.

Request body

actor
RecipientReference

The actor to reference in the the workflow run.

data
object(any)

The data to pass to the workflow template for rendering.

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 the workflow with.

Returns

PreviewWorkflowTemplateResponse

A response to a preview workflow template request.

Condition

A condition to be evaluated.

Attributes

argument
string

The argument to be evaluated. Arguments can be either static values or dynamic properties. Static values will always be JSON decoded so will support strings, lists, objects, numbers, and booleans. Dynamic values should be path expressions.

operator
enum(string)

The operator to use in the evaluation of the condition.

variable
string

The variable to be evaluated. Variables can be either static values or dynamic properties. Static values will always be JSON decoded so will support strings, lists, objects, numbers, and booleans. Dynamic values should be path expressions.

ConditionGroup

A group of conditions to be evaluated.

Attributes

ConditionGroup
2 possible types

A group of conditions to be evaluated.

Duration

A duration of time, represented as a unit and a value.

Attributes

unit
enum(string)

The unit of time.

value
integer

The value of the duration.

SendWindow

A send window time for a notification. Describes a single day.

Attributes

day
enum(string)

The day of the week.

from
string(time)

The start time of the send window.

type
enum(string)

The type of send window.

until
string(time)

The end time of the send window.

Workflow

A workflow object.

Attributes

active
boolean

Whether the workflow is active in the current environment. (read-only).

categories
string[]

A list of categories that the workflow belongs to.

conditions

A conditions object that describes one or more conditions to be met for the workflow to be executed. (optional).

created_at
string(date-time)

The timestamp of when the workflow was created. (read-only).

deleted_at
string(date-time)

The timestamp of when the workflow was deleted. (read-only).

description
string

An arbitrary string attached to a workflow object. Useful for adding notes about the workflow for internal purposes. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the workflow exists. (read-only).

key
string

The unique key string for the workflow object. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.

name
string

A name for the workflow. Must be at maximum 255 characters in length.

settings
object

A map of workflow settings.

sha
string

The SHA hash of the workflow data. (read-only).

A list of workflow step objects in the workflow.

trigger_data_json_schema
object(any)

A JSON schema for the expected structure of the workflow trigger's data payload. Used to validate trigger requests. Read more in the docs.

trigger_frequency
enum(string)

The frequency at which the workflow should be triggered. One of: once_per_recipient, once_per_recipient_per_tenant, every_trigger. Defaults to every_trigger. Read more in docs.

updated_at
string(date-time)

The timestamp of when the workflow was last updated. (read-only).

valid
boolean

Whether the workflow and its steps are in a valid state. (read-only).

WorkflowStep

A step within a workflow. Each workflow step, regardless of its type, share a common set of core attributes (type, ref, name, description, conditions).

Attributes

WorkflowStep
7 possible types

A step within a workflow. Each workflow step, regardless of its type, share a common set of core attributes (type, ref, name, description, conditions).

WorkflowBatchStep

A batch function step. Read more in the docs.

Attributes

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

settings
object

The settings for the batch step.

type
enum(string)

The type of the workflow step.

WorkflowBranchStep

A branch function step. Read more in the docs.

Attributes

branches
WorkflowBranchStepBranch[]

A list of workflow branches to be evaluated.

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

type
enum(string)

The type of step.

WorkflowChannelStep

A channel step within a workflow. Read more in the docs.

Attributes

channel_group_key
string

The key of the channel group to which the channel step will be sending a notification. A channel step can have either a channel key or a channel group key, but not both.

channel_key
string

The key of the channel to which the channel step will be sending a notification. A channel step can have either a channel key or a channel group key, but not both.

channel_overrides
5 possible types

A map of channel overrides for the channel step.

conditions

A set of conditions to be evaluated for this channel step.

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

send_windows

A list of send window objects. Must include one send window object per day of the week.

template
6 possible types

The message template for the channel step. The shape of the template depends on the type of the channel you'll be sending to. See below for definitions of each channel type template: email, in-app, SMS, push, chat, and webhook.

type
enum(string)

The type of the workflow step.

WorkflowDelayStep

A delay function step. Read more in the docs.

Attributes

conditions

A set of conditions to be evaluated for this delay step.

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

settings
object

The settings for the delay step. Both fields can be set to compute a delay where delay_for is an offset from the delay_until_field_path.

type
enum(string)

The type of the workflow step.

WorkflowFetchStep

A fetch function step. Read more in the docs.

Attributes

conditions

A conditions object that describes one or more conditions to be met in order for the step to be executed.

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

A request template for a fetch function step.

type
enum(string)

The type of the workflow step.

WorkflowThrottleStep

A throttle function step. Read more in the docs.

Attributes

conditions

A conditions object that describes one or more conditions to be met in order for the step to be executed.

description
string

An arbitrary string attached to a workflow step. Useful for adding notes about the workflow for internal purposes.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

settings
object

The settings for the throttle step.

type
enum(string)

The type of the workflow step.

WorkflowTriggerWorkflowStep

A workflow trigger function step. Read more in the docs.

Attributes

conditions

A set of conditions to be evaluated for this trigger workflow step.

description
string

A description for the workflow step.

name
string

A name for the workflow step.

ref
string

The reference key of the workflow step. Must be unique per workflow.

settings
object

The settings for the workflow trigger workflow step.

type
enum(string)

The type of the workflow step.

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.

Endpoints
GET/v1/email_layouts
GET/v1/email_layouts/{email_layout_key}
PUT/v1/email_layouts/{email_layout_key}
PUT/v1/email_layouts/{email_layout_key}/validate

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.

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.

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.

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.

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.

annotate
boolean

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

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.

Request body

email_layout
EmailLayoutRequest
Required

A request to update or create an email layout.

Returns

WrappedEmailLayoutResponse

Wraps the EmailLayout response under the email_layout key.

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.

Request body

email_layout
EmailLayoutRequest
Required

A request to update or create an email layout.

Returns

WrappedEmailLayoutResponse

Wraps the EmailLayout response under the email_layout key.

EmailLayout

A versioned email layout used within an environment.

Attributes

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.

html_layout
string

The complete HTML content of the email layout.

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.

Translations

Translations support localization in Knock. They hold the translated content for a given locale, which you can reference in your message templates with the t Liquid function filter.

You can retrieve, update, and create translations as well as list all translations in a given environment. Translations are identified by their locale code + an optional namespace.

Endpoints
GET/v1/translations
GET/v1/translations/{locale_code}
PUT/v1/translations/{locale_code}
PUT/v1/translations/{locale_code}/validate

List translations

Returns a paginated list of translations available in a given environment. The translations are returned in alphabetical order by locale code.

Endpoint

GET/v1/translations

Query parameters

locale_code
string

A specific locale code to filter translations for.

namespace
string

A specific namespace to filter translations for.

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

environment
string

The environment slug.

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

PaginatedTranslationResponse

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

Get translation

Retrieve a translation by its locale and namespace, in a given environment.

Endpoint

GET/v1/translations/{locale_code}

Path parameters

locale_code
string

A specific locale code to filter translations for.

Query parameters

environment
string

The environment slug.

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

namespace
string

A specific namespace to filter translations for.

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

WrappedTranslationResponse

Wraps the Translation response under the translation key.

Upsert translation

Updates a translation of a given locale code + namespace, or creates a new one if it does not yet exist.

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

Endpoint

PUT/v1/translations/{locale_code}

Path parameters

locale_code
string

A locale code of the translation.

Query parameters

environment
string

The environment slug.

namespace
string

An optional namespace that identifies the translation.

format
enum(string)

Optionally specify the returned content format. Supports 'json' and 'po'. Defaults to 'json'.

annotate
boolean

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

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.

Request body

translation
TranslationRequest
Required

A translation object with a content attribute used to update or create a translation.

Returns

WrappedTranslationResponse

Wraps the Translation response under the translation key.

Validate translation

Validates a translation payload without persisting it.

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

Endpoint

PUT/v1/translations/{locale_code}/validate

Path parameters

locale_code
string

The translation's locale code.

Query parameters

environment
string

The environment slug.

Request body

translation
TranslationRequest
Required

A translation object with a content attribute used to update or create a translation.

Returns

WrappedTranslationResponse

Wraps the Translation response under the translation key.

Translation

A translation object.

Attributes

content
string

A JSON encoded string containing the key-value pairs of translation references and translation strings.

format
enum(string)

Indicates whether content is a JSON encoded object string or a string in the PO format.

inserted_at
string(date-time)

The timestamp of when the translation was created.

locale_code
string

The locale code for the translation object.

namespace
string

An optional namespace for the translation to help categorize your translations.

updated_at
string(date-time)

The timestamp of when the translation was last updated.

Partials

Partials are reusable pieces of content you can use across your channel templates.

You can retrieve, update, and create partials as well as list all partials in a given environment. Partials are identified by their unique partial key.

Endpoints
GET/v1/partials
GET/v1/partials/{partial_key}
PUT/v1/partials/{partial_key}
PUT/v1/partials/{partial_key}/validate

List partials

List all partials for a given environment.

Endpoint

GET/v1/partials

Query parameters

environment
string

The environment slug.

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

PaginatedPartialResponse

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

Get a partial

Get a partial by its key.

Endpoint

GET/v1/partials/{partial_key}

Path parameters

partial_key
string

The key of the partial to retrieve.

Query parameters

environment
string

The environment slug.

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 partial is a reusable piece of content that can be used in a template.

Upsert a partial

Updates a partial of a given key, or creates a new one if it does not yet exist.

Note: this endpoint only operates on partials in the “development” environment.

Endpoint

PUT/v1/partials/{partial_key}

Path parameters

partial_key
string

The key of the partial to upsert.

Query parameters

environment
string

The environment slug.

annotate
boolean

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

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.

Request body

partial
PartialRequest
Required

A partial object with attributes to update or create a partial.

Returns

WrappedPartialResponse

Wraps the Partial response under the partial key.

Validate a partial

Validates a partial payload without persisting it.

Note: this endpoint only operates on partials in the “development” environment.

Endpoint

PUT/v1/partials/{partial_key}/validate

Path parameters

partial_key
string

The key of the partial to validate.

Query parameters

environment
string

The environment slug.

Request body

partial
PartialRequest
Required

A partial object with attributes to update or create a partial.

Returns

WrappedPartialResponse

Wraps the Partial response under the partial key.

Partial

A partial is a reusable piece of content that can be used in a template.

Attributes

content
string

The partial content.

description
string

An arbitrary string attached to a partial object. Useful for adding notes about the partial for internal purposes. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the partial exists.

icon_name
string

The name of the icon to be used in the visual editor.

inserted_at
string(date-time)

The timestamp of when the partial was created.

key
string

The unique key string for the partial object. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.

name
string

A name for the partial. Must be at maximum 255 characters in length.

type
enum(string)

The partial type. One of 'html', 'json', 'markdown', 'text'.

updated_at
string(date-time)

The timestamp of when the partial was last updated.

valid
boolean

Whether the partial and its content are in a valid state.

visual_block_enabled
boolean

Indicates whether the partial can be used in the visual editor. Only applies to HTML partials.

Commits

To version the changes you make in your environments, Knock uses a commit model. When you make changes to a workflow, a layout, or a translation, you will need to commit them in your development environment, then promote to subsequent environments before those changes will appear in the respective environments.

You can retrieve all commits in a given environment, or show the details of one single commit based on the target commit id.

Endpoints
GET/v1/commits
PUT/v1/commits
GET/v1/commits/{id}
PUT/v1/commits/promote
PUT/v1/commits/{id}/promote

List commits

Returns a paginated list of commits in a given environment. The commits are ordered from most recent first.

Endpoint

GET/v1/commits

Query parameters

environment
string

The environment slug.

promoted
boolean

Whether to show commits in the given environment that have not been promoted to the subsequent environment (false) or commits which have been promoted (true).

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

PaginatedCommitResponse

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

Commit all changes

Commit all changes across all resources in the development environment.

Endpoint

PUT/v1/commits

Query parameters

environment
string

The environment slug.

commit_message
string

An optional message to include in a commit.

Returns

CommitAllResponse

The response from committing all changes.

Get a commit

Retrieve a single commit by its ID.

Endpoint

GET/v1/commits/{id}

Path parameters

id
string(uuid)

The id of the commit to retrieve.

Returns

A commit is a change to a resource within an environment, made by an author.

Promote all changes

Promote all changes across all resources to the target environment from its preceding environment.

Endpoint

PUT/v1/commits/promote

Query parameters

to_environment
string

A slug of the target environment to which you want to promote all changes from its directly preceding environment.

For example, if you have three environments “development”, “staging”, and “production” (in that order), setting this param to “production” will promote all commits not currently in production from staging.

Note: This must be a non-development environment.

Returns

PromoteAllResponse

The response from promoting all changes.

Promote one commit

Promotes one change to the subsequent environment.

Endpoint

PUT/v1/commits/{id}/promote

Path parameters

id
string

The target commit ID to promote to the subsequent environment.

Returns

WrappedCommitResponse

Wraps the Commit response under the commit key.

Commit

A commit is a change to a resource within an environment, made by an author.

Attributes

commit_author
CommitAuthor

The author of the commit.

commit_message
string

The optional message about the commit.

created_at
string(date-time)

The timestamp of when the commit was created.

environment
string

The environment of the commit.

id
string(uuid)

The unique identifier for the commit.

resource
CommitResource

The resource object associated with the commit.

updated_at
string(date-time)

The timestamp of when the commit was last updated.

Variables

Variables are used to store shared attributes for your workflows and templates at the environment level.

Endpoints
GET/v1/variables

List variables

Returns a paginated list of variables for a given environment.

Endpoint

GET/v1/variables

Query parameters

environment
string

The environment slug.

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

PaginatedVariableResponse

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

Variable

An environment variable object.

Attributes

description
string

The description of the variable.

inserted_at
string(date-time)

The timestamp of when the variable was created.

key
string

The key of the variable.

type
enum(string)

The type of the variable.

updated_at
string(date-time)

The timestamp of when the variable was last updated.

value
string

The value of the variable.

Templates

Templates represent the templated contents of a message sent to an individual recipient on a specific channel.

There are no endpoints for working directly with templates, instead you must do so through modifying a workflow.

ChatTemplate

A chat template.

Attributes

json_body
string

A JSON template for the chat notification message payload. Only present if not using the markdown body.

markdown_body
string

The markdown body of the chat template.

summary
string

The summary of the chat template. Used by some chat apps in their push notifications.

EmailTemplate

An email message template.

Attributes

html_body
string

An HTML template for the email body. Either html_body or visual_blocks must be provided.

settings
EmailTemplateSettings

The settings for the email template. Can be omitted.

subject
string

The subject of the email.

text_body
string

A text template for the email body. Only present if opted out from autogenerating it from the HTML template.

visual_blocks
object[]

The visual blocks of the email. Either html_body or visual_blocks must be provided.

PushTemplate

A push notification template.

Attributes

settings
object

The settings for the push template. Can be omitted.

text_body
string

The body of the push notification.

title
string

The title of the push notification.

SmsTemplate

An SMS template.

Attributes

settings
object

The settings for the SMS template. Can be omitted.

text_body
string

The message of the SMS.

InAppFeedTemplate

An in-app feed template.

Attributes

action_buttons
object[]

The action buttons of the in-app feed message.

action_url
string

The URL to navigate to when the in-app feed is tapped. Can be omitted for multi-action templates, where the action buttons will be used instead.

markdown_body
string

The markdown body of the in-app feed.

RequestTemplate

A request template for a fetch function step.

Attributes

body
string

The body of the request. Only used for POST or PUT requests.

headers
object[]

A list of key-value pairs for the request headers. Each object should contain key and value fields with string values.

method
enum(string)

The HTTP method of the request.

query_params
object[]

A list of key-value pairs for the request query params. Each object should contain key and value fields with string values.

url
string

The URL of the request.

WebhookTemplate

A webhook template. By default, a webhook step will use the request settings you configured in your webhook channel. You can override this as you see fit on a per-step basis.

Attributes

body
string

The body of the request. Only used for POST or PUT requests.

headers
object[]

A list of key-value pairs for the request headers. Each object should contain key and value fields with string values.

method
enum(string)

The HTTP method of the webhook.

query_params
object[]

A list of key-value pairs for the request query params. Each object should contain key and value fields with string values.

url
string

The URL of the webhook.

Message Types

A message type is a schema for a message that maps to a UI component or element within your application.

Endpoints
GET/v1/message_types
GET/v1/message_types/{message_type_key}
PUT/v1/message_types/{message_type_key}
PUT/v1/message_types/{message_type_key}/validate

List message types

Returns a paginated list of message types available in a given environment.

Endpoint

GET/v1/message_types

Query parameters

environment
string

The environment slug.

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

PaginatedMessageTypeResponse

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

Get message type

Retrieve a message type by its key, in a given environment.

Endpoint

GET/v1/message_types/{message_type_key}

Path parameters

message_type_key
string

The key of the message type to retrieve.

Query parameters

environment
string

The environment slug.

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 message type is a schema for a message that maps to a UI component or element within your application.

Upsert message type

Updates a message type, or creates a new one if it does not yet exist.

Note: this endpoint only operates in the development environment.

Endpoint

PUT/v1/message_types/{message_type_key}

Path parameters

message_type_key
string

The key of the message type to upsert.

Query parameters

environment
string

The environment slug.

annotate
boolean

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

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.

Request body

message_type
MessageTypeRequest
Required

A request to create a message type.

Returns

WrappedMessageTypeResponse

Wraps the MessageType response under the message_type key.

Validate message type

Validates a message type payload without persisting it.

Note: this endpoint only operates on message types in the development environment.

Endpoint

PUT/v1/message_types/{message_type_key}/validate

Path parameters

message_type_key
string

The key of the message type to validate.

Query parameters

environment
string

The environment slug.

Request body

message_type
MessageTypeRequest
Required

A request to create a message type.

Returns

WrappedMessageTypeResponse

Wraps the MessageType response under the message_type key.

MessageType

A message type is a schema for a message that maps to a UI component or element within your application.

Attributes

archived_at
string(date-time)

The timestamp of when the message type was deleted.

created_at
string(date-time)

The timestamp of when the message type was created.

deleted_at
string(date-time)

The timestamp of when the message type was deleted.

description
string

An arbitrary string attached to a message type object. Useful for adding notes about the message type for internal purposes. Maximum of 280 characters allowed.

environment
string

The environment of the message type.

icon_name
string

The icon name of the message type.

key
string

The unique key string for the message type object. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.

name
string

A name for the message type. Must be at maximum 255 characters in length.

owner
enum(string)

The owner of the message type.

preview
string

An HTML/liquid template for the message type preview.

semver
string

The semantic version of the message type.

sha
string

The SHA hash of the message type.

updated_at
string(date-time)

The timestamp of when the message type was last updated.

valid
boolean

Whether the message type is valid.

The variants of the message type.

MessageTypeVariant

A variant of a message type.

Attributes

fields
object[]

The field types available for the variant.

key
string

The unique key string for the variant. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.

name
string

A name for the variant. Must be at maximum 255 characters in length.

MessageTypeTextField

A text field used in a message type.

Attributes

key
string

The unique key of the field.

label
string

The label of the field.

settings
object

Settings for the text field.

type
enum(string)

The type of the field.