Management API Reference
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.
Workflows
To define a logical flow of your notifications, you create a workflow consisting of workflow 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.
Workflow definition
Attributes
WorkflowSettings definition
WorkflowStep definition
All workflow steps, regardless of its type, share a common set of core attributes.
Common attributes
ChannelStep definition
Contains all properties of the WorkflowStep
and additionally:
Attributes
Email template attributes
In-app template attributes
SMS template attributes
Push template attributes
Chat template attributes
Webhook template attributes
By default, a webhoook 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
in the template
field.
ChannelSettings definition
Contains all settings that are applied to a channel integration. Used to override a channel's default settings at the ChannelStep
level in a workflow.
Chat channel settings attributes
Email channel settings attributes
In-app feed channel settings attributes
SMS channel settings attributes
SendWindow definition
Attributes
Delay step definition
Contains all properties of the WorkflowStep
and additionally:
Attributes
Must set either settings.delay_for
or settings.delay_until_field_path
.
Batch step definition
Contains all properties of the WorkflowStep
and additionally:
Attributes
Must set either settings.batch_window
or settings.batch_until_field_path
.
Branch step definition
Contains all properties of the WorkflowStep
, but cannot have conditions
and additionally:
Attributes
WorkflowBranch definition
Fetch step definition
Contains all properties of the WorkflowStep
and additionally:
Attributes
List all workflows
Returns a paginated list of workflows available in a given environment. The workflows are returned in alpha sorted order by its key.
Endpoint
Query parameters
Returns
A paginated list of workflows
Get a workflow
Retrieve a workflow by its key and namespace, in a given environment.
Endpoint
Path parameters
Query parameters
Returns
A complete workflow
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
Path parameters
Query parameters
Body parameters
Returns
An upserted workflow
Run a workflow
Runs the latest version of a saved workflow.
Endpoint
Rate limitTier 2
Path parameters
Body parameters
Returns
A workflow run ID
Validate a workflow
Validates a workflow payload without persisting it.
Note: Validating a workflow is only done in the development environment context.
Endpoint
Path parameters
Body parameters
Returns
A validated workflow object, if valid. Note: some read-only fields will be empty as they are generated by the system when persisted.
Activate a workflow
Activates (or deactivates) a workflow in a given environment.
Note: This immediately enables or disables a workflow in a given environment without needing to go through environment promotion.
Endpoint
Path parameters
Body parameters
Returns
workflow
A workflow object.
Email layouts
Email layouts wrap email message templates to share consistent design components between the email notifications that your recipients receive.
You can retrieve, update, and create email layouts as well as listing all in a given environment. Email layouts are identified by their unique key.
EmailLayout definition
Attributes
EmailLayoutFooterLink Attributes
List all email layouts
Returns a paginated list of email layouts available in a given environment.
Endpoint
Query parameters
Returns
A paginated list of email layouts
Get an email layout
Retrieve an email layout by its key, in a given environment.
Endpoint
Path parameters
Query parameters
Returns
An email layout object
Upsert an 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
Path parameters
Query parameters
Body parameters
Returns
An email layout.
Validate an email layout
Validates an email layout payload without persisting it.
Note: this endpoint only operates in the “development” environment.
Endpoint
Path parameters
Body parameters
Returns
An email layout
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.
Translation definition
Attributes
List all translations
Returns a paginated list of translations available in a given environment. The translations are returned in alpha-sorted order by locale code.
Endpoint
Query parameters
Returns
A paginated list of translations
Get a translation
Retrieve a translation by its locale and namespace, in a given environment.
Endpoint
Path parameters
Query parameters
Returns
A translation object
Upsert a 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
Path parameters
Query parameters
Body parameters
Returns
A translation object
Validate a translation
Validates a translation payload without persisting it.
Note: this endpoint only operates on translations in the “development” environment.
Endpoint
Path parameters
Body parameters
Returns
A translation object
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.
Partial definition
Attributes
List all partials
Returns a paginated list of partials available in a given environment. The partials are returned in alpha-sorted order by key.
Endpoint
Query parameters
Returns
A paginated list of partials
Get a partial
Retrieve a partial by its locale and namespace, in a given environment.
Endpoint
Path parameters
Query parameters
Returns
A partial object
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
Path parameters
Query parameters
Body parameters
Returns
A partial object
Validate a partial
Validates a partial payload without persisting it.
Note: this endpoint only operates on partials in the “development” environment.
Endpoint
Path parameters
Body parameters
Returns
A partial object
Commits
To version the changes you make in your environments, Knock uses a commit model. When you make changes to a workflow, a layout, a translation or an event action mapping, 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.
Commit definition
Attributes
CommitResource attributes
CommitAuthor attributes
List all commits
Returns a paginated list of commits in a given environment. The commits are ordered from most recent first.
Endpoint
Query parameters
Returns
A paginated list of commits
Get commit
Commit all changes
Promote all changes
Promote all changes across all resources to the target environment from its preceding environment.
Endpoint
Query parameters
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 new changes from the staging environment.
Note: This must be a non-development environment.
Returns
result
A "success" message.