Appearance
Create a template
Agents and your software start documents from the workspace's templates. When there isn't a suitable one, create_template makes it, from text you write or as a copy of a library entry. It needs the documents permission. It emails no one, so it never waits for approval. Sending a document started from it waits for approval, as every send by an agent key does.
People can make templates in the app as well:
- From the library. Open Library, choose an entry, then Save as template. Its fill-ins stay blank, to fill in each time. (Choosing Create document and then Save as template on the document's page also works, but it leaves the draft document behind, which you can delete.)
- In the editor. Write a document with fill-ins and signing fields, then save it as a template.
- From a PDF. Upload it, place its fields, and keep it as a template.
1. Check the workspace
A key works only in the workspace it was made in. get_workspace says which, with its plan, how many templates it keeps, and whether the key's sends wait for approval:
bash
curl https://tryjustdocs.com/api/v1/workspace \
-H "Authorization: Bearer $JUSTDOCS_AGENT_KEY"text
get_workspace {}json
{
"id": "f1a3c5e7-9b2d-4c4f-a6e8-1b3d5f7a9c2e",
"name": "Northwind",
"personal": false,
"plan": "teams",
"plan_name": "Teams & Platform",
"key": { "name": "Sales agent", "kind": "agent", "kind_label": "Agent key", "sends_need_approval": true, "sends_label": "Sends wait for approval" },
"templates": { "saved": 4, "limit": null }
}A personal workspace is named "Personal". If list_templates comes back empty, or a template id you were given isn't found, compare name with the workspace where the template was made. The full response is in the reference.
2. Write the text
The text is plain, in blocks separated by a blank line:
| Write | For |
|---|---|
# Title | A heading. ## and ### make smaller ones. A heading is a block of its own. |
- item or 1. item | A list. Every line of the block starts the same way. |
--- | A horizontal rule. |
| Anything else | A paragraph. Its lines are kept as line breaks. |
Inside the text:
| Write | For |
|---|---|
**words** | Bold. |
{{client_name}} | A fill-in, completed for each document. Its label is made from its key: Client name. |
{{client_name|Client's legal name}} | A fill-in with its own label. |
[[signature:client]] | A signing field for the role client. |
[[text:client|Job title]] | A signing field with its own label. |
[[initials:client?]] | An optional field. A field is optional when its role ends in ?, before any label. |
[[text:client?|Job title]] | An optional field with its own label. |
A fill-in's key is lowercase letters, numbers and _, starting with a letter, up to 40 characters. A field's type is signature, initials, date_signed, full_name, text or checkbox, and its role is lowercase letters, numbers and -, up to 40 characters. A fill-in used more than once is one fill-in, completed once.
Text left looking like a fill-in or a field is refused with its line rather than saved as words. For example, {{Client Name}} on line 3 gets:
text
Line 3: "{{Client Name}}" isn't a fill-in: write {{key}} or {{key|Label}}, key in lowercase letters, numbers and _, label up to 100 charactersFor example:
text
# Consulting agreement
This agreement is between Northwind Ltd and {{client_name|Client's legal name}}, starting on {{start_date}}.
1. Northwind provides the services described in {{scope}}.
2. The client pays {{fee}} a month, within 30 days of each invoice.
3. Either party may end this agreement with 30 days' notice.
**For the client**
Signature: [[signature:client]]
Name: [[full_name:client]]
Date: [[date_signed:client]]3. Say who signs
A template made through the API has at least one signing role, and at most 20. By default, the roles are the ones the text's fields use, in the order they first appear.
List them in roles to add signers without writing their fields. A listed role with no field in the text gets a block at the end, after one rule. For the role provider, that is:
text
---
**Provider**
Signature: [[signature:provider]]
Name: [[full_name:provider]]
Date: [[date_signed:provider]]With roles, a field for a role that isn't listed is refused, so a typo such as [[signature:cleint]] is caught. Each role needs at least one required field, so no one can sign without leaving a mark. A role can have up to 500 fields.
4. Label the fill-ins
fill_ins gives labels by key, such as { "key": "fee", "label": "Monthly fee" }. A fill-in takes its label from fill_ins first, then from the first label written in the text, then from its key. Each key in fill_ins must appear in the text.
5. Create it
bash
curl -X POST https://tryjustdocs.com/api/v1/templates \
-H "Authorization: Bearer $JUSTDOCS_AGENT_KEY" \
-H "Idempotency-Key: consulting-template-v1" \
-H "Content-Type: application/json" \
-d @template.jsontext
create_template {
"title": "Consulting agreement",
"content": "# Consulting agreement\n\nThis agreement is between Northwind Ltd and {{client_name|Client's legal name}}, starting on {{start_date}}.\n\n1. Northwind provides the services described in {{scope}}.\n2. The client pays {{fee}} a month, within 30 days of each invoice.\n3. Either party may end this agreement with 30 days' notice.\n\n**For the client**\nSignature: [[signature:client]]\nName: [[full_name:client]]\nDate: [[date_signed:client]]",
"fill_ins": [{ "key": "fee", "label": "Monthly fee" }],
"roles": ["client", "provider"],
"idempotency_key": "consulting-template-v1"
}For REST, template.json holds the same fields as the MCP call, without idempotency_key. The answer is 201 with the new template: its id, fill_ins, roles (here client and provider, whose block was added at the end) and form, the questions that answer its fill-ins. In a team, the template is shared with the team for use, as one saved in the app is.
A retry with the same idempotency key returns the same template. A mistake in the text is refused before the key is used, so you can fix it and retry with the same key.
Copy a library entry
Give library_entry instead of content, with an optional title (the entry's own name by default):
bash
curl -X POST https://tryjustdocs.com/api/v1/templates \
-H "Authorization: Bearer $JUSTDOCS_AGENT_KEY" \
-H "Idempotency-Key: mutual-nda-template" \
-H "Content-Type: application/json" \
-d '{ "library_entry": "mutual-nda" }'text
create_template {
"library_entry": "mutual-nda",
"idempotency_key": "mutual-nda-template"
}The entry brings its own text, fill-ins and roles, so content, fill_ins and roles aren't taken with it. The written documents and official forms in the library can be copied, the W-9 (w9-request) included; the reference for create_template lists every slug. The paid company and equity documents, which the legal questionnaire drafts, can't be saved as templates. Nor can the questionnaire itself, packets (save their entries one at a time), Your Own Document (upload the PDF in the app instead), or entries that aren't available yet.
Then use it
Start a document from it with start_document, then ask to send it with create_signing_request. See Send an agreement with approval.
There is no update or delete through the API. A person can edit or delete the template in the app.
Limits and errors
| Title | 1 to 255 characters. Needed with content. |
| Text | Up to 500,000 characters, in a body of up to 2 MB. |
| Fill-ins | Up to 200. |
| Labels | Up to 100 characters, for a fill-in or a field. |
| Roles | 1 to 20, each with up to 500 fields. |
| Saved templates | The plan's limit. See Plans and limits. |
| Status | When |
|---|---|
400 | The text has a mistake, named with its line; no one signs it; a role's fields are all optional; a field's role isn't in roles; a key in fill_ins isn't in the text; or the library entry can't be saved as a template. |
402 | The workspace keeps as many saved templates as its plan allows. Delete one you no longer use in the app, or upgrade the plan. |
403 | The key doesn't have the documents permission. |
404 | There's no library entry with that slug. |
409 | The library entry isn't available yet, or the idempotency key was used for something else. |
413 | The body is larger than 2 MB, or the template is too long to save. |