Skip to main content

Copy Gallery Template

Copy a gallery template directly into your organization's custom templates. The endpoint creates a new custom template populated with the gallery template's HTML and returns the new template's id. That id can be used as template_id when creating an email campaign or passed to PATCH /templates/:id to customize the design before sending.

This is the easiest way to use a starter design programmatically. It replaces the old 3-call flow (GET gallery template → extract HTML → POST custom template) with a single request.

Endpoint

POST /templates/gallery/:id/copy

Returns: 201 Created

Headers

HeaderValueRequired
AuthorizationBearer <your-api-key>Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeDescription
idstringGallery template ID (from Browse Gallery or Get Gallery Template).

Body Parameters

The request body is optional. You can send {} or omit the body entirely.

ParameterTypeRequiredDescription
namestringNoName for the new custom template. Max 100 characters. Defaults to the gallery template's name.

Response

{
"id": "0192a1b2-c3d4-7e5f-9000-abcdef123456"
}
FieldTypeDescription
idstringID of the new custom template. Use this as template_id when creating an email campaign, or with PATCH /templates/:id to customize further.

Examples

Copy with default name

curl -X POST "https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy" \
-H "Authorization: Bearer be_your_api_key" \
-H "Content-Type: application/json" \
-d '{}'

Copy with custom name

curl -X POST "https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy" \
-H "Authorization: Bearer be_your_api_key" \
-H "Content-Type: application/json" \
-d '{"name": "Spring Sale 2026"}'

The typical workflow for launching a campaign from a gallery design:

  1. Browse the gallery via GET /templates/gallery to find a suitable starter.
  2. Copy it via this endpoint (POST /templates/gallery/:id/copy) — get back { id }.
  3. Pass that id as template_id to POST /email/campaigns to create the campaign.
  4. Schedule delivery with POST /email/campaigns/:id/send (include scheduled_at to send at a specific time).
const API = "https://api.arsel.sa/v1";
const headers = {
Authorization: "Bearer be_your_api_key",
"Content-Type": "application/json",
};

// 1. Find a starter (grab the first result)
const { data } = await (
await fetch(`${API}/templates/gallery?search=welcome&limit=1`, { headers })
).json();
const galleryId = data[0].id;

// 2. Copy it into custom templates
const { id: templateId } = await (
await fetch(`${API}/templates/gallery/${galleryId}/copy`, {
method: "POST",
headers,
body: JSON.stringify({ name: "Welcome Campaign 2026" }),
})
).json();

// 3. Create the campaign using the copied template
const { id: campaignId } = await (
await fetch(`${API}/email/campaigns`, {
method: "POST",
headers,
body: JSON.stringify({
name: "Welcome Campaign",
subject: "Welcome to Arsel!",
from: "hello@yourdomain.com",
from_name: "Your Brand",
template_id: templateId,
list_ids: ["your-list-id"],
}),
})
).json();

// 4. Schedule it for a specific time (UTC)
await fetch(`${API}/email/campaigns/${campaignId}/send`, {
method: "POST",
headers,
body: JSON.stringify({ scheduled_at: "2026-04-28T09:00:00.000Z" }),
});

Error Responses

{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid or missing API key"
}