ASDinCloudDocs
API ReferenceTemplates

The template object

View as Markdown

Templates store reusable content for emails, SMS, and printable pages.

Attributes

idinteger
Identifier assigned by the API.
namestring
Template name, up to 100 characters.
typestring
Use email, sms, or page.
editorstring
Editor format, email or page.
subjectstring or null
Email subject, up to 140 characters.
body_htmlstring or null
HTML content, optionally containing template variables.
body_jsonmap or array or null
Structured template editor data.
sms_textstring or null
Text used by an SMS template.
style_cssstring or null
CSS for a page template. Use null to clear it.
metadatamap or null
Additional template information.
editableboolean
Whether you can change or remove the template.
is_defaultboolean
Whether the template is a workspace default.
parent_idinteger or null
Source template ID, if copied.
profile_print_enabledboolean
Whether a page template appears in the profile print menu.
tscinteger or null
Creation time as Unix seconds.
tsuinteger or null
Last update time as Unix seconds.

List templates

View as Markdown
GET/api/v1/templates

Lists template records in the workspace.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Read.

Query parameters

typestring
Use email, sms, or page.
profile_print_enabledboolean
Whether a page template appears in the profile print menu.
qstring
Search template names.
lengthinteger
Number of records to return.
startinteger
Zero-based offset.
drawstring
Optional request marker echoed in the response.
sortstring
Sort by id, tsc, or tsu. Prefix the field name with a minus sign for descending order.
orderstring
Direction for unprefixed sort fields. Use asc or desc.

Returns

Returns templates in data with the counts before and after text search.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
400
The profile print filter must be a boolean.

Retrieve a template

View as Markdown
GET/api/v1/templates/{id}

Returns one template by ID.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Read.

Path parameters

idintegerRequired
ID of the template.

Returns

The template is returned in data.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
404
The requested record was not found.

Update a template

View as Markdown
PATCH / PUT / POST/api/v1/templates/{id}

Updates a template by ID.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Write.

Path parameters

idintegerRequired
ID of the template.

Body parameters

namestring
Template name, up to 100 characters.
typestring
Use email, sms, or page.
editorstring
Editor format, email or page.
subjectstring or null
Email subject, up to 140 characters.
body_htmlstring or null
HTML content, optionally containing template variables.
body_jsonmap or array or null
Structured template editor data.
sms_textstring or null
Text used by an SMS template.
style_cssstring or null
CSS for a page template. Use null to clear it.
metadatamap or null
Additional template information.

Only editable templates can be changed. Use Set profile print visibility to change menu visibility for a page.

Returns

Returns a successful update response.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
404
The requested record was not found.
400
The template, body, or stylesheet could not be processed.

Delete a template

View as Markdown
DELETE/api/v1/templates/{id}
POST/api/v1/templates/{id}/delete

Removes an editable template.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Write.

Path parameters

idintegerRequired
ID of the template.

Returns

Returns a successful removal response.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
404
The requested record was not found.
400
The template could not be removed.

List template variables

View as Markdown
GET/api/v1/templates/tags

Lists available template variables and their placeholder syntax.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Read.

Headers

X-Localestring
Language for group and variable labels. Use en or it. Defaults to it.

Returns

Returns groups in data, each with a stable group key, a display label, and a list of variable labels and values.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.

Render template HTML

View as Markdown
POST/api/v1/templates/{id}/parse

Renders the stored template HTML using request values.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Write.

Path parameters

idintegerRequired
ID of the template.

Body parameters

athlete_idinteger
Use an athlete ID to populate the athlete variables.
contextstring
Use athlete_print to require a valid athlete and fail if any template variables remain unresolved.
additional propertiesmap values
Send template variables as top-level properties. The JSON body takes precedence over form or query values.

Returns

Returns the rendered fragment in html. Page templates also return a complete HTML document in document_html and any CSS in style_css.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
400
The template, body, or stylesheet could not be processed.
404
The requested record was not found.
422
The athlete print context is invalid or variables could not be resolved.

Generate a template PDF

View as Markdown
POST/api/v1/templates/{id}/print

Generates a PDF from a stored template or an HTML preview.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Write.

Path parameters

idintegerRequired
ID of the template.

Body parameters

athlete_idinteger
Use an athlete ID to populate the athlete variables.
contextstring
Use athlete_print to require a valid athlete and fail if any template variables remain unresolved.
htmlstring
Optional HTML preview. If supplied, it replaces the rendered template content.
style_cssstring or null
Override the page stylesheet when also supplying preview HTML.
filenamestring
Optional name for the generated PDF.
additional propertiesmap values
Send template variables as top-level properties when rendering the stored template.

Returns

Returns the URL of the generated PDF in url.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
400
The template, body, or stylesheet could not be processed.
404
The requested record was not found.
422
The athlete print context is invalid or variables could not be resolved.
500
The PDF could not be generated.

Set profile print visibility

View as Markdown
POST/api/v1/templates/{id}/profile-print-visibility

Updates whether a page template appears in the profile print menu.

Permissions

Send your API key in X-API-Key. Required permissions are Templates → Write.

Path parameters

idintegerRequired
ID of the template.

Body parameters

enabledbooleanRequired
Set true to show the page template in the menu or false to hide it.

Returns

Returns the updated page template in data.

Errors

401
The API key is missing or invalid.
403
The API key lacks the required permission.
400
The template is not a page or enabled is missing or invalid.
404
The requested record was not found.