Get and use your API Token
General
To interact with our WhatsApp API you always need an API token. Every time you send a HTTP REST request to our WhatsApp API,
you need to add a Authorization
header to your request. The value of the header is your API token as a Bearer token
.
You should also always add a Accept
and Content-Type
header to ensure to send and receive JSON!
Header Name | Header Value |
---|---|
Authorization | Bearer your-api-token |
Accept | application/json |
Content-Type | application/json |
PHP Example
$apiToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://waapi.app/api/v1/instances', [
'headers' => [
'Authorization' => 'Bearer ' . $apiToken,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
]
]);
$responseBody = json_decode($response->getBody(), true);
$instances = $responseBody['instances']; //array of all instances of the authenticated user
foreach ($instances as $instance) {
$id = $instance['id'];
$ownerEmail = $instance['owner'];
$webhookUrl = $instance['webhook_url']; //this webhook url will receive the subscribed events
$webhookEvents = $instance['webhook_events']; //array of subscribed events
}
Create an API token
Login to your account. If you do not have an account yet, create a new account and verify your email address.
Please ensure that you have subscribed to one of our billing plans. You can also use our trial version to get familiar with
our WhatsApp API.
Navigate to User API Tokens. Here you can create new API tokens, edit the permissions of existing
API tokens or delete existing tokens.
If you create a new API token, you can choose any name for it. The name does not matter and is only for your token management.
API tokens **never** expire! You need to delete them by your own if needed.
API token permissions
API tokens can have different permissions:
Permission | Description |
---|---|
create | Create new instances up to your total instance limit. |
delete | Completely delete existing instances. This will decrease your total instance limit. |
read | Receive information of all or a single of your existing instances (e.g. read the instance id, webhook url, the instance owner or the subscribed events). |
update | Update an existing instance (e.g. change the webhook url or edit the subscription to events). |