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

# Get User Templates

> Retrieves all private templates belonging to the authenticated user

The `/templates` endpoint retrieves all private templates belonging to the authenticated user.

## Request

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication.
</ParamField>

## Response

Returns an array of template objects. Each template includes:

<ResponseField name="id" type="string">
  The unique identifier for the template.
</ResponseField>

<ResponseField name="name" type="string">
  The name of the template.
</ResponseField>

<ResponseField name="description" type="string">
  The description of the template.
</ResponseField>

<ResponseField name="category" type="string">
  The category of the template.
</ResponseField>

<ResponseField name="tags" type="array">
  The tags associated with the template.
</ResponseField>

<ResponseField name="usage_count" type="integer">
  The number of times this template has been used.
</ResponseField>

<ResponseField name="fields" type="array">
  The field definitions for the template, from the latest version of the template. Each field follows the same structure as described in the suggest-fields response.
</ResponseField>

<ResponseField name="is_public" type="boolean">
  Whether the template is public or private.
</ResponseField>

<ResponseField name="user_id" type="string">
  The ID of the user who owns this template.
</ResponseField>

<ResponseField name="created_at" type="string">
  When the template was created (ISO 8601 format).
</ResponseField>

<ResponseField name="updated_at" type="string">
  When the template was last updated (ISO 8601 format).
</ResponseField>

## Examples

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.vizapi.ai/v1/templates \
    -H "x-api-key: YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const fetch = require('node-fetch');

  async function getUserTemplates() {
    const response = await fetch('https://api.vizapi.ai/v1/templates', {
      method: 'GET',
      headers: {
        'x-api-key': 'YOUR_API_KEY'
      }
    });
    
    const data = await response.json();
    console.log(data);
  }

  getUserTemplates();
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.vizapi.ai/v1/templates"
  headers = {
      "x-api-key": "YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  data = response.json()
  print(data)
  ```
</CodeGroup>

### Example Response

```json theme={null}
[
  {
    "id": "template_12345",
    "name": "Plant Disease Detector",
    "description": "Template for analyzing plant health and detecting diseases",
    "category": "agriculture",
    "tags": ["farming", "disease-detection"],
    "usage_count": 25,
    "fields": [
      {
        "name": "plant_species",
        "type": "string",
        "description": "The species of plant being analyzed",
        "required": true,
        "return_as_list": false,
        "subfields": [],
        "enum_values": []
      },
      {
        "name": "disease_detected",
        "type": "boolean",
        "description": "Whether disease is present in the plant",
        "required": true,
        "return_as_list": false,
        "subfields": [],
        "enum_values": []
      },
      {
        "name": "severity_level",
        "type": "string",
        "description": "The severity level of detected disease",
        "required": false,
        "return_as_list": false,
        "subfields": [],
        "enum_values": ["mild", "moderate", "severe"]
      }
    ],
    "is_public": false,
    "user_id": "user_67890",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-20T14:45:00Z"
  },
  {
    "id": "template_67890",
    "name": "Object Detection Template",
    "description": "Template for detecting and counting objects in images",
    "category": "detection",
    "tags": ["object-detection", "counting"],
    "usage_count": 12,
    "fields": [
      {
        "name": "object_type",
        "type": "string",
        "description": "The type of object detected",
        "required": true,
        "return_as_list": false,
        "subfields": [],
        "enum_values": []
      },
      {
        "name": "object_count",
        "type": "number",
        "description": "The number of objects detected",
        "required": true,
        "return_as_list": false,
        "subfields": [],
        "enum_values": []
      },
      {
        "name": "confidence_score",
        "type": "number",
        "description": "The confidence score of the detection",
        "required": true,
        "return_as_list": false,
        "subfields": [],
        "enum_values": []
      }
    ],
    "is_public": false,
    "user_id": "user_67890",
    "created_at": "2024-01-10T09:15:00Z",
    "updated_at": "2024-01-18T16:20:00Z"
  }
]
```

## Error Codes

| Status Code | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| 401         | Unauthorized - Invalid or missing API key                           |
| 500         | Internal Server Error - An unexpected error occurred on our servers |
