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 published copy; has_draft says whether a draft is left.

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 published content last changed

name
string
required

Template name, as it appears in the dashboard

subject
string
required

The published subject, set on the template page. Empty until one is published, and overridden by a send that names its own subject.

preheader
string
required

The published preview text, injected into the delivered HTML when it is set

variables
object[]
required

Every variable the design uses. A send of this template 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.

from
object | null
required

The default sender, used by a send that names no from. Null when the template has none, and then every send must name one.

Example:
reply_to
object | null
required

The default reply-to address, used by a send that sets no reply-to, also one that names its own from. Null when the template 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.
  • 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 Draft returns it.

content
object | null

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