---
title: "Create a template from an envelope"
method: POST
path: "/api/v1/templates"
tags: ["Templates"]
---

# Create a template from an envelope

`POST /api/v1/templates`

Supports the optional Idempotency-Key header. Repeating the same key and request replays the original 201 response; a key currently in flight returns 409, and reusing a key with a different request returns 422.

## Request body

- object
  - `sourceEnvelopeId` string, required
  - `name` string, required
  - `roles` object[]
    - `participantId` string
    - `partyIndex` integer
    - `name` string, required
    - `isSender` boolean

## Response `201`

Template graph created

- object
  - `template` object, required
    - `id` string, required
    - `organizationId` string, required
    - `teamId` string, nullable, required
    - `name` string, required
    - `originalFilename` string, required
    - `sourceFormat` string, required
    - `contentHash` string, required
    - `sizeBytes` number, required
    - `archivedAt` string, date-time, nullable, required
    - `useCount` integer, required
    - `lastUsedAt` string, date-time, nullable, required
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required
  - `roles` object[], required
    - `id` string, required
    - `templateId` string, required
    - `name` string, required
    - `orderIndex` integer, required
    - `isSender` boolean, required
  - `fields` object[], required
    - `id` string, required
    - `templateId` string, required
    - `roleId` string, required
    - `type` 'signature' | 'initials' | 'date' | 'text' | 'checkbox', required
    - `page` integer, required
    - `x` number, required
    - `y` number, required
    - `width` number, required
    - `height` number, required
    - `label` string, nullable, required
    - `required` boolean, required
    - `prefillValue` string, nullable, required
    - `autoSource` 'signed_date' | 'participant_name' | 'participant_email' | 'participant_company' | 'participant_title' | 'sender_org_name' | 'null', nullable, required
    - `prefillKey` string, nullable, required

## Other responses

- `401` — Missing or invalid API key
- `404` — Source envelope not found in this organization
- `409` — An idempotent request with this key is already in flight
- `422` — Source envelope or role overrides are not valid for a template
- `502` — Document storage copy failed

---

[API](https://skmtc.dev/atlaswork/apis/atlas-api.md) · [All operations](https://skmtc.dev/atlaswork/apis/atlas-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/atlaswork/atlas-api/revisions/a8a1e7479c90/schema)
