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

# List Templates

> Retrieves a list of all templates available for the authenticated company.

GET [https://api.pdfnoodle.com/v1/integration/templates](https://api.pdfnoodle.com/v1/integration/templates)

## Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api.pdfnoodle.com/v1/integration/templates' \
  --header 'Authorization: Bearer pdfnoodle_api_123456789'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.pdfnoodle.com/v1/integration/templates",
    {
      method: "GET",
      headers: {
        Authorization: "Bearer pdfnoodle_api_123456789",
      },
    }
  );

  const result = await response.json();
  ```

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

  response = requests.get(
      'https://api.pdfnoodle.com/v1/integration/templates',
      headers={
          'Authorization': 'Bearer pdfnoodle_api_123456789'
      }
  )

  result = response.json()
  ```
</CodeGroup>

## Response

<CodeGroup>
  ```json Success (200 OK) theme={null}
  {
    "templates": [
      {
        "id": "invoice-template-001",
        "displayName": "Standard Invoice"
      },
      {
        "id": "receipt-template-002",
        "displayName": "Receipt Template"
      }
    ]
  }
  ```

  ```json Empty Result (200 OK) theme={null}
  {
    "templates": []
  }
  ```
</CodeGroup>

This endpoint responds with `200 OK` and returns a list of all templates available for your company. Templates are returned sorted alphabetically by `displayName` in ascending order.

## Response Fields

<ParamField response="templates" type="array">
  List of template objects. Returns an empty array `[]` if no templates exist
  for the company.
</ParamField>

<ParamField response="templates[].id" type="string">
  Template identifier (this is the template `name` field, used for fetching
  templates and as the `templateId` parameter in other endpoints)
</ParamField>

<ParamField response="templates[].displayName" type="string">
  Human-readable template name
</ParamField>

## Usage

This endpoint is useful for:

* Displaying available templates in a UI
* Building template selection interfaces
* Discovering which templates are available before fetching details
* Getting template IDs to use with other endpoints

<Note>
  The `id` field in the response corresponds to the template's `name` field in
  the database. Use this value as the `templateId` or `name` parameter when
  fetching a specific template or its variables.
</Note>

## Usage Example

Here's a complete example of listing templates and then fetching details for a specific template:

<Tabs>
  <Tab title="Node.js">
    ```javascript theme={null}
    // List all templates
    const listResponse = await fetch(
      "https://api.pdfnoodle.com/v1/integration/templates",
      {
        headers: { Authorization: "Bearer pdfnoodle_api_123456789" },
      }
    );

    const { templates } = await listResponse.json();

    console.log("Available templates:", templates);

    // Get the first template's ID
    if (templates.length > 0) {
      const templateId = templates[0].id;
      console.log("First template ID:", templateId);

      // Fetch template details
      const templateResponse = await fetch(
        `https://api.pdfnoodle.com/v1/integration/templates/${templateId}`,
        {
          headers: { Authorization: "Bearer pdfnoodle_api_123456789" },
        }
      );

      const templateData = await templateResponse.json();
      console.log("Template details:", templateData);
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    # List all templates
    response = requests.get(
        'https://api.pdfnoodle.com/v1/integration/templates',
        headers={'Authorization': 'Bearer pdfnoodle_api_123456789'}
    )

    result = response.json()
    templates = result['templates']

    print('Available templates:', templates)

    # Get the first template's ID
    if templates:
        template_id = templates[0]['id']
        print('First template ID:', template_id)

        # Fetch template details
        template_response = requests.get(
            f'https://api.pdfnoodle.com/v1/integration/templates/{template_id}',
            headers={'Authorization': 'Bearer pdfnoodle_api_123456789'}
        )

        template_data = template_response.json()
        print('Template details:', template_data)
    ```
  </Tab>
</Tabs>

## Error Responses

### 401 Unauthorized

```json theme={null}
{
  "message": "Unauthorized"
}
```

**Occurs when:** The API key is missing or invalid.

### 500 Internal Server Error

```json theme={null}
{
  "message": "Couldnt get templates"
}
```

**Occurs when:** An internal server error prevents the operation from completing.
