Skip to main content
POST
AhaSend Go SDK
The AhaSend API copies a published version into the template’s draft. Access requires templates:write. The API and the dashboard edit the same draft, so the restore replaces the whole draft, including changes made in the dashboard. The template’s name does not change. With publish: true, the API then publishes the draft, as Publish Template does. If the version cannot be published, the API refuses the request and the draft stays as it was. If the publish step fails after the restore, the draft keeps the restored version. If the template changes in the dashboard or through another request while this request runs, the API tries again. If that continues, the API answers 503 with a Retry-After header. Retry the request after that delay. This operation accepts an Idempotency-Key header. A 503 stores no response, so a retry with the same key runs the request again. See Idempotency.

Authorizations

Authorization
string
header
required

API key for authentication. Non-empty Security Requirement values are AhaSend API-key roles. Roles listed within one requirement object are jointly required; separate requirement objects are alternatives.

Headers

Idempotency-Key
string

Optional idempotency key for safe request retries. Must be a unique string for each logical request. An identical request with a completed stored outcome returns the original status and body. An in-progress execution returns 409, a changed method/path/body returns 422, and a released 5xx execution may run again. Keys for non-secret responses expire after 24 hours. API-key create responses include a one-time secret_key, so successful encrypted replay responses for those operations expire after 5 minutes.

Maximum string length: 255

Path Parameters

account_id
string<uuid>
required

Account ID

template_id
string<uuid>
required

Template ID

version_id
string<uuid>
required

Version ID

Body

application/json

Optional. An empty body restores without publishing.

publish
boolean
default:false

Publish the draft once the version is restored into it.

Response

Version restored. The Template object is the working copy, the draft while one is left; has_draft says whether one is.

A transactional template, as one of its copies. Get Template and the answer of every template write give its working copy: its draft while it has one, and its published copy otherwise. Get Published Template and List Templates give its published copy, the one a send uses. has_draft says whether a draft exists.

object
enum<string>
required

Object type identifier

Available options:
template
id
string<uuid>
required

Pass as template_id to Create Template Message to send this template

created_at
string<date-time>
required

When the template was created

updated_at
string<date-time>
required

When the template's name or this copy last changed

name
string
required

Template name, as it appears in the dashboard

subject
string
required

This copy's subject, set on the template page. Empty until one is set. A send uses the published subject, unless it names its own subject.

preheader
string
required

This copy's preview text, which a send of the published copy injects into the delivered HTML when it is set

variables
object[]
required

Every variable this copy's design uses. A send of this template uses the published copy's variables, which Get Published Template returns, and takes the values only from each recipient's substitutions. Every recipient must give a value for each required variable; if one does not, the request is rejected and no message is sent. Each variable's kind says what shape of value to send.

from
object | null
required

This copy's default sender. A send that names no from uses the published copy's. Null when the copy has none; a send of a published copy with none must name one.

Example:
reply_to
object | null
required

This copy's default reply-to address. A send that sets no reply-to, also one that names its own from, uses the published copy's. Null when the copy has none. It has the shape of a send request's reply_to; its name is always empty.

Example:
editor
enum<string>
required

The editor the template is designed with. It never changes after the template is created.

  • advanced: designed in MJML, with the dashboard's advanced editor.
  • simple: designed with the dashboard's simple editor. Its HTML is made from the design and can be read but not changed through the API. A read or write answer of one item gives the design as AhaSend Markup (AhaML) in content.markup; a list does not. A write changes the design with content.markup.
  • html: an HTML template, uploaded or written by hand.
Available options:
advanced,
simple,
html
has_draft
boolean
required

Whether the template has a draft, changes saved in the dashboard or through the API that are not published yet. Get Template returns the draft while one exists.

content
object | null

This copy's content. Null when it has no body, as for the published copy of a template that was never published. List Templates leaves this field out; every other operation that returns a Template sets it.

markup_warnings
object[]

Warnings about the AhaML in content.markup, up to the first 100; empty when there are none. Present only in the answer to a write that carried content.markup.

Maximum array length: 100