How to use your bearer access token

Before you invoke an API call, you must be authenticated. When you have authenticated, you must mark each subsequent request with an HTTP header—Authorization with the Bearer access token set.

Your token expires after 1 hour. You can reuse your token as many times as you like during that time. To reuse your token, simply cache it and, each time you make a request, grab the token from your cache.

To avoid errors being returned by your API request due to an expired token, intercept 401 Unauthorized errors with a The access token is invalid or has expired message that your request receives when you use your cached token. If you receive such a message, request a new token and replace the cached value with the new one.

Headers

Authorization (required)

Bearer {access_token} 

Where {access_token} was returned in the response after invoking getting a bearer access token. For information on getting a bearer access token, see Getting a bearer access token.

Example


Most URLs in the example code use the following values:

  • ***. To access the API for your region, replace *** with the correct subdomain for your region:
  • a1b2c3d4e5. The value represents the Vonage Contact Center account on which the API request is run. To run the API request on your account data, you must replace a1b2c3d4e5, where used, with your account's API key. For example, if your API key is mtovfiliti3, use mtovfiliti3 in place of a1b2c3d4e5.
  • <ACCESS_TOKEN>. The value represents a bearer access token which you must use to validate every request. Replace <ACCESS_TOKEN> where used with your bearer access token. For information about getting a bearer access token, see Getting a bearer access token.

curl -H "Authorization: Bearer a1b2c3d4e5f6g7h8i9j0"
-X GET "https://***.cc.vonage.com/v0/123456/calls/94e5928c-7f7e-4645-ad72-61010f