# List template variables

> Read the variables of the template version being edited.

`GET https://api-connect.nxiom.com/api/v1/emails/templates/{templateId}/variables`

## Authorization

Requires `email.full_access`.

## Path parameters

| Field | Type | Description |
| --- | --- | --- |
| `templateId` | string · required | The template ID. |

## Request

### cURL

```shell
curl "https://api-connect.nxiom.com/api/v1/emails/templates/YOUR_TEMPLATE_ID/variables" \
  -H "Authorization: Bearer $NEXIOM_API_KEY"
```

### Node.js

```typescript
import { NexiomConnect } from '@nexiom/connect';

const apiKey = process.env.NEXIOM_API_KEY;
if (!apiKey) throw new Error('Set NEXIOM_API_KEY');

const nexiom = new NexiomConnect({ apiKey });

const { data, error } = await nexiom.templates.variables('YOUR_TEMPLATE_ID');

if (error) throw new Error(`${error.code}: ${error.message}`);
for (const variable of data) {
  console.log(variable.key, variable.type, variable.required);
}
```

### PHP

```php
<?php

use Nexiom\Connect\NexiomConnect;

$apiKey = getenv('NEXIOM_API_KEY');
if (!$apiKey) {
    throw new RuntimeException('Set NEXIOM_API_KEY');
}

$nexiom = new NexiomConnect($apiKey);

$variables = $nexiom->templates->variables('YOUR_TEMPLATE_ID');

foreach ($variables as $variable) {
    echo $variable['key'], ' ', $variable['type'], PHP_EOL;
}
```

## Response

HTTP `200`. Variables are ordered by `key`. See [Variables](/docs/learn/templates#variables) for what each field means.

This lists the variables of the draft when the template has one, otherwise of the published version. Sends always use the published version: to see exactly what a send needs while a draft exists, read `published_version.variables` from [Retrieve a template](/docs/api/templates/retrieve).

### 200 OK

Example successful response.

```json
{
  "data": [
    {
      "id": "variable_example",
      "key": "first_name",
      "type": "string",
      "required": true,
      "fallback_value": null
    },
    {
      "id": "variable_example_2",
      "key": "trial_days",
      "type": "number",
      "required": false,
      "fallback_value": 14
    }
  ]
}
```

### 401 Unauthorized

The API key is missing, malformed, revoked, or expired.

```json
{
  "error": "unauthorized",
  "message": "Invalid API key",
  "correlationId": "req_example"
}
```

### 403 Forbidden

The API key lacks a required permission, or its domain restriction does not allow this sender.

```json
{
  "error": "not_allowed",
  "message": "Missing required API key permissions: email.full_access",
  "correlationId": "req_example"
}
```

### 404 Not Found

No resource with this ID exists in the API key’s project.

```json
{
  "error": "not_found",
  "code": "resource_not_found",
  "message": "Resource not found",
  "correlationId": "req_example"
}
```

---

Source: https://connect.nxiom.com/docs/api/templates/variables
