Email layouts
Commands for managing email layouts in the Knock CLI.
Email layout commands enable you to manage email layouts in your Knock account from the CLI.
Layout file structure
#When email layouts are pulled from Knock, they are stored in directories named by their layout key.
layouts/ ├── default/ │ ├── html_layout.html │ ├── layout.json │ └── text_layout.txt └── custom-layout/ ├── html_layout.html ├── layout.json └── text_layout.txt
If you're migrating your local layout files into Knock, you can arrange them using the example file structure above and then push them into Knock with a single command using knock layout push --all. Each layout.json file should follow the example shown below; additional information on the Layout structure is defined here.
knock layout list [flags]
#List all email layouts in the 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 layout get <layout_key> [flags]
#Fetches a single email layout, using the key of the email layout.
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 layout new [flags]
#Create a new email layout with a minimal configuration.
The command will create a new layout directory in your local file system. By default, this will be in the layouts resource directory set by your knock.json file, or the current working directory if not configured.
Flags
The key for the email layout. If not provided, will be prompted or inferred from the layout directory name.
The name for the email layout. 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 email layout to Knock after creating it locally. Defaults to false.
Overwrites an existing layout directory without prompting for confirmation. Defaults to false.
knock layout pull <layout_key> [flags]
#Pulls the contents of one or all email layouts from Knock into your local file system. Using <layout_key> you can pull a single email layout specified by the key, or use the --all flag to pull all email layouts from Knock at once.
By default this command will resolve to the email layouts 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 --email-layouts-dir flag.
See the Layout file structure section for details on how layout files are organized.
Flags
The environment to use. Defaults to development.
Whether to pull all email layouts from the specified environment into the target directory path set by --email-layouts-dir. Defaults to false.
When used, all contents in the target directory will be erased and replaced with all email layouts from the specified environment.
Specifies which target directory path to pull all email layouts into. Only available to be used with --all, and defaults to the current working directory.
knock layout push <layout_key> [flags]
#Pushes local email layouts back to Knock and upserts them. Using <layout_key> you can push a single email layout specified by the key, or use the --all flag to push all email layouts from Knock at once.
By default this command will resolve to the email layouts 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 --email-layouts-dir flag.
See the Layout file structure section for details on how layout files are organized.
Flags
Push and commit at the same time. Defaults to false.
The commit message to pass when using the --commit flag.
Whether to push all email layouts to the target environment. Defaults to false.
Specifies the target directory path to find and push all email layouts from. Only available to be used with --all, and defaults to the current working directory.
knock layout validate <layout_key> [flags]
#Validates one or more email layouts. Useful for checking if the layout is valid before running the email_layout push command.
The <layout_key> can be provided to validate a single email layout, or your can use the --all flag to validate all email layouts.
Can only be validated against the development environment.
Flags
Whether to validate all email layouts. Defaults to false.
Specifies the target directory path to find and validate all email layouts from. Only available to be used with --all, and defaults to the current working directory.