Templates
Get template
Gets a template and its editable properties for an organization. Provide the organization ID and template ID; the response is the template, with actor details protected according to the caller’s permissions.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- The caller must have organization access and the
template.readpermission. - A template of type
receiptalso requiresreceipt.read. - A template of type
donationConfirmationalso requiresdonationsSettings.read.
Request
Path parameters
-
organizationIdidrequired -
templateIdidrequired
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request GET 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/YOUR_TEMPLATE_ID' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/YOUR_TEMPLATE_ID", {
method: "GET",
headers: {
"X-API-Key": "YOUR_API_KEY"
},
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
$context = stream_context_create(['http' => [
'method' => 'GET',
'header' => [
'X-API-Key: YOUR_API_KEY',
],
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/templates/YOUR_TEMPLATE_ID', 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
object
Response200
{
"_id": "000000000000000000000001",
"organization": "000000000000000000000001",
"designRevision": 0,
"type": "transactional",
"folder": "000000000000000000000001",
"publishedAt": "2026-06-15T22:30:00Z",
"archivedAt": "2026-06-15T22:30:00Z",
"name": "string",
"description": "string",
"draft": {
"email": {
"version": 1,
"channel": "email",
"container": {
"type": "container",
"id": "string",
"desktop": {
"padding": [
null
]
},
"mobile": {
"padding": [
null
]
},
"width": 1,
"fontFamily": "System",
"background": {
"backgroundColor": {
"color": "string",
"hide": true
},
"backgroundGradient": {
"hide": true,
"stops": [
{
"color": "string",
"position": 0
}
],
"angle": 1
},
"backgroundImage": {
"hide": true,
"image": {
"type": "resource",
"resourceId": "string"
},
"size": "cover",
"position": "top left"
}
},
"items": [
{
"id": "string",
"name": "string",
"hideOnMobile": true,
"hideOnDesktop": true,
"hidden": true,
"locked": true,
"condition": {
"operator": "and",
"conditions": [
null
]
},
"desktop": {
"margin": [
null
],
"padding": [
null
],
"radius": 0
},
"mobile": {
"margin": [
null
],
"padding": [
null
],
"radius": 0
},
"type": "block",
"repeat": {
"source": {
"variable": "string"
}
},
"background": {
"backgroundColor": {
"color": "string",
"hide": true
},
"backgroundGradient": {
"hide": true,
"stops": [
{
"color": null,
"position": null
}
],
"angle": 1
},
"backgroundImage": {
"hide": true,
"image": null,
"size": "cover",
"position": "top left"
}
},
"border": {
"color": "string",
"width": 0,
"style": "solid",
"hide": true
},
"items": [
{
"id": "string",
"name": "string",
"hideOnMobile": true,
"hideOnDesktop": true,
"hidden": true,
"locked": true,
"condition": null,
"desktop": {
"width": null
},
"mobile": {
"width": null
},
"type": "table",
"align": "left",
"border": {
"color": null,
"width": null,
"style": "solid",
"hide": null
},
"collapseMobile": true,
"items": [
null
]
}
]
}
]
},
"languages": [
"string"
],
"resources": [
{
"resource": "string",
"id": "string"
}
]
},
"letter": {
"version": 1,
"channel": "paper",
"container": {
"type": "container",
"id": "string",
"repeat": {
"source": {
"variable": "string"
}
},
"pageSize": {
"width": 1,
"height": 1,
"landscape": true
},
"fontFamily": "string",
"items": [
{
"id": "string",
"name": "string",
"hidden": true,
"locked": true,
"condition": {
"operator": "and",
"conditions": [
null
]
},
"type": "page",
"repeat": {
"source": {
"variable": "string"
}
},
"margin": [
null
],
"background": {
"backgroundColor": {
"color": "string",
"hide": true
},
"backgroundGradient": {
"hide": true,
"stops": [
{
"color": null,
"position": null
}
],
"angle": 1
},
"backgroundImage": {
"hide": true,
"image": null,
"size": "cover",
"position": "top left"
}
},
"foldingMarks": [
{
"top": 1,
"left": 1,
"width": 1
}
],
"items": [
{
"id": "string",
"name": "string",
"hidden": true,
"locked": true,
"condition": null,
"margin": [
null
],
"padding": [
null
],
"radius": null,
"background": {
"backgroundColor": null,
"backgroundGradient": null,
"backgroundImage": null
},
"border": {
"color": null,
"width": null,
"style": "solid",
"hide": null
},
"orientation": "horizontal",
"placement": "top left",
"gapX": null,
"gapY": 0,
"type": "section",
"repeat": null,
"height": {
"value": null,
"unit": "#"
},
"items": [
null
]
}
]
}
]
},
"unit": "px",
"languages": [
"string"
],
"onlineLetter": true,
"resources": [
{
"resource": "string",
"id": "string"
}
],
"attachment": {
"resourceId": "string",
"mode": "overlay",
"pages": 1
}
},
"pass": {
"version": 1,
"channel": "pass",
"id": "string",
"languages": [
"string"
],
"resources": [
{
"resource": "string",
"id": "string"
}
],
"isSingleUse": true,
"expiresAt": {
"variable": "string"
},
"locations": [
{
"latitude": -90,
"longitude": -180
}
],
"issuerName": {
"mode": "plain",
"values": {
"key": [
{
"kind": "literal",
"value": "string"
}
]
},
"fallbackLanguage": "string"
},
"logoImage": {
"type": "resource",
"resourceId": "string"
},
"mainImage": {
"type": "resource",
"resourceId": "string"
},
"textFields": {
"key": {
"type": "header",
"label": {
"mode": "plain",
"values": {
"key": [
null
]
},
"fallbackLanguage": "string"
},
"value": {
"mode": "plain",
"values": {
"key": [
null
]
},
"fallbackLanguage": "string"
}
}
},
"barcode": {
"format": "qrcode",
"content": {
"mode": "plain",
"values": {
"key": [
null
]
},
"fallbackLanguage": "string"
},
"text": {
"mode": "plain",
"values": {
"key": [
null
]
},
"fallbackLanguage": "string"
}
},
"apple": {
"showIssuerName": true,
"textColor": "string",
"hideMainFields": true
},
"google": {
"renderWideLogo": true
},
"type": "custom",
"custom": {
"header": {
"mode": "plain",
"values": {
"key": [
{
"kind": "literal",
"value": null
}
]
},
"fallbackLanguage": "string"
},
"subheader": {
"mode": "plain",
"values": {
"key": [
{
"kind": "literal",
"value": null
}
]
},
"fallbackLanguage": "string"
},
"backgroundColor": {
"mode": "plain",
"values": {
"key": [
{
"kind": "literal",
"value": null
}
]
},
"fallbackLanguage": "string"
}
}
},
"retiredResources": [
{
"resource": "string",
"id": "string"
}
],
"savedAt": "2026-06-15T22:30:00Z"
},
"email": {
"design": {
"version": 1,
"channel": "email",
"container": {
"type": "container",
"id": "string",
"desktop": {
"padding": [
null
]
},
"mobile": {
"padding": [
null
]
},
"width": 1,
"fontFamily": "System",
"background": {
"backgroundColor": {
"color": "string",
"hide": true
},
"backgroundGradient": {
"hide": true,
"stops": [
{
"color": "string",
"position": 0
}
],
"angle": 1
},
"backgroundImage": {
"hide": true,
"image": {
"type": "resource",
"resourceId": "string"
},
"size": "cover",
"position": "top left"
}
},
"items": [
{
"id": "string",
"name": "string",
"hideOnMobile": true,
"hideOnDesktop": true,
"hidden": true,
"locked": true,
"condition": {
"operator": "and",
"conditions": [
null
]
},
"desktop": {
"margin": [
null
],
"padding": [
null
],
"radius": 0
},
"mobile": {
"margin": [
null
],
"padding": [
null
],
"radius": 0
},
"type": "block",
"repeat": {
"source": {
"variable": "string"
}
},
"background": {
"backgroundColor": {
"color": "string",
"hide": true
},
"backgroundGradient": {
"hide": true,
"stops": [
{
"color": "string",
"position": 0
}
],
"angle": 1
},
"backgroundImage": {
"hide": true,
"image": {
"type": "resource",
"resourceId": "string"
},
"size": "cover",
"position": "top left"
}
},
"border": {
"color": "string",
"width": 0,
"style": "solid",
"hide": true
},
"items": [
{
"id": "string",
"name": "string",
"hideOnMobile": true,
"hideOnDesktop": true,
"hidden": true,
"locked": true,
"condition": {
"operator": "and",
"conditions": null
},
"desktop": {
"width": {
"type": "hug",
"width": {
"value": null,
"unit": "#"
}
}
},
"mobile": {
"width": {
"type": "hug",
"width": null
}
},
"type": "table",
"align": "left",
"border": {
"color": "string",
"width": 0,
"style": "solid",
"hide": true
},
"collapseMobile": true,
"items": [
{
"id": "string",
"name": "string",
"hideOnMobile": true,
"hideOnDesktop": true,
"hidden": true,
"locked": true,
"condition": null,
"desktop": {
"placement": "top left",
"height": null
},
"mobile": {
"placement": "top left",
"height": null
},
"type": "tableRow",
"repeat": null,
"backgroundColor": {
"color": null,
"hide": null
},
"border": {
"color": null,
"width": null,
"style": "solid",
"hide": null
},
"items": [
null
]
}
]
}
]
}
]
},
"languages": [
"string"
],
"resources": [
{
"resource": "string",
"id": "string"
}
]
},
"attachments": [
{
"resource": "string",
"id": "string"
}
]
},
"standard": true,
"transactionalType": "content"
}
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 404 | No fixed message | If the template is not found in the organization, the endpoint returns HTTP 404 (NOT_FOUND). |
Errors nearly every request can meet are listed under Errors.