# List a WhatsApp number's templates

> GET /v1/whatsapp/senders/{sender_id}/templates

The message templates Meta has approved for this number's business account: the ones a conversation can be started with. Write and approve them in WhatsApp Manager. Needs `whatsapp:write`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `sender_id` | path | string (uuid) | Yes |  |

## Answer

`200` with [WhatsappTemplateList](/reference/objects/WhatsappTemplateList).

## Errors

Every error is a [problem document](/errors) with a stable `code`.

| Status | When |
|---|---|
| `401` | The key is missing, mistyped, unknown, revoked or expired. |
| `403` | The key lacks a permission, a live key was sent from a browser, or the organization is frozen and the request would change something. |
| `404` | This key reaches no such WhatsApp number. |
| `409` | The connection has no business account id or access token. |
| `422` | Validation Error |
| `429` | Too many requests for this key or its organization; see `Retry-After`. |
| `500` | Something went wrong on our side. Quote the `request_id` to support. |
| `501` | This deployment does not run WhatsApp. |

## Examples

**curl**

```sh
#!/bin/sh
# List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
curl -sS --fail-with-body -X GET "https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates" \
  -H "Authorization: Bearer $AIGENTLY_API_KEY"
```

**JavaScript**

```js
// List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
const response = await fetch("https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.AIGENTLY_API_KEY}`,
  },
});
const answer = await response.json();
if (!response.ok) throw new Error(`${answer.code}: ${answer.detail}`);
console.log(answer);
```

**Python**

```python
# List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
# pip install httpx
import os

import httpx

response = httpx.get(
    "https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates",
    headers={
        "Authorization": f"Bearer {os.environ['AIGENTLY_API_KEY']}",
    },
)
if response.is_error:
    raise SystemExit(response.text)
print(response.json())
```

**Go**

```go
// List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	request, err := http.NewRequest("GET", "https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates", nil)
	if err != nil {
		panic(err)
	}
	request.Header.Set("Authorization", "Bearer "+os.Getenv("AIGENTLY_API_KEY"))
	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()
	body, _ := io.ReadAll(response.Body)
	if response.StatusCode >= 400 {
		fmt.Fprintln(os.Stderr, string(body))
		os.Exit(1)
	}
	fmt.Println(string(body))
}
```

**Java**

```java
// List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates"))
            .header("Authorization", "Bearer " + System.getenv("AIGENTLY_API_KEY"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();
        // HTTP/1.1: on a plain-http address Java's default asks to upgrade, which not every
        // server allows.
        HttpClient client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
        HttpResponse<String> response =
            client.send(request, HttpResponse.BodyHandlers.ofString());
        if (response.statusCode() >= 400) {
            System.err.println(response.body());
            System.exit(1);
        }
        System.out.println(response.body());
    }
}
```

**C#**

```csharp
// List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
using System.Net.Http.Headers;
using System.Text;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("AIGENTLY_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates")
{
};
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
    Console.Error.WriteLine(body);
    return 1;
}
Console.WriteLine(body);
return 0;
```

**PHP**

```php
<?php
// List a WhatsApp number's templates. Write and approve them in WhatsApp Manager.
$curl = curl_init("https://api.aigently.ai/v1/whatsapp/senders/7d9f1b3d-5f7b-4d9f-c1b3-d5f7b9dbfd1f/templates");
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("AIGENTLY_API_KEY"),
    ],
]);
$body = curl_exec($curl);
if (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) >= 400) {
    fwrite(STDERR, $body . "\n");
    exit(1);
}
echo $body, "\n";
```
