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.

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

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

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

--keystring

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

--namestring

The name for the email layout. 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 email layout to Knock after creating it locally. Defaults to false.

--forceboolean

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

--environmentstring

The environment to use. Defaults to development.

--allboolean

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.

--email-layouts-dirdirectory

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

--commitboolean

Push and commit 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 email layouts to the target environment. Defaults to false.

--email-layouts-dirdirectory

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

--allboolean

Whether to validate all email layouts. Defaults to false.

--email-layouts-dirdirectory

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.

New chat