Templates
List templates
Searches an organization's templates by folder, type, status and other filters, with sorting and pagination. Returns matching templates, a count and thumbnail links for published designs; designs themselves are omitted. Thumbnail links are valid for one day.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- Organization access with the
template.readpermission is required. - Without
receipt.read, receipt templates are excluded. - Without
donationsSettings.read, donation confirmation templates are excluded.
Request
Path parameters
-
organizationIdidrequired
Body
Content-Type: application/json
-
searchstringnullableat most 240 characters
-
typesobject[]2 properties
-
typestringrequiredtransactionalcontactbookingreceiptdonationConfirmation -
subtypestringnullableat most 64 characters
-
-
contactTypestringnullablememberaddresscustomersponsorcontributoremployeesupplier -
includeAllContactsbooleandefault
false -
hasEmailDesignboolean -
hasLetterDesignboolean -
receiptTypesstring[]invoicedepositdonationofferconfirmationreminderreturnedPayment -
folderIdidnullable -
statusstringdefault
"active"activepublisheddraftarchived -
standardFirstbooleandefault
false -
defaultsstringonlyexclude -
sortstringdefault
"name"namecreatedAtupdatedAt -
sortBystringdefault
"asc"ascdesc -
offsetintegerat least 0 · default
0 -
limitinteger1–60 · default
30
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/search' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"types": [
{
"type": "receipt"
}
],
"receiptTypes": [
"invoice"
],
"status": "published",
"limit": 1
}'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/search", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"types": [
{
"type": "receipt"
}
],
"receiptTypes": [
"invoice"
],
"status": "published",
"limit": 1
}),
redirect: 'error',
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`campai HTTP ${response.status}`);
const text = await response.text();
const result = text ? JSON.parse(text) : null;
console.log(JSON.stringify(result, null, 2));<?php
$body = [
'types' => [
[
'type' => 'receipt',
],
],
'receiptTypes' => [
'invoice',
],
'status' => 'published',
'limit' => 1,
];
$context = stream_context_create(['http' => [
'method' => 'POST',
'header' => [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json',
],
'content' => json_encode($body, JSON_THROW_ON_ERROR),
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/search', false, $context);
preg_match('/^HTTP\/\S+ (\d{3})/', $http_response_header[0] ?? '', $match);
$status = (int) ($match[1] ?? 0);
if ($text === false || $status < 200 || $status >= 300) {
throw new RuntimeException("campai HTTP $status (0 means no response)");
}
$result = $text === '' ? null : json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
A request the admin app sent for “Create a receipt”.
Response
200 Successful response
Content-Type: application/json
-
templatesobject[] -
countnumber -
thumbnailsobject of object
More about the fields
templates[].email: For a contact template,templates[].emailis null if the email channel is absent.templates[].letter: For a contact template,templates[].letteris null if the letter channel is absent.
Response200
{
"templates": [
{
"_id": "000000000000000000000001",
"folder": "000000000000000000000001",
"publishedAt": "2026-06-15T22:30:00Z",
"archivedAt": "2026-06-15T22:30:00Z",
"name": "string",
"description": "string",
"type": "transactional",
"standard": true,
"transactionalType": "content"
}
],
"count": 1,
"thumbnails": {
"key": {
"email": {
"width": 1,
"height": 1,
"pages": 1,
"background": "string",
"url": "string"
},
"letter": {
"width": 1,
"height": 1,
"pages": 1,
"background": "string",
"url": "string"
},
"current": true
}
}
}
What else happens
- May queue
misc.renderTemplateThumbnailsjobs onDefaultQueuefor template thumbnails.
Errors
No errors of its own are known for this endpoint.
Errors nearly every request can meet are listed under Errors.