Submit JSON with Custom Templates
✨🎨 Custom templates are available on Pro and Scale plans
Submission Templates
Custom templates let you control how a submission is displayed in email notifications, integrations (Slack, Discord, Telegram), and the Submit JSON UI.
Use double curly braces for variables, for example: {{ data.name }}.
Enable on an endpoint
- Open your endpoint settings.
- Set Submission format to 🎨 Custom.
- Add your Custom template in the textarea.
- Save.
Enable project-wide defaults
- Open your project settings.
- Set Submission format to 🎨 Custom.
- Add a Custom template in the textarea.
- Save.
This template becomes the default for endpoints that use project defaults.
Template syntax
Templates support:
- Variable interpolation with
{{ ... }} - Dot-path access like
{{ data.user.email }} - Conditionals with
{{#if ...}},{{else if ...}},{{else}}, and{{#unless ...}} - Select HTML tags
<p>,<br>,<b>,<strong>,<i>,<em>,<u>,<ul>,<ol>,<li>,<a>
Templates do not support loops or custom helpers.
For links, only safe protocols are allowed in <a href="...">: https://, http://, mailto:, and tel:.
Template variable context
Templates are rendered with these context roots:
...data: top-level submission datadata: your submitted payloadsubmission: submission metadata
Examples:
{{ name }}(top-level submitted field){{ data.name }}{{ data.contact.email }}{{ submission.submissionId }}{{ submission.endpointSlug }}{{ submission.endpointName }}{{ submission.createdAt }}
Example template
<strong>New Lead</strong>
<ul>
<li>Name: {{ name }}</li>
<li>Email: {{ email }}</li>
<li>Company: {{ company }}</li>
</ul>
{{#if budget}}
<strong>Budget: {{ budget }}</strong>
{{else}}
No budget provided
{{/if}}
<a href="https://www.submitjson.com/endpoints/{{ submission.endpointSlug }}">
View endpoint ({{ submission.endpointName }})
</a>
<a href="https://www.submitjson.com/submissions/{{ submission.submissionId }}">
View submission details
</a>
Configure defaults with the JS client
You can define submissionFormat and submissionTemplate as defaults in client initialization:
import SubmitJSON from 'submitjson'
const sj = new SubmitJSON({
apiKey: 'sjk_xxxxxxxxxxxxxx',
endpoint: 'XxXxXxXxX',
options: {
submissionFormat: 'custom',
submissionTemplate: '<p><strong>{{ name }}</strong> ({{ email }})</p>',
},
})
await sj.submit({
name: 'Yo Yoerson',
email: '[email protected]',
})
Override per submission
Per-submission options can override endpoint/project templates.
options.submissionTemplate takes precedence over the template configured on the endpoint.
curl -X POST "https://api.submitjson.com/v1/submit/XxXxXxXxX" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-API-Key: sjk_xxxxxxxxxxxxxx" \
-d '{
"data": {
"name": "Yo Yoerson",
"email": "[email protected]"
},
"options": {
"submissionFormat": "custom",
"submissionTemplate": "<p><strong>{{ data.name }}</strong> ({{ data.email }})</p>"
}
}'
Fallback behavior
If a custom template is missing or cannot be rendered safely, Submit JSON falls back to the pretty format for that submission.
Email Subject Templates
Email subjects also support {{ variables }} interpolation with the same context as submission templates.
Example:
New message from {{ data.name }} ({{ submission.endpointSlug }})
Subject templates render plain strings and are useful for per-endpoint or per-submission customization.
