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
| Header | Value | Required |
|---|---|---|
Authorization | Bearer <your-api-key> | Yes |
Content-Type | application/json | Yes |
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Gallery template ID (from Browse Gallery or Get Gallery Template). |
Body Parameters
The request body is optional. You can send {} or omit the body entirely.
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Name for the new custom template. Max 100 characters. Defaults to the gallery template's name. |
Response
{
"id": "0192a1b2-c3d4-7e5f-9000-abcdef123456"
}
| Field | Type | Description |
|---|---|---|
id | string | ID 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
- JavaScript
- Python
- C#
- PHP
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 '{}'
const response = await fetch(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer be_your_api_key",
},
body: JSON.stringify({}),
},
);
const { id } = await response.json();
console.log(id); // new custom template ID
import requests
response = requests.post(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer be_your_api_key",
},
json={},
)
data = response.json()
print(data["id"]) # new custom template ID
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer be_your_api_key");
var json = "{}";
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
content
);
Console.WriteLine(await response.Content.ReadAsStringAsync());
// {"id":"..."}
<?php
$ch = curl_init("https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer be_your_api_key"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{}');
$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data["id"];
curl_close($ch);
Copy with custom name
- cURL
- JavaScript
- Python
- C#
- PHP
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"}'
const response = await fetch(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer be_your_api_key",
},
body: JSON.stringify({ name: "Spring Sale 2026" }),
},
);
const { id } = await response.json();
console.log(id); // new custom template ID
import requests
response = requests.post(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer be_your_api_key",
},
json={"name": "Spring Sale 2026"},
)
data = response.json()
print(data["id"]) # new custom template ID
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer be_your_api_key");
var payload = new { name = "Spring Sale 2026" };
var json = System.Text.Json.JsonSerializer.Serialize(payload);
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy",
content
);
Console.WriteLine(await response.Content.ReadAsStringAsync());
// {"id":"..."}
<?php
$ch = curl_init("https://api.arsel.sa/v1/templates/gallery/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a/copy");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer be_your_api_key"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["name" => "Spring Sale 2026"]));
$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data["id"];
curl_close($ch);
End-to-end: Use a gallery template in a campaign
The typical workflow for launching a campaign from a gallery design:
- Browse the gallery via
GET /templates/galleryto find a suitable starter. - Copy it via this endpoint (
POST /templates/gallery/:id/copy) — get back{ id }. - Pass that
idastemplate_idtoPOST /email/campaignsto create the campaign. - Schedule delivery with
POST /email/campaigns/:id/send(includescheduled_atto send at a specific time).
- JavaScript
- Python
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" }),
});
import requests
API = "https://api.arsel.sa/v1"
headers = {"Authorization": "Bearer be_your_api_key"}
# 1. Find a starter (grab the first result)
resp = requests.get(
f"{API}/templates/gallery",
headers=headers,
params={"search": "welcome", "limit": 1},
)
gallery_id = resp.json()["data"][0]["id"]
# 2. Copy it into custom templates
resp = requests.post(
f"{API}/templates/gallery/{gallery_id}/copy",
headers=headers,
json={"name": "Welcome Campaign 2026"},
)
template_id = resp.json()["id"]
# 3. Create the campaign using the copied template
resp = requests.post(
f"{API}/email/campaigns",
headers=headers,
json={
"name": "Welcome Campaign",
"subject": "Welcome to Arsel!",
"from": "hello@yourdomain.com",
"from_name": "Your Brand",
"template_id": template_id,
"list_ids": ["your-list-id"],
},
)
campaign_id = resp.json()["id"]
# 4. Schedule it for a specific time (UTC)
requests.post(
f"{API}/email/campaigns/{campaign_id}/send",
headers=headers,
json={"scheduled_at": "2026-04-28T09:00:00.000Z"},
)
Error Responses
- 401 Unauthorized
- 404 Not Found
- 429 Rate Limited
{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid or missing API key"
}
{
"status_code": 404,
"name": "not_found",
"message": "Gallery template not found"
}
{
"status_code": 429,
"name": "too_many_requests",
"message": "Rate limit exceeded. Please slow down your requests."
}