> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tapace.lk/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a template

> Creates a template from a definition.

Most teams design templates in the dashboard. To create one in code, start from a design you like: [get that template](/api-reference/templates/get), then send its `definition` here with your changes. Upload images first with [Upload an asset](/api-reference/assets/upload) and reference their IDs in `definition.images`.

<ParamField header="Idempotency-Key" type="string" required>
  A unique value for this request.
</ParamField>

<ParamField body="name" type="string" required>
  The template's name, from 1 to 100 characters.
</ParamField>

<ParamField body="type" type="string" required>
  `generic` or `event_ticket`.
</ParamField>

<ParamField body="definition" type="object" required>
  The design: colours, images, barcode, platforms and fields. It's checked against the template schema, and each problem is listed in `error.issues`.
</ParamField>

### Response

Returns the new [template](/api-reference/templates/get) with `revision` 1 and status `201`.

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.tapace.lk/v1/templates \
    -H "Authorization: Bearer $TAPACE_API_KEY" \
    -H "Idempotency-Key: 7d3b9e2a-1c5f-4a8d-b6e2-4a9c1f7d3b50" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Gold membership",
      "type": "generic",
      "definition": {
        "schemaVersion": 1,
        "type": "generic",
        "description": "Gold membership card",
        "organizationName": "FORM Fitness",
        "colors": { "background": "#111827", "foreground": "#ffffff" },
        "platforms": { "apple": true, "google": true },
        "images": { "icon": "asset_Xr9Lm2Qv7Tn4Kp8Zs1Wd" },
        "config": {
          "fields": {
            "primary": [
              { "key": "memberName", "label": "Member", "binding": "perPass", "required": true }
            ]
          }
        }
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "object": "template",
    "id": "tmpl_Q4vN8xT2mLr7KpZs3Wd1",
    "type": "generic",
    "name": "Gold membership",
    "revision": 1,
    "archived": false,
    "requiredFields": ["memberName"],
    "createdAt": "2026-10-13T09:00:00.000Z",
    "updatedAt": "2026-10-13T09:00:00.000Z",
    "definition": { "schemaVersion": 1, "type": "generic" }
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.