Update Template
Update a template's name or HTML body. Provide only the fields you want to change.
Endpoint
PATCH /templates/:id
Returns: 200 OK
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The template ID |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | New template name. Max 255 characters. |
html | string | No | Replacement HTML body. Sanitized server-side. |
Response
Returns the updated template — see Create Template for the shape.
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X PATCH "https://api.arsel.sa/v1/templates/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a" \
-H "Authorization: Bearer be_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Welcome back, {{first_name}}!</h1>"
}'
const templateId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
const response = await fetch(
`https://api.arsel.sa/v1/templates/${templateId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer be_your_api_key",
},
body: JSON.stringify({
html: "<h1>Welcome back, {{first_name}}!</h1>",
}),
},
);
console.log(await response.json());
import requests
template_id = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a"
response = requests.patch(
f"https://api.arsel.sa/v1/templates/{template_id}",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer be_your_api_key",
},
json={"html": "<h1>Welcome back, {{first_name}}!</h1>"},
)
print(response.json())
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer be_your_api_key");
var templateId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
var payload = new { html = "<h1>Welcome back, {{first_name}}!</h1>" };
var json = System.Text.Json.JsonSerializer.Serialize(payload);
var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
var request = new HttpRequestMessage(HttpMethod.Patch, $"https://api.arsel.sa/v1/templates/{templateId}")
{
Content = content
};
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$templateId = "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a";
$ch = curl_init("https://api.arsel.sa/v1/templates/{$templateId}");
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_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"html" => "<h1>Welcome back, {{first_name}}!</h1>"
]));
$response = curl_exec($ch);
echo $response;
curl_close($ch);
Error Responses
- 404 Not Found
{
"status_code": 404,
"name": "not_found",
"message": "Template not found"
}