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

# Create Template

> Uploads a new document template definition with fields and processing instructions. Returns the created template metadata.

### Request Format

**Option 1:Multipart Form Data**

```http
POST /api/templates
Content-Type: multipart/form-data
X-API-Key: <api_key>

file: <binary file>
name: <template name>
description: <template description>
extractFields: ["field1", "field2", ...]
instructions: <optional custom instructions>
```

### Parameters

| Parameter     | Type      | Required | Location | Description                                                                |
| ------------- | --------- | -------- | -------- | -------------------------------------------------------------------------- |
| file          | File      | Yes      | Body     | Document file (sample PDF/image) used to define the template               |
| name          | String    | Yes      | Body     | Template name (e.g., `"General"`)                                          |
| description   | String    | Yes      | Body     | Short description of the template (e.g., `"Invoice"`)                      |
| extractFields | String\[] | Yes      | Body     | List of fields to extract (e.g., company name, invoice total, due date, …) |
| instructions  | String    | No       | Body     | Additional processing instructions (custom rules or extraction logic)      |
| api\_key      | String    | Yes      | Header   | API key                                                                    |

<Note>extractFields must be passed as a JSON array string.</Note>

<RequestExample>
  ```bash cURL
  curl -X POST "https://api.clevrscan.com/api/templates" \
    -H "X-API-Key: <api_key>" \
    -F "file=@invoice.pdf" \
    -F "name=General" \
    -F "description=Invoice" \
    -F "extractFields=[\"Company Name\",\"Company Address\",\"Bill To\",\"Ship To\",\"Invoice Number\",\"Invoice Date\",\"P.O. Number\",\"Due Date\",\"Invoice Total\",\"Quantity\",\"Description\",\"Unit Price\",\"Amount\",\"Subtotal\",\"GST\",\"Terms & Conditions\",\"Payment Due Date\",\"Bank Name\",\"Account Number\",\"Routing Number\"]" \
    -F "instructions="
  ```
</RequestExample>

<ResponseExample>
  ```json Sample Response
  {
    "message": "Template created successfully",
    "template_id": 396
  }
  ```
</ResponseExample>
