Create template

Create a template draft that your app can send once it is published.

POSThttps://api.cresca.xyz/api/v1/templates

Requires a full-access key. The template starts as a draft; call Publish template before sending with it. It also appears under Transactional → Templates in the Cresca app, where you can edit it, send a test and see its version history.

Body parameters

namestringrequired

Template name, up to 120 characters, unique in your account.

htmlstringrequired

HTML body. Use {{{VARIABLE}}} placeholders for values your app sends.

aliasstringoptional

A readable id for sending, such as password-reset: lowercase letters, numbers, dashes and underscores, up to 64 characters, unique in your account.

subjectstringoptional

Default subject. Can contain variables.

textstringoptional

Plain-text version. If omitted, it is generated from the HTML at send time.

fromstringoptional

Default sender, for example Acme <hello@acme.com>.

reply_tostringoptional

Default Reply-To address.

preview_textstringoptional

The snippet inbox apps show after the subject, up to 500 characters. Can contain variables.

variablesobject[]optional

Variable definitions: { "key": "NAME", "type": "string", "fallback_value": "there" }. type is string (default) or number. Up to 50. See Templates and variables.

Example

Request
curl -X POST 'https://api.cresca.xyz/api/v1/templates' \
  -H 'Authorization: Bearer cr_live_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Password reset",
  "alias": "password-reset",
  "subject": "Reset your password",
  "from": "Acme <hello@acme.com>",
  "html": "<p>Hi {{{NAME}}},</p><p><a href=\"{{{RESET_LINK}}}\">Reset your password</a>. The link expires in 1 hour.</p>",
  "variables": [
    {
      "key": "NAME",
      "type": "string",
      "fallback_value": "there"
    },
    {
      "key": "RESET_LINK",
      "type": "string"
    }
  ]
}'
Response 201
{
  "object": "template",
  "id": "6713b1f4c2a94e0012ab34cd"
}