---
title: "Create Templates via API for Seamless Document Flow"
description: "Learn how to create templates in BoldSign using its API. Explore step-by-step instructions for template creation, optimizing workflow efficiency."
url: "https://boldsign.com/blogs/how-to-create-a-template-via-api/"
---

1. [Blog](https://boldsign.com/blogs.md)
2. [API](https://boldsign.com/category/api.md)

# Create Templates via API for Seamless Document Flow

[Gopinath Kannusamy](https://boldsign.com/author/gopinath-kannusamy/) April 10, 2024 Updated July 23, 2026 4 min read

Document workflow management can often be time-consuming, especially when repetitive tasks are involved. In this blog post, we will explore how to streamline document creation and distribution using the BoldSign API. Specifically, we’ll delve into the process of [creating templates via API](https://developers.boldsign.com/template/create-template), enabling you to save time and enhance efficiency in managing contracts and agreements.

## Why Templates Matter

Imagine needing to send the same contracts to different groups of individuals regularly. Creating templates allows you to reduce the time and effort required significantly. With the BoldSign API, you can easily generate templates for various purposes, whether it’s for self-signing or sending signature requests to multiple signers.

## Asynchronous Template Processing

One aspect to understand about template creation is that it’s an asynchronous process. Although you’ll receive a template ID promptly upon initiation, the actual file creation may still be underway in the background. To confirm whether the template has been successfully created, you’ll need to listen for webhooks.

Upon completion, the system triggers either a **TemplateCreated** or **TemplateCreateFailed** event, indicating success or failure, respectively. If the creation fails, an error message will be provided. Resolving any errors promptly ensures seamless template creation in subsequent requests.Troubleshooting and resolution details are covered in the [Template not found](https://support.boldsign.com/kb/article/20310/solve-the-template-not-found-error-when-using-template-via-the-boldsign-api) guide.

See [Available webhook events](https://developers.boldsign.com/webhooks/available-events) and Validate and [verify webhook events](https://developers.boldsign.com/webhooks/verify-webhook-events) for implementation and security guidance

## Code Snippets

Let’s explore code snippets in various programming languages to demonstrate how to [create templates](https://support.boldsign.com/kb/article/19270/create-a-template-using-boldsign-api) via the BoldSign API.

```
curl -X 'POST' \
  \ 'https://api.boldsign.com/v1/template/create' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {YOUR_API_KEY}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'DocumentMessage=Document message for signers' \
  -F 'Files=@{YOUR_FILE_PATH};type=application/pdf' \
  -F 'Title=Title of the template' \
  -F 'DocumentTitle=Title of the document' \
  -F 'Roles={
  "name": "Hr",
  "index": 1,
  "defaultSignerName": "Alex Gayle",
  "defaultSignerEmail": "alexgayle@cubeflakes.com",
  "signerOrder": 1,
  "signerType": "Signer",
  "formFields": [
    {
      "id": "sign_id",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 50,
        "y": 100,
        "width": 100,
        "height": 60
      }
    }
  ]
}'
```

```
var apiClient = new ApiClient("https://api.boldsign.com", "{YOUR_API_KEY}");
var templateClient = new TemplateClient(apiClient);
var documentFilePath = new DocumentFilePath
{
    ContentType = "application/pdf",
    FilePath = "{YOUR_FILE_PATH}",
};
var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};
var signatureField = new FormField(
    id: "sign_id",
    type: FieldType.Signature,
    pageNumber: 1,
    bounds: new Rectangle(x: 50, y: 100, width: 100, height: 60));
var formFieldsCollections = new List<FormField>
{
    signatureField,
};
var templateRole = new TemplateRole(
    roleIndex: 1,
    name: "Hr",
    defaultSignerName: "Alex Gayle",
    defaultSignerEmail: "alexgayle@cubeflakes.com",
    signerOrder: 1,
    signerType: SignerType.Signer,
    formFields: formFieldsCollections);
var roles = new List<TemplateRole>
{
    templateRole,
};
var templateRequest = new CreateTemplateRequest()
{
    Title = "Title of the template",
    DocumentMessage = "Document message for signers",
    Files = filesToUpload,
    DocumentTitle = "Title of the document",
    Roles = roles
};
var templateCreated = templateClient.CreateTemplate(templateRequest);
```

```
import boldsign

configuration = boldsign.Configuration(api_key="YOUR_API_KEY")

with boldsign.ApiClient(configuration) as api_client:

    template_api = boldsign.TemplateApi(api_client)

    form_field = boldsign.FormField(
        fieldType="Signature",
        page_number=1,
        bounds=boldsign.Rectangle(x=50, y=100, width=100, height=60),
    )

    role = boldsign.TemplateRole(
        index=1,
        name="Hr",
        defaultSignerName="Alex Gayle",
        defaultSignerEmail="alexgayle@cubeflakes.com",
        signerType="Signer",
        signerOrder=1,
        formFields=[form_field],
    )

    create_template_request = boldsign.CreateTemplateRequest(
        title="Title of the template",
        documentTitle="Title of the document",
        documentMessage="Document message for signers",
        roles=[role],
        files=["YOUR_FILE_PATH"],
    )

    template_created = template_api.create_template(create_template_request=create_template_request)
```

```
<?php require_once "vendor/autoload.php";

use BoldSign\Configuration;
use BoldSign\Api\TemplateApi;
use BoldSign\Model\{FormField, Rectangle, TemplateRole, CreateTemplateRequest};

$config = new Configuration();
$config->setApiKey('YOUR_API_KEY');

$template_api = new TemplateApi($config);

$form_field = new FormField();
$form_field->setFieldType('Signature');
$form_field->setPageNumber(1);
$bounds = new Rectangle([50, 100, 100, 60]);
$form_field->setBounds($bounds);

$role = new TemplateRole();
$role->setIndex(1);
$role->setName('Hr');
$role->setDefaultSignerName('Alex Gayle');
$role->setDefaultSignerEmail('alexgayle@cubeflakes.com');
$role->setSignerType('Signer');
$role->setSignerOrder(1);
$role->setFormFields([$form_field]);

$create_template = new CreateTemplateRequest();
$create_template->setTitle('Title of the template');
$create_template->setDocumentTitle('Title of the document');
$create_template->setDocumentMessage('Document message for signers');
$create_template->setRoles([$role]);
$create_template->setFiles(['YOUR_FILE_PATH']);

$template_created = $template_api->createTemplate([$create_template]);
```

```
ApiClient client = Configuration.getDefaultApiClient();
client.setApiKey("YOUR_API_KEY");

TemplateApi templateApi = new TemplateApi(client);

FormField signatureField = new FormField();
signatureField.setFieldType(FormField.FieldTypeEnum.SIGNATURE);
signatureField.setPageNumber(1);
Rectangle bounds = new Rectangle().x(50f).y(100f).width(100f).height(60f);
signatureField.setBounds(bounds);

TemplateRole templateRole = new TemplateRole();
templateRole.setIndex(1);
templateRole.setName("Hr");
templateRole.setDefaultSignerName("Alex Gayle");
templateRole.setDefaultSignerEmail("alexgayle@cubeflakes.com");
templateRole.setSignerType(TemplateRole.SignerTypeEnum.SIGNER);
templateRole.setSignerOrder(1);
templateRole.setFormFields(Arrays.asList(signatureField));

CreateTemplateRequest createTemplate = new CreateTemplateRequest();
createTemplate.setTitle("Title of the template");
createTemplate.setDocumentTitle("Title of the document");
createTemplate.setDocumentMessage("Document message for signers");
createTemplate.setRoles(Arrays.asList(templateRole));

File file = new File("YOUR_FILE_PATH");
createTemplate.setFiles(Arrays.asList(file));

TemplateCreated templateCreated = templateApi.createTemplate(createTemplate);
```

```
import { TemplateApi, CreateTemplateRequest, TemplateRole, Rectangle, FormField } from "boldsign";
import * as fs from "fs";

async function main() {
  const templateApi = new TemplateApi();
  templateApi.setApiKey("YOUR_API_KEY");

  const bounds = new Rectangle();
  bounds.x = 50;
  bounds.y = 100;
  bounds.width = 100;
  bounds.height = 60;

  const formField = new FormField();
  formField.fieldType = FormField.FieldTypeEnum.Signature;
  formField.pageNumber = 1;
  formField.bounds = bounds;

  const role = new TemplateRole();
  role.index = 1;
  role.name = "Hr";
  role.defaultSignerEmail = "alexgayle@cubeflakes.com";
  role.defaultSignerName = "Alex Gayle";
  role.signerType = TemplateRole.SignerTypeEnum.Signer;
  role.signerOrder = 1;
  role.formFields = [formField];

  const file = fs.createReadStream("YOUR_FILE_PATH");

  const createTemplateRequest = new CreateTemplateRequest();
  createTemplateRequest.title = "Title of the template";
  createTemplateRequest.documentTitle = "Title of the document";
  createTemplateRequest.documentMessage = "Document message for signers";
  createTemplateRequest.roles = [role];
  createTemplateRequest.files = [file];

  const templateCreated = templateApi.createTemplate(createTemplateRequest);
}

main();
```

> Please note that you must use either the fileUrls or files parameter in a request, both cannot be used together.

## How do you use a template to send documents?

Once the template is successfully created and confirmed through the **TemplateCreated** webhook event, it can be used to send documents for signing. When [sending a document](https://developers.boldsign.com/documents/send-document-from-template), you provide the templateId and assign real users to the predefined roles in the template. The document structure and form fields defined in the template remain unchanged, ensuring consistency across all sends.

## Conclusion

In conclusion, [creating templates](https://support.boldsign.com/kb/article/20/creating-templates) using the BoldSign API is an effective way to streamline and automate your document workflows. Instead of rebuilding documents from scratch, you can rely on reusable templates and focus only on the details that change. If you’re integrating BoldSign into your application, understanding template creation via the API is an essential part of building fast, reliable signing experiences.

To explore and test these features safely, create a free [BoldSign Sandbox account](https://account.boldsign.com/signup?planId=1076\&utm_source=boldsignblogs\&utm_medium=redirect\&utm_campaign=boldsign) and start experimenting with the API right away.\
If you need help or have questions, feel free to comment below, [book a demo](https://boldsign.com/request-demo.md) , or reach out to our support team through the [support portal](https://support.boldsign.com/support/tickets/create).

Topics [API integration](https://boldsign.com/blogs/tag/api-integration.md)[Templates](https://boldsign.com/blogs/tag/templates.md)

## Sign documents 3x faster

Send, sign and manage documents securely and efficiently.

[Try it today](https://account.boldsign.com/signup?planId=1018\&utm_source=boldsignblogs\&utm_medium=redirect\&utm_campaign=boldsign)

## Gopinath Kannusamy

Gopinath is a passionate software developer with 2 years of experience at BoldSign. He is an avid writer and enjoys sharing his insights on technology and development. In his free time, he enjoys exploring new technologies and learning new things. Connect with him on [LinkedIn](https://www.linkedin.com/in/gopinath-kannusamy-b7b84517a/).

[More posts by Gopinath Kannusamy](https://boldsign.com/author/gopinath-kannusamy/)

## Related posts

- [API](https://boldsign.com/category/api.md) September 29, 2026 10 min read

  ## [How to Migrate from Docusign Without Losing Templates or Workflow Continuity](https://boldsign.com/blogs/migrate-from-docusign.md)

  Learn how to migrate from Docusign while protecting templates, signed records, and active workflows. Explore key risks, a practical checklist, and next steps.

- [API](https://boldsign.com/category/api.md) September 22, 2026 9 min read

  ## [What Are the Common Challenges When Using Signature APIs in Software Development](https://boldsign.com/blogs/common-signature-api-challenges.md)

  Explore the common challenges developers face with a Signature API, from authentication issues to PDF rendering, webhooks, templates, and rate limits.

- [API](https://boldsign.com/category/api.md) September 18, 2026 6 min read

  ## [How to Safely Edit eSignature API Templates in Production](https://boldsign.com/blogs/edit-esignature-api-template.md)

  Learn what can break when you edit an eSignature API template, including roles, fields, and indexes, and how to update templates safely in production today.

Get started

## Sign up for your free trial today!

[Start free trial](https://account.boldsign.com/signup?planId=1018)

- 30-day free trial
- No credit card required

*Picture: A completed employment contract: signed by John Doe on 11/03/2026, all parties have signed*
