# Templates

## List templates

<mark style="color:blue;">`GET`</mark> `https://api.usestencil.com/v1/projects/:project_id/templates`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| project\_id | string | Project ID  |

#### Query Parameters

| Name   | Type   | Description                   |
| ------ | ------ | ----------------------------- |
| before | string | Query the previous result set |
| after  | string | Query the next result set     |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "meta":{
    "next":null,
    "previous":null,
    "total_count":2
  },
  "results":[
    {
      "available_modifications":[
        [
          {
            "description":"URL of the image",
            "field":"src",
            "primary":true,
            "required":true,
            "type":"string",
            "value":"https//example.com/image.png"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"image_3"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ],
        [
          {
            "description":"Value for the textbox",
            "field":"text",
            "primary":true,
            "required":true,
            "type":"string",
            "value":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
          },
          {
            "description":"Text color",
            "field":"fill",
            "primary":false,
            "required":false,
            "type":"string",
            "value":"rgba(15, 15, 15, 1)"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"circular_text_2"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ],
        [
          {
            "description":"Value for the textbox",
            "field":"text",
            "primary":true,
            "required":true,
            "type":"string",
            "value":"ينا الألم. في بعض الأحيان ونظراً للالتزامات التي يفرضها علينا الواجب والعمل سنتنازل غالباً ونرفض الشعور"
          },
          {
            "description":"Text color",
            "field":"fill",
            "primary":false,
            "required":false,
            "type":"string",
            "value":"rgba(0, 0, 0, 1)"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"text_5"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ]
      ],
      "created_at":"2021-05-22T05:00:44Z",
      "id":"10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
      "name":"Test2",
      "project_id":"f2eb2dab-a861-4960-b5f4-d54c61552f7d",
      "self":"https://api.usestencil.com/v1/templates/10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
      "signed_image_base":"Hts6NWUuvtXbmGaQbM2kGM",
      "starred":false,
      "updated_at":"2021-05-22T05:00:59Z"
    },
    {
      "available_modifications":[
        [
          {
            "description":"URL of the image",
            "field":"src",
            "primary":true,
            "required":true,
            "type":"string",
            "value":"https//example.com/image.png"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"image_3"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ],
        [
          {
            "description":"Value for the textbox",
            "field":"text",
            "primary":true,
            "required":true,
            "type":"string",
            "value":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
          },
          {
            "description":"Text color",
            "field":"fill",
            "primary":false,
            "required":false,
            "type":"string",
            "value":"rgba(15, 15, 15, 1)"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"circular_text_2"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ],
        [
          {
            "description":"Text color",
            "field":"fill",
            "primary":false,
            "required":false,
            "type":"string",
            "value":"rgba(0, 0, 0, 1)"
          },
          {
            "description":"Object identifier",
            "field":"name",
            "primary":false,
            "required":true,
            "type":"string",
            "value":"text_5"
          },
          {
            "description":"Angle of the object",
            "field":"angle",
            "primary":false,
            "required":false,
            "type":"integer",
            "value":0
          }
        ]
      ],
      "created_at":"2021-05-22T04:59:03Z",
      "id":"70176253-3bcb-4592-913d-a6c5df83a258",
      "name":"Untitled",
      "project_id":"f2eb2dab-a861-4960-b5f4-d54c61552f7d",
      "self":"http://api.usestencil.com/v1/templates/70176253-3bcb-4592-913d-a6c5df83a258",
      "signed_image_base":"Hts6NWUuvtXbmGaQbM2kGM",
      "starred":true,
      "updated_at":"2021-05-22T07:43:02Z"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`after` and `before` are related to pagination. Please see [pagination](/api/pagination.md) page for more information&#x20;
{% endhint %}

## Get specific template

<mark style="color:blue;">`GET`</mark> `https://api.usestencil.com/v1/templates/:id`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | Template ID |

#### Query Parameters

| Name   | Type   | Description                   |
| ------ | ------ | ----------------------------- |
| before | string | Query the previous result set |
| after  | string | Query the next result set     |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "available_modifications":[
    [
      {
        "description":"URL of the image",
        "field":"src",
        "primary":true,
        "required":true,
        "type":"string",
        "value":"https://example.com/image.png"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"image_3"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ],
    [
      {
        "description":"Value for the textbox",
        "field":"text",
        "primary":true,
        "required":true,
        "type":"string",
        "value":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
      },
      {
        "description":"Text color",
        "field":"fill",
        "primary":false,
        "required":false,
        "type":"string",
        "value":"rgba(15, 15, 15, 1)"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"circular_text_2"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ],
    [
      {
        "description":"Text color",
        "field":"fill",
        "primary":false,
        "required":false,
        "type":"string",
        "value":"rgba(0, 0, 0, 1)"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"text_5"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ]
  ],
  "created_at":"2021-05-22T05:00:44Z",
  "id":"10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
  "name":"Test2",
  "project_id":"f2eb2dab-a861-4960-b5f4-d54c61552f7d",
  "self":"https://api.usestencil.com/v1/templates/10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
  "signed_image_base":"Hts6NWUuvtXbmGaQbM2kGM",
  "starred":false,
  "updated_at":"2021-05-22T05:00:59Z"
}
```

{% endtab %}
{% endtabs %}

### Response

#### `available_modification` object

| Property      | Description                                                    |
| ------------- | -------------------------------------------------------------- |
| `description` | Description of the property                                    |
| `field`       | Field unique identifier                                        |
| `value`       | Value of the field                                             |
| `required`    | Indicate that the value must be specified                      |
| `type`        | The type of value i.e. Integer requires number to be specified |

#### `signed_image_base`

Base ID for secure signed image. See [Secure Signed Image](/integrations/secure-signed-image/signed-image.md) for more information.

The rests of the fields are self explanatory.&#x20;

## Copy a template

<mark style="color:green;">`POST`</mark> `https://api.usestencil.com/v1/templates/:id/copy`&#x20;

Duplicate a template

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Query string**

| Name | Value       |
| ---- | ----------- |
| id   | Template ID |

**Body**

| Name         | Type   | Description                                                                   |
| ------------ | ------ | ----------------------------------------------------------------------------- |
| `name`       | string | Optional. New name for the template. Default to existing name.                |
| `project_id` | string | Optional. Project ID to duplicate the project to. Default to current project. |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "available_modifications":[
    [
      {
        "description":"URL of the image",
        "field":"src",
        "primary":true,
        "required":true,
        "type":"string",
        "value":"https://example.com/image.png"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"image_3"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ],
    [
      {
        "description":"Value for the textbox",
        "field":"text",
        "primary":true,
        "required":true,
        "type":"string",
        "value":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do..."
      },
      {
        "description":"Text color",
        "field":"fill",
        "primary":false,
        "required":false,
        "type":"string",
        "value":"rgba(15, 15, 15, 1)"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"circular_text_2"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ],
    [
      {
        "description":"Text color",
        "field":"fill",
        "primary":false,
        "required":false,
        "type":"string",
        "value":"rgba(0, 0, 0, 1)"
      },
      {
        "description":"Object identifier",
        "field":"name",
        "primary":false,
        "required":true,
        "type":"string",
        "value":"text_5"
      },
      {
        "description":"Angle of the object",
        "field":"angle",
        "primary":false,
        "required":false,
        "type":"integer",
        "value":0
      }
    ]
  ],
  "created_at":"2021-05-22T05:00:44Z",
  "id":"10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
  "name":"Test2",
  "project_id":"f2eb2dab-a861-4960-b5f4-d54c61552f7d",
  "self":"https://api.usestencil.com/v1/templates/10dee897-cc28-4ae1-bf8e-f1bc1c551fe3",
  "signed_image_base":"Hts6NWUuvtXbmGaQbM2kGM",
  "starred":false,
  "updated_at":"2021-05-22T05:00:59Z"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.usestencil.com/api/endpoints/templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
