Skip to content

POST Create Templates

Base URLs

Demo URL: https://demoapi.openletterconnect.com/api/v1

Production URL: https://api.openletterconnect.com/api/v1

{{base_url}}/templates

Description

This endpoint is used to create a new template in the system. By providing details such as the template title, associated product ID, paths for the template and thumbnail, and any necessary fields, users can add a new template that can be utilized for various purposes within the account. The response will include a confirmation message indicating that the template was created successfully, along with the details of the newly created template.

AUTHORIZATION

Bearer Token

  • Token: {{jwt_token}}

Pre-Requiest

Before creating a template using this API, you must first upload the required files using the Upload Template API. The uploaded files should include:

  1. Template File (e.g., a JSON file): This file contains the structure or content of the template.
  2. Thumbnail File: This file serves as the visual representation or preview of the template.

The Upload Template API will return the file paths for the{{TemplatePath}}} and {{thumbnailPath}}} fields. These paths are mandatory when making the API request to create a template. Without these file paths, the template creation will fail.

Bode raw

{
  "title": "My Template1",
  "productId": 16,
  "templatePath": "s3/openletterconnect/org-1/user-3/templates/upload/html/1702895166930-template.html",
  "backTemplatePath": "s3/openletterconnect/org-2/user-3/templates/upload/backHtml/1702379710452-back-template.html",
  "thumbnailPath": "s3/openletterconnect/org-1/user-1/templates/upload/thumbnail/1701775937282-logo.png",
  "backThumbnailPath": "s3/openletterconnect/org-1/user-1/templates/upload/thumbnail/1701775937282-logo.png",
  "fields": [
    {
      "key": "{{CF.FIRST_NAME}}",
      "value": "First Name"
    }
  ]
}

Example Request

curl --location -g '{{base_url}}/templates' \
--data '{
    "title": "My Template 6",
    "productId": 3,
    "templatePath": "s3/openletterconnect/org-1/user-1/templates/upload/json/1701792981367-template.json",
    "thumbnailPath": "s3/openletterconnect/org-1/user-1/templates/upload/thumbnail/1701775937282-logo.png",
    "fields": [
        {
            "key": "{{CONTACTS.FIRST_NAME}}",
            "value": "First Name",
            "strict": false,
            "defaultValue": ""
        }
    ]
}'

Example Response

{
  "message": "Template Created Successfully",
  "data": {
    "id": "10",
    "title": "My Template 6",
    "templateUrl": " https://api.openletterconnect.com/api/v1/s3/openletterconnect/org-1/user-1/templates/upload/json/1701792981367-template.json",
    "templateType": "json",
    "thumbnailUrl": " https://api.openletterconnect.com/api/v1/s3/openletterconnect/org-1/user-1/templates/upload/thumbnail/1701775937282-logo.png",
    "creator": {
      "id": "2",
      "fullName": "Usman Iqbal"
    },
    "product": {
      "id": "3",
      "paperType": "60# Statement",
      "paperSize": "8.5x11",
      "deliveryType": "First Class",
      "productType": "Professional letters",
      "envelopeType": "#10 Grey",
      "postageType": "Live",
      "name": "Professional Letters, First Class",
      "meta": null
    }
  }
}