Templates
A template is the form definition a warrant application is built from. It declares the fields the application collects (form elements), how the document is rendered (generated documents), and the workflow rules that apply to applications made from it.
List
curl -s "$BASE/templates" -H "x-api-key: $API_KEY"
The result contains both kinds of template:
| Kind | is_system_template | Editable |
|---|---|---|
| System | true | No, duplicate it first |
| Agency | false | Yes |
System templates are the statutory forms eCourtDate maintains and keeps current. Agency templates are yours.
Add ?active_only=false to include retired templates, which stay readable so
that applications already created from them still render.
Retrieve
curl -s "$BASE/templates/$TEMPLATE_ID" -H "x-api-key: $API_KEY"
{
"id": "c47b2a91-5e3d-4f88-b0a2-7d1c6e9f4a53",
"name": "Emergency Detention (Form MH-101)",
"description": "Statutory emergency detention application used by hospital staff.",
"is_system_template": true,
"is_active": true,
"elements": [],
"workflow": {"requiresJudgeApproval": true, "notifyOnSubmission": true},
"style_preset": "letter-portrait",
"allow_editing_per_warrant": true
}
The elements array is the contract for form_data on any application created
from this template. Read it and drive your payload from it rather than
hard-coding field names, so a template change does not silently break your
integration.
Duplicate
curl -s -X POST "$BASE/templates/$TEMPLATE_ID/duplicate" \
-H "x-api-key: $API_KEY" \
-H "X-On-Behalf-Of: admin.reyes@example.gov"
This is how a system template gets customized: the copy is an ordinary agency template you can edit, and the original keeps receiving eCourtDate's updates.
Create
curl -s -X POST "$BASE/templates" \
-H "x-api-key: $API_KEY" \
-H "X-On-Behalf-Of: admin.reyes@example.gov" \
-H "Content-Type: application/json" \
-d '{
"name": "Blood Draw Warrant",
"description": "Used by patrol for implied-consent blood draws.",
"elements": [
{"id": "el_1", "type": "DYNAMIC_FIELD", "fieldId": "subject_name", "label": "Subject name", "dataType": "TEXT", "required": true, "x": 0, "y": 0, "width": 0, "height": 0},
{"id": "el_2", "type": "SIGNATURE", "fieldId": "officer_signature", "label": "Officer signature", "x": 0, "y": 0, "width": 0, "height": 0}
],
"workflow": {"requiresJudgeApproval": true, "notifyOnSubmission": true},
"style_preset": "letter-portrait"
}'
Update and delete
PUT /v1/templates/{templateId} replaces the template's definition, and
DELETE /v1/templates/{templateId} removes it. Neither works on a system
template.
Applications already created from a template keep the form_data they
captured. Changing a template does not rewrite history, and deleting one does
not invalidate the warrants made from it. It does mean new applications cannot
be created from it, so retire a template by leaving it in place and removing it
from the enabled templates instead, unless you
are certain nothing references it.
Workflow rules
The workflow object carries the rules that apply to applications from this
template:
| Key | Meaning |
|---|---|
requiresJudgeApproval | Applications need a judge's signature |
notifyOnSubmission | Notify reviewers as soon as one is submitted |
autoExpireHours | Hours after signing that the warrant expires |
allowedRoles | Roles permitted to create applications from this template |
autoExpireHours sets expires_at on the signed warrant. Expiry is
informational on the record itself: what it means operationally is a matter of
your jurisdiction's law, and this API does not enforce it.
Building a document from a file
A template can be backed by an existing document. Upload it (files and attachments), then convert it:
curl -s -X POST "$BASE/templates/process-document" \
-H "x-api-key: $API_KEY" \
-H "X-On-Behalf-Of: admin.reyes@example.gov" \
-H "Content-Type: application/json" \
-d '{"storage_key": "agencies/4f0c9d2e/templates/base.docx", "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}'
Word documents are converted to PDF; images and PDFs come back unchanged. The
returned storage_key is what you set as the template's base document.