Authentication
Standard Authentication
In order to use Turn's REST API you will need to use the Turn UI. In the Turn UI > Settings > API & Webhooks, click Create a Token button. This option allows you to generate a new token by specifying its name and expiration date.
Turn expects for the access token to be included in all API requests to the server in a header that looks like the following:
Authorization: Bearer token
You must replace token with your personal access token.
Turn.io Graph Endpoint Authentication
This method should be used with caution since generating a new access token will invalidate the previously generated token for this number. If the previous token is actively being used for a service or integration, invalidating it will result in service disruptions or integration failures.
To generate a token without invalidating the previous one use, create a token within the Turn UI.
If you need direct access to the endpoints at https://whatsapp.turn.io/graph/<API_VERSION>/<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/ then you can generate the necessary token like so:
# Use Basic Auth over HTTPS to get an access token
$ curl -X POST \
--user 'username:password' \
https://whatsapp.turn.io/v1/users/login
> {
"users": [{
"token": "eyJhbGciOHlXVCJ9.eyJ1c2VyIjoNTIzMDE2Nn0.mEoF0COaO00Z1cANo",
"expires_after": "2018-03-01 15:29:26+00:00"
}]
}
Make sure to replace
username:passwordwith your username and password.
You can get your username and password from the Turn UI > Settings > API & Webhooks. With it you can request an API access token.