Templates

Templates are the bluebrints of your documents. You can create a template and use it to create documents. You can also create a template from an existing document by uploading a PDF and mark your input fields in the editor of our app. On this page, we'll dive into the different templates endpoints you can use to fill templates programmatically. We'll look at how to query templates so you can fill them with data. To create, update and delete templates please use our app at wunderdocs.io .

The template model

The template model contains all the information about your template, such as their name, creator, and most important input fields. The uid is also used as a reference from your generated documents to the template used.

Properties

  • Name
    uid
    Type
    string
    Description

    The unique identifier for the document.

  • Name
    teamId
    Type
    number
    Description

    The ID of the team associated with the template.

  • Name
    creatorId
    Type
    number
    Description

    The ID of the user who created the template.

  • Name
    created
    Type
    timestamp
    Description

    Timestamp of when the template was created.

  • Name
    updated
    Type
    timestamp
    Description

    Timestamp of when the template was last updated.

  • Name
    name
    Type
    string
    Description

    The name of the template.

  • Name
    fields
    Type
    object
    Description

    The fiels associated with the template.

Template fields

Every template has a list of fields. These fields are the input fields that you can fill with data when you create a document from a template. The fields are stored as an array of objects. Each object has a label, key and type property. The label is the name of the field, the key is the unique identifier for the field and the type is the type of field. The type can be one of the following:

  • text
  • number
  • checkbox

So a field object could look like this:

{
  "label": "First Name",
  "key": "firstName",
  "type": "text"
}

Properties

  • Name
    label
    Type
    string
    Description

    A human readable name for the field.

  • Name
    key
    Type
    string
    Description

    The unique identifier for the field. Currently this is the same as the label.

  • Name
    type
    Type
    text/number/checkbox
    Description

    The ID of the user who created the template.


GET/v1/templates

List all templates

This endpoint allows you to retrieve a paginated list of all your templates. By default, a maximum of 25 templates are shown per page.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of templates returned.

  • Name
    offset
    Type
    integer
    Description

    Offset of templates returned.

Request

GET
/v1/templates
curl -G https://api.wunderdocs.io/v1/templates \
  -H "X-API-KEY: {api-key}" \
  -d limit=10 \
  -d offset=0 

Response

{
"totalCount": 3,
"filteredCount": 3,
"data": [
	{
		"uid": "7d7081bb-c4a1-407e-9dd3-82fb5079e1d9",
		"name": "My Template",
		"creatorId": 1,
		"teamId": 2,
		"fields": [
			{
				"label": "First Name",
				"key": "firstName",
      "type": "text",
			}
		],
		"created": "2023-03-22T11:42:52.000Z",
		"updated": "2023-05-11T23:35:10.000Z"
	},
}

GET/v1/templates/:uid

Retrieve a template

This endpoint allows you to retrieve a template by providing their wunderdocs uid. Refer to the list at the top of this page to see which properties are included with template objects.

Request

GET
/v1/templates/WAz8eIbvDR60rouK
curl https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
  -H "X-API-KEY: {api-key}" \

Response

	{
		"uid": "7d7081bb-c4a1-407e-9dd3-82fb5079e1d9",
		"name": "My Template",
		"creatorId": 1,
		"teamId": 2,
		"fields": [
			{
				"label": "First Name",
				"key": "firstName",
      "type": "text",
			}
		],
		"created": "2023-03-22T11:42:52.000Z",
		"updated": "2023-05-11T23:35:10.000Z"
	},

GET/v1/templates/:uid/fields

Retrieve template fields

This endpoint allows you to retrieve only the fields of a template by providing their wunderdocs uid. Usefull if you have the template uid and want to build a form to fill the template.

Request

GET
/v1/templates/WAz8eIbvDR60rouK/fields
curl https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK/fields \
  -H "X-API-KEY: {api-key}" \

Response

[
			{
				"label": "First Name",
				"key": "firstName",
      "type": "text"
			}
]

PUT/v1/templates/:uid

Update a template

This endpoint allows you to perform an update on a template. Currently, the only attribute that can be updated on template is the name attribute which controls how a template appears in your list in wunderdocs.

Optional attributes

  • Name
    name
    Type
    string
    Description

    The template name.

Request

PUT
/v1/templates/WAz8eIbvDR60rouK
curl -X PUT https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
  -H "X-API-KEY: {api-key}" \
  -d name="Template Name"

Response

	{
		"uid": "7d7081bb-c4a1-407e-9dd3-82fb5079e1d9",
		"name": "My Template",
		"creatorId": 1,
		"teamId": 2,
		"fields": [
			{
				"label": "First Name",
				"key": "firstName"
			}
		],
		"created": "2023-03-22T11:42:52.000Z",
		"updated": "2023-05-11T23:35:10.000Z"
	},

DELETE/v1/templates/:uid

Delete a template

This endpoint allows you to delete a template in wunderdocs. Note:

Request

DELETE
/v1/templates/WAz8eIbvDR60rouK
curl -X DELETE https://api.wunderdocs.io/v1/templates/WAz8eIbvDR60rouK \
  -H "X-API-KEY: {api-key}" \