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.

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 $ARSEL_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 $ARSEL_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).
async function arsel(path, { method = "GET", body } = {}) {
const response = await fetch(`https://api.arsel.sa/v1${path}`, {
method,
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
"Content-Type": "application/json",
},
body: body && JSON.stringify(body),
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.name}: ${data.message}`);
return data;
}

// 1. Find a starter (grab the first result)
const { data } = await arsel("/templates/gallery?search=welcome&limit=1");
const galleryId = data[0].id;

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

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

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

Error Responses​

{
"status_code": 404,
"name": "not_found",
"message": "Gallery template not found"
}