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.
message-types/ └── alert-banner/ ├── message_type.json └── preview.html
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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
The total number to fetch per page.
Fetches all entries after this cursor.
Fetches all entries before this cursor.
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
The key for the message type. If not provided, will be prompted or inferred from the message type directory name.
The name for the message type. If not provided, will be generated from the key.
The environment to use. Defaults to development.
The branch to use. Defaults to the main branch.
Push the message type to Knock after creating it locally. Defaults to false.
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
The environment to use. Defaults to development.
Should any uncommitted changes be hidden? Defaults to false.
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
The environment to use. Defaults to development.
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.
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.
Should any uncommitted changes be hidden? Defaults to false.
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 pushcommand only pushes message types into thedevelopmentenvironment. - You must be directly above the target message type directory when running the
message-type pushcommand, so the CLI can locate themessage_type.jsonfile. - You can also pass in the
--commitflag (with an optional--commit-messageflag) to commit the upserted changes immediately.
See the Message type file structure section for details on how message type files are organized.
Flags
Push and commit the message type(s) at the same time. Defaults to false.
The commit message to pass when using the --commit flag.
Whether to push all message types from the target directory path set by --message-types-dir. Defaults to false.
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
Whether to validate all message types from the target directory path set by --message-types-dir. Defaults to false.
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.