Create document

Create a new document based on a specified template.

HTTP request

The id in the path parameter should be the unique identifier of the template you are using to create the document.

POST https://api.wordfields.com/v1.0/templates/{id}/documents

Note: The query string parameter @api.templateFileId should be included in the URL if template has more than one file, otherwise request will not complete.

Request headers

Name Description
x-api-key API key. Required. Learn more about authentication.

Request body

In the request body, supply a JSON representation of the document resource to create. The data object corresponds to the properties defined in the template is required.

Response

If successful, this method returns a 201 Created response code and the document resource in the response body.

Example

The following example shows how to create a new document based on the specified template.

Request

POST https://api.wordfields.com/v1.0/templates/1499179389525622343/documents
Content-Type: application/json

{
  "data": {
     "Client Name": "Client Corp."
     "Company": "My Company",
     "Payment": 150.36,
     "ServiceDate": "2024-06-15"
  }
}

Response

If successful, this method returns the newly created document resource with a reference to document file. You can download the generated file via @api.downloadURL found in the documentFile.

HTTP/1.1 200 OK
Content-type: application/json; charset=utf-8

{
  "id": "1234004984261771264",
  "name": "MyTemplate-015",
  "data": {
    "Client Name": "Client Corp."
    "Company": "My Company",
    "Payment": 150.36,
    "ServiceDate": "2024-06-15"
    "AutomaticNumber": 3,
    "CreatedOn": "2024-08-16T14:00:58Z",
    "Description": null,
    "DocumentDate": "2024-08-16T14:00:58Z",
    "Keywords": null,
    "Organization": "Tester Organization Ltd.",
    "Subject": null,
    "Template": "1499179389525622343",
    "Title": "MyTemplate-015"
  },
  "templateReference": {
    "id": "1499179389525622343",
    "name": "TemplateMe"
  },
  "files": [
    {
      "id": "135140dd-2e1e-4d7d-96de-3cd137a00d43",
      "mimeType": "text/plain",
      "filename": "TemplateMe-003.txt",
      "size": 262,
      "templateFileReference": {
        "id": "1234985047770169344",
        "name": "MyTemplate",
        "templateId": "1499179389525622343"
      },
      "isTemporary": true,
      "@api.downloadUrl": "https://api.wordfields.com/files/content?version=1&uniqueId=135140dd-2e1e-4d7d-96de-3cd137a00d43&tempauth=eyJhbGciOiMBIzI1NiIxImE6cCI6IkpXVCJ9.eyJmaWxlSWQi...mFaCOaB8OxbNgA0dVwQ8GxFW1XKtp30dIPfs"
    }
  ]
}

Error responses

For more information on error handling, refer to the Error Responses article.