ahasend messages send --template-id sends.
These commands need CLI v0.3.0 or later. Check your version with
ahasend --version, and upgrade if it is older.Prerequisites
Authenticate with a full API key. Template tasks need these scopes:messages send --template-id needs only the send scope of the sender’s domain, not a templates scope. The shell examples need Bash and jq.
Drafts, Publishing and Versions
Changes to a template go to its draft, the same draft the dashboard edits. Sends use the published copy, so publish the draft with--publish or templates publish before you send. A template created without --publish has only a draft, and sends of it fail until you publish it.
Every publish is kept as a version. A template keeps its 50 most recent versions, and you can restore any of them into the draft.
Create, Publish and Send a Test Template
Save this file aswelcome.html:
welcome.html
hello@example.com. The send uses sandbox mode, so nothing is delivered.
templates get shows the published copy, with the variables a send must supply, each marked required or optional. The template supplies the content, so messages send --template-id takes no content flags; --from and --subject default to the template’s sender and subject. Pass variable values with --global-substitutions or a --recipients file, as the messages commands describe.
Content comes from files. --mjml-file sets the MJML of an advanced template, and --html-file the HTML of an html template; you cannot combine them. --text-file sets the plain text version, which is otherwise made from the HTML. Give --editor when there is neither an MJML nor an HTML file. The editor cannot change after you create the template.
Update the Draft
Continue the script.update sends only the flags you give. Every field but the name goes to the draft; a new name applies at once.
update --publish publishes the whole draft, including changes made in the dashboard; on its own it only publishes. To drop a draft instead, run ahasend templates draft discard "$TEMPLATE_ID" --force. draft get on a template with no draft returns a not found error.
Other update flags:
--subject ""and--preheader ""clear those fields.--fromreplaces the sender address and name together.--clear-fromremoves the sender and the reply-to.--reply-toneeds a template that has a sender.--clear-reply-toremoves the reply-to.--regenerate-textmakes the text version again from the HTML.
List and Restore Versions
Continue the script.versions list shows each published version, newest first, without its content. The script reads the ID of the oldest version, its first publish, from the JSON output’s data array, then shows and restores that version:
--publish, a version that the publish checks refuse is refused before the restore, and the draft is left as it was.
Delete the Test Template
Finish the script by deleting the template it created. Sends of a deleted template fail.ahasend templates list and delete it with templates delete.
templates delete, templates draft discard and templates versions restore ask for confirmation first; see prompts.
Command Flags
These flags come from the CLI’s--help. All commands also accept the global flags.

