Message types

Commands for managing message types in the Knock CLI.

#

Message type commands enable you to manage in-app message types in your Knock account from the CLI.

Message type file structure

#

When message types are pulled from Knock, they are stored in directories named by their message type key. Each message type directory contains a message_type.json file that describes the message type's schema and configuration, and a preview.html file that contains the HTML preview template.

If you're migrating your local message type files into Knock, you can arrange them using the example file structure above.

knock message-type list [flags]

#

Display all in-app message types for an environment. Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--limitnumber

The total number to fetch per page.

--afterstring

Fetches all entries after this cursor.

--beforestring

Fetches all entries before this cursor.

--jsonstring

Format output as json.

knock message-type new [flags]

#

Create a new message type with a minimal configuration.

The command will create a new message type directory in your local file system. By default, this will be in the message-types resource directory set by your knock.json file, or the current working directory if not configured.

Flags

--keystring

The key for the message type. If not provided, will be prompted or inferred from the message type directory name.

--namestring

The name for the message type. If not provided, will be generated from the key.

--environmentstring

The environment to use. Defaults to development.

--branchstring

The branch to use. Defaults to the main branch.

--pushboolean

Push the message type to Knock after creating it locally. Defaults to false.

--forceboolean

Overwrites an existing message type directory without prompting for confirmation. Defaults to false.

knock message-type get <message_type_key> [flags]

#

Display a single in-app message type from an environment.

Use an --environment flag to specify the target environment; if omitted, the Knock CLI defaults to the development environment.

Flags

--environmentstring

The environment to use. Defaults to development.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--jsonstring

Format output as json.

knock message-type pull <message_type_key> [flags]

#

Pull one or more in-app message types from an environment into a local file system. Knock CLI will create a new message type directory or update the existing message type directory in the local file system.

By default this command will resolve to the message types resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --message-types-dir flag.

Note: if pulling the target message type for the first time (or all message types), Knock CLI will ask to confirm before writing to the local file system.

See the Message type file structure section for details on how message type files are organized.

Flags

--environmentstring

The environment to use. Defaults to development.

--allboolean

Whether to pull all in-app message types from the specified environment into the target directory path set by --message-types-dir. Defaults to false.

When used, all contents in the target directory will be erased and replaced with all message types from the specified environment.

--message-types-dirdirectory

Specifies which target directory path to pull all in-app message types into. Only available to be used with --all, and defaults to the current working directory.

--hide-uncommitted-changesboolean

Should any uncommitted changes be hidden? Defaults to false.

--forceboolean

Removes the confirmation prompt. Defaults to false.

knock message-type push <message_type_key> [flags]

#

Push one or more message types from a local file system to Knock. Knock will update an existing message type by the matching message type key, or create a new message type if it does not exist yet.

By default this command will resolve to the message types resource directory via your knock.json file. When not set, will use the current working directory as the default. In the case of the --all flag, the target directory path will be resolved via your knock.json file or the --message-types-dir flag.

Note:

  • The message-type push command only pushes message types into the development environment.
  • You must be directly above the target message type directory when running the message-type push command, so the CLI can locate the message_type.json file.
  • You can also pass in the --commit flag (with an optional --commit-message flag) to commit the upserted changes immediately.

See the Message type file structure section for details on how message type files are organized.

Flags

--commitboolean

Push and commit the message type(s) at the same time. Defaults to false.

-m, --commit-messagestring

The commit message to pass when using the --commit flag.

--allboolean

Whether to push all message types from the target directory path set by --message-types-dir. Defaults to false.

--message-types-dirdirectory

Specifies the target directory path to find and push all message types from. Only available to be used with --all, and defaults to the current working directory.

knock message-type validate <message_type_key> [flags]

#

Validate one or more message types from a local file system. Knock will validate the given message type payload in the same way as it would with the message-type push command, except without persisting those changes.

Note: Validating a message type is only done against the development environment.

Flags

--allboolean

Whether to validate all message types from the target directory path set by --message-types-dir. Defaults to false.

--message-types-dirdirectory

Specifies the target directory path to find and validate all message types from. Only available to be used with --all, and defaults to the current working directory.

New chat