Seal Docs

Templates API

Create and manage reusable document templates with custom fields

Templates API

The Templates API allows you to create reusable document templates with predefined fields. Templates speed up document creation by providing a standardized structure that can be used repeatedly.

The Template Object

Attributes

AttributeTypeDescription
idstringUnique template identifier
namestringTemplate name
descriptionstringTemplate description
categorystringTemplate category for organization
fieldsarrayArray of field definitions
created_atstringISO 8601 creation timestamp
updated_atstringISO 8601 last update timestamp
usage_countnumberNumber of times template has been used

Example Object

{
  "id": "tpl_abc123",
  "name": "Employment Contract",
  "description": "Standard employment agreement template",
  "category": "HR",
  "created_at": "2024-01-15T10:00:00Z",
  "updated_at": "2024-01-20T14:30:00Z",
  "usage_count": 45
}

List Templates

Retrieve all templates for your organization.

Endpoint

GET /api/v1/templates

Required Scope

seal:templates:read

Query Parameters

ParameterTypeDescription
limitnumberNumber of results (max 100, default 20)
cursorstringPagination cursor
categorystringFilter by category

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates?category=HR", {
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
  },
});

const { templates, has_more, next_cursor } = await response.json();

cURL Example

curl -X GET "https://seal.convex.site/api/v1/templates?category=HR" \
  -H "Authorization: Bearer ak_your_api_key_here"

Get Template

Retrieve a single template by ID.

Endpoint

GET /api/v1/templates/get?id={id}

Required Scope

seal:templates:read

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates/get?id=tpl_abc123", {
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
  },
});

const template = await response.json();

cURL Example

curl -X GET "https://seal.convex.site/api/v1/templates/get?id=tpl_abc123" \
  -H "Authorization: Bearer ak_your_api_key_here"

Get Template Fields

Retrieve field definitions for a template.

Endpoint

GET /api/v1/templates/fields?id={id}

Required Scope

seal:templates:read

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates/fields?id=tpl_abc123", {
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
  },
});

const fields = await response.json();

Response

{
  "fields": [
    {
      "id": "field_1",
      "name": "employee_name",
      "label": "Employee Name",
      "type": "text",
      "required": true,
      "placeholder": "Enter full name"
    },
    {
      "id": "field_2",
      "name": "start_date",
      "label": "Start Date",
      "type": "date",
      "required": true
    },
    {
      "id": "field_3",
      "name": "salary",
      "label": "Annual Salary",
      "type": "number",
      "required": true
    }
  ]
}

Create Template from Document

Create a new template from an existing document.

Endpoint

POST /api/v1/templates

Required Scope

seal:templates:write

Request Body

FieldTypeRequiredDescription
document_idstringYesSource document ID
namestringYesTemplate name
descriptionstringNoTemplate description
categorystringNoTemplate category

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates", {
  method: "POST",
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    document_id: "doc_xyz789",
    name: "Employment Contract",
    description: "Standard employment agreement",
    category: "HR",
  }),
});

const template = await response.json();

cURL Example

curl -X POST https://seal.convex.site/api/v1/templates \
  -H "Authorization: Bearer ak_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_id": "doc_xyz789",
    "name": "Employment Contract",
    "category": "HR"
  }'

Update Template

Update a template's metadata.

Endpoint

PUT /api/v1/templates/update?id={id}

Required Scope

seal:templates:write

Request Body

FieldTypeDescription
namestringNew template name
descriptionstringNew description
categorystringNew category

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates/update?id=tpl_abc123", {
  method: "PUT",
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Updated Employment Contract",
    category: "Legal",
  }),
});

Delete Template

Permanently delete a template.

Endpoint

DELETE /api/v1/templates/delete?id={id}

Required Scope

seal:templates:write

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates/delete?id=tpl_abc123", {
  method: "DELETE",
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
  },
});

const result = await response.json();
// Returns { "deleted": true } with 200 status

Use Template

Create a new document from a template.

Endpoint

POST /api/v1/templates/use?id={id}

Required Scope

seal:templates:read

Request Body

FieldTypeRequiredDescription
titlestringYesDocument title
descriptionstringNoDocument description

TypeScript Example

const response = await fetch("https://seal.convex.site/api/v1/templates/use?id=tpl_abc123", {
  method: "POST",
  headers: {
    Authorization: "Bearer ak_your_api_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: "John Doe Employment Contract",
    description: "Employment agreement for John Doe",
  }),
});

const document = await response.json();

Response

{
  "id": "doc_new123",
  "title": "John Doe Employment Contract",
  "status": "draft",
  "created_from_template": "tpl_abc123",
  "created_at": "2024-01-27T15:00:00Z"
}

Field Types

TypeDescriptionExample Value
textSingle-line text input"John Doe"
textareaMulti-line text input"Full address..."
numberNumeric input75000
dateDate picker"2024-02-01"
emailEmail address"john@example.com"
checkboxBoolean checkboxtrue
selectDropdown selection"option1"
signatureSignature field(drawn signature)

Next Steps

Last updated on

On this page