Docs
/
/

Environments mAPI reference

Complete reference documentation for the Environments resource.

Environments

#

Knock uses the concept of environments to ensure logical separation of your data. Your account starts with a single production environment. If you've enabled environments, you can create resources in your development environment and promote them to higher environments.

List environments

#

Returns a paginated list of visible environments in catalog order.

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.

A list of entries.

created_at
string(date-time)
Required

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
Required

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

order
integer
Required

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)
Required

Who created the environment. system environments, such as Development and Production, are defined by Knock: they can't be deleted, and only Production can be renamed. user environments were created by you and can be renamed or deleted.

systemuser
slug
string
Required

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

updated_at
string(date-time)
Required

The timestamp of when the environment was last updated.

visibility
enum(string)
Required

Whether the environment is part of the account catalog.

visiblehidden
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 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.

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)

Who created the environment. system environments, such as Development and Production, are defined by Knock: they can't be deleted, and only Production can be renamed. user environments were created by you and can be renamed or deleted.

systemuser
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.

visibility
enum(string)

Whether the environment is part of the account catalog.

visiblehidden

Create an environment

#

Creates an environment. The slug is derived from the name. Without preceding_environment, the environment is placed just before Production. Creating an environment also creates its public and secret API keys and copies the project's variables, channel and source settings, and preference center into it. Everything committed in the preceding environment is then promoted into it asynchronously, so its content may not be available as soon as this request returns. Requires environments to be enabled on the account.

Endpoint

POST/v1/environments

Request body

hide_pii_data
boolean

Whether to hide PII data in the dashboard for the environment. Read more in the data obfuscation docs.

label_color
string

A 3- or 6-digit hex color code for the environment label in the dashboard. A color is picked at random when omitted.

name
string
Required

A human-readable name for the environment. The environment's slug is derived from it and must be unique in the project.

preceding_environment
string

The slug of the environment the new environment comes directly after. Cannot be the last environment (Production). Defaults to the environment just before Production.

Returns

An environment object.

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)

Who created the environment. system environments, such as Development and Production, are defined by Knock: they can't be deleted, and only Production can be renamed. user environments were created by you and can be renamed or deleted.

systemuser
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.

visibility
enum(string)

Whether the environment is part of the account catalog.

visiblehidden

Delete an environment

#

Deletes an environment you created (owner is user). Every API key in the environment is revoked first, so any integration still using those keys stops working. A deleted environment can't be restored from the API or the dashboard. Knock-defined environments, such as Development and Production, can't be deleted. To delete a branch, use the delete branch endpoint.

Endpoint

DELETE/v1/environments/{environment_slug}

Path parameters

environment_slug
string

The slug of the environment.

Returns

204 No Content

Update an environment

#

Updates an environment. Omitted fields are left unchanged, and at least one field is required. What can change depends on the environment's owner. Environments you create (user) can change name, label_color and hide_pii_data. Renaming one also changes its slug, and the response holds the new slug. Later requests must use the new slug, and permission groups that reference the environment are updated to match. Production can change its name, but its slug stays production. Other Knock-defined environments, such as Development, can only change label_color and hide_pii_data. Sending them a name other than their current one returns an error.

Endpoint

PUT/v1/environments/{environment_slug}

Path parameters

environment_slug
string

The slug of the environment.

Request body

hide_pii_data
boolean

Whether to hide PII data in the dashboard for the environment. Read more in the data obfuscation docs.

label_color
string

A 3- or 6-digit hex color code for the environment label in the dashboard.

name
string

A new name for the environment. Renaming an environment you created also changes its slug. Production keeps its slug. Other Knock-defined environments can't be renamed, and a name other than their current one returns an error.

Returns

An environment object.

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)

Who created the environment. system environments, such as Development and Production, are defined by Knock: they can't be deleted, and only Production can be renamed. user environments were created by you and can be renamed or deleted.

systemuser
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.

visibility
enum(string)

Whether the environment is part of the account catalog.

visiblehidden

Get environment defaults

#

Returns the default settings for an environment. When no defaults have been set, preference_set and both timestamps are null.

Endpoint

GET/v1/environments/{environment_slug}/defaults

Path parameters

environment_slug
string

The slug of the environment to read or update the defaults for.

Returns

The default settings for an environment.

created_at
string(date-time)

The timestamp of when the defaults were first set. Null when no defaults have been set.

A preference set applied to every recipient in the environment unless the recipient overrides it. The __persistence_strategy__ and __strategy__ keys are not supported, because defaults are always replaced in full.

