Appearance
Publish a template
Take a draft live so it can be sent.
http
POST /v1/templates/{id}/publishRequires a Full access API key.
{id} is the template's id or its alias (the slug) — both resolve to the same template.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The template id or its alias. |
Example
bash
curl -X POST "https://api.sendgrail.com/v1/templates/$TEMPLATE_ID/publish" \
-H "Authorization: Bearer $SENDGRAIL_API_KEY"js
const res = await fetch(
`https://api.sendgrail.com/v1/templates/${id}/publish`,
{
method: 'POST',
headers: { Authorization: `Bearer ${process.env.SENDGRAIL_API_KEY}` },
},
);
const template = await res.json();Response
Just the id — fetch the full object with Get a template to see the new status and published_at.
json
{
"object": "template",
"id": "d3f8c2a1-6b47-4e9a-b25c-1f0e7a9d4c83"
}What publishing does
- Flips the template's
statusfromdrafttopublishedand stampspublished_at. - Only a published template can be sent. A send call that references a draft is rejected — publish it first.
- Idempotent. Publishing an already-published template is fine; it simply re-stamps and returns the same id.
Once published, send with it from POST /v1/emails.
Errors
A template belonging to another team answers 404, by id or alias. A Sending access key gets 403. See Errors.