[Development Guides Home](/guides) >> [Guide to Template Toolkit](/guides/guide-to-template-toolkit)

# Guide to Template Toolkit - API Calls from Template Toolkit

## Introduction

cPanel & WHM uses template files to construct interfaces that call cPanel's API functions. Template Toolkit files for cPanel & WHM templates use the same formatting as other Template Toolkit files. For more information, read the [Template::Manual](http://template-toolkit.org/docs/manual/index.html) documentation.

Warning:
* You **cannot** use Template Toolkit files to call WHM API 1 functions.
* If you use Template Toolkit files in a WHM plugin, you must add the function in a Perl script. For more information, read our [Guide to WHM Plugins](/guides/guide-to-whm-plugins/) documentation.


## API calls

Note:
Enter these API functions in the Template Toolkit file format.

### UAPI


```
[% execute( 'Module', 'function', { 'parameter' => 'value', 'parameter' => 'value', 'parameter' => 'value', } ); %]
```

Note:
For more information about UAPI calls, read our [UAPI](https://api.docs.cpanel.net/cpanel/introduction) documentation.

### cPanel API 2


```
[% USE Api2; Api2.exec( 'Module', 'function', { 'parameter' => 'value', 'parameter' => 'value', 'parameter' => 'value', } ); %]
```

Note:
For more information about cPanel API 2 calls, read our [cPanel API 2](https://api.docs.cpanel.net) documentation.

### cPanel API 1

Warning:
cPanel API 1 is **deprecated**. We **strongly** recommend that you use [cPanel API 2](https://api.docs.cpanel.net) or [UAPI](https://api.docs.cpanel.net/cpanel/introduction) instead.


```
[% USE Api1; Api1.exec( 'Module', 'function', { 'value', 'value', 'value', } ); %]
```

Note:
* cPanel API 1 calls use numbered, rather than named, parameters.
* For more information about cPanel API 1 calls, read our [Guide to cPanel API 1](https://api.docs.cpanel.net/cpanel/introduction) documentation.


These examples use the following variables:

| Variable | Description | Possible values | Example |
|  --- | --- | --- | --- |
| `Module` | The function's module. | Any module in the specified API. | `Email` |
| `function ` | The function name. | Any function in the specified module. | `addpop` |
| `parameters` | The function's input parameters. | Any parameter from the specified function. | `domain` |
| `value` | The values to assign to the input parameter. | Parameters accept a variety of values. | example.com |


### Example

The following example code calls UAPI's [`Email::list_lists`](https://api.docs.cpanel.net/openapi/cpanel/operation/list_lists/) function.


```
[% lists = execute('Email', 'list_lists', { 'domain' => 'example.com' }) %]
[% FOREACH q = lists.data %]
<p> [% q.list %] - [% q.humandiskused %] </p>
[% END %]
```

* Line 1 calls UAPI's [`Email::list_lists`](https://api.docs.cpanel.net/openapi/cpanel/operation/list_lists/) function and returns the data to the `lists` variable.
* Line 2 sets up a loop that repeats for each entry in the function's output.
* Line 3 returns text in paragraph tags. The template will replace the variables with the values from the function's `list` and `humandiskused` output parameters.
* Line 4 ends the loop when the template has returned a line for each `list` in the function's output.


In the interface, this template code could display the following results:


```undefined
list@example.com - 17.2 KB
admins@example.com - 1.7 MB
curmudgeons@example.com - 47.4 GB
```