categories
object

A map of category key to a boolean or an object containing channel_types, channels, and conditions.

channel_types
object

A map of channel type to a boolean or an object containing conditions. Valid channel types are email, sms, push, chat, in_app_feed, and http.

channels
object

A map of channel ID to a boolean or an object containing conditions.

commercial_subscribed
2 possible types

Whether the recipient is subscribed to commercial messages, as a boolean or a settings object.

workflows
object

A map of workflow key to a boolean or an object containing channel_types, channels, and conditions.

updated_at
string(date-time)

The timestamp of when the defaults were last updated. Null when no defaults have been set.

Upsert environment defaults

#

Creates or replaces the default settings for an environment. The change applies to the environment immediately, including production. It is not committed or promoted, and concurrent writes are last-write-wins. The preference_set replaces any existing set in full, and null clears it.

Endpoint

PUT/v1/environments/{environment_slug}/defaults

Path parameters

environment_slug
string

The slug of the environment to read or update the defaults for.

Request body

preference_setRequired

A preference set applied to every recipient in the environment unless the recipient overrides it. The __persistence_strategy__ and __strategy__ keys are not supported, because defaults are always replaced in full.

categories
object

A map of category key to a boolean or an object containing channel_types, channels, and conditions.

channel_types
object

A map of channel type to a boolean or an object containing conditions. Valid channel types are email, sms, push, chat, in_app_feed, and http.

channels
object

A map of channel ID to a boolean or an object containing conditions.

commercial_subscribed
2 possible types

Whether the recipient is subscribed to commercial messages, as a boolean or a settings object.

workflows
object

A map of workflow key to a boolean or an object containing channel_types, channels, and conditions.

Returns

The default settings for an environment.

created_at
string(date-time)

The timestamp of when the defaults were first set. Null when no defaults have been set.

A preference set applied to every recipient in the environment unless the recipient overrides it. The __persistence_strategy__ and __strategy__ keys are not supported, because defaults are always replaced in full.

categories
object

A map of category key to a boolean or an object containing channel_types, channels, and conditions.

channel_types
object

A map of channel type to a boolean or an object containing conditions. Valid channel types are email, sms, push, chat, in_app_feed, and http.

channels
object

A map of channel ID to a boolean or an object containing conditions.

commercial_subscribed
2 possible types

Whether the recipient is subscribed to commercial messages, as a boolean or a settings object.

workflows
object

A map of workflow key to a boolean or an object containing channel_types, channels, and conditions.

updated_at
string(date-time)

The timestamp of when the defaults were last updated. Null when no defaults have been set.

EnvironmentDefaultsPreferenceSet

#

A preference set applied to every recipient in the environment unless the recipient overrides it. The __persistence_strategy__ and __strategy__ keys are not supported, because defaults are always replaced in full.

Attributes

categories
object

A map of category key to a boolean or an object containing channel_types, channels, and conditions.

channel_types
object

A map of channel type to a boolean or an object containing conditions. Valid channel types are email, sms, push, chat, in_app_feed, and http.

channels
object

A map of channel ID to a boolean or an object containing conditions.

commercial_subscribed
2 possible types

Whether the recipient is subscribed to commercial messages, as a boolean or a settings object.

workflows
object

A map of workflow key to a boolean or an object containing channel_types, channels, and conditions.

EnvironmentDefaults

#

The default settings for an environment.

Attributes

created_at
string(date-time)

The timestamp of when the defaults were first set. Null when no defaults have been set.

A preference set applied to every recipient in the environment unless the recipient overrides it. The __persistence_strategy__ and __strategy__ keys are not supported, because defaults are always replaced in full.

categories
object

A map of category key to a boolean or an object containing channel_types, channels, and conditions.

channel_types
object

A map of channel type to a boolean or an object containing conditions. Valid channel types are email, sms, push, chat, in_app_feed, and http.

channels
object

A map of channel ID to a boolean or an object containing conditions.

commercial_subscribed
2 possible types

Whether the recipient is subscribed to commercial messages, as a boolean or a settings object.

workflows
object

A map of workflow key to a boolean or an object containing channel_types, channels, and conditions.

updated_at
string(date-time)

The timestamp of when the defaults were last updated. Null when no defaults have been set.

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)

Who created the environment. system environments, such as Development and Production, are defined by Knock: they can't be deleted, and only Production can be renamed. user environments were created by you and can be renamed or deleted.

systemuser
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.

visibility
enum(string)

Whether the environment is part of the account catalog.

visiblehidden
New chat