Avetta Authentication API
## How to authenticate Every request to the Avetta APIs must include an `Authorization` header. You can fill it in using **one** of two methods. Pick the one that fits your integration; you do not need both. Option A: OAuth 2.0 Bearer Token Option B: API Key Best for Integrations that prefer a more secure authentication model using short-lived tokens Existing integrations already set up with an API key Works with All endpoints All endpoints Steps 2 steps: get a token, then send the token 1 step: send your key Expires Yes, after expires_in seconds (typically 3600 = 1 hour) No Header value Bearer <ACCESS_TOKEN> apikey <API_KEY> ### Before you start - You need credentials from Avetta. If you don't have them, contact [APISupport@avetta.com](mailto:APISupport@avetta.com). - Your credentials are your Avetta **`accountId`** and **`apikey`**. --- ## Option A: OAuth 2.0 Bearer Token This method takes two steps: first trade your credentials for a temporary access token, then send that token on each request. ### Step 1: Get an access token Send a `POST` request to `https://api.avetta.com/auth/v1/token`: ```bash curl --request POST 'https://api.avetta.com/auth/v1/token' \ --header 'Content-Type: application/json' \ --data '{ "grant_type": "client_api_credentials", "username": "", "password": "" }' ``` | Field | What to put in it | |---|---| | `grant_type` | Always `client_api_credentials` | | `username` | Your `accountId` | | `password` | Your `apikey` | A successful response looks like this: ```json { "access_token": "", "token_type": "Bearer", "expires_in": 3600 } ``` Copy the value of `access_token`. You will use it in Step 2. ### Step 2: Send the token on each request Add this header to every request: ``` Authorization: Bearer ``` **Example** ```bash curl 'https://api.avetta.com/api/v1/connections' \ --header 'Authorization: Bearer ' ``` ### When the token expires - The token stops working after `expires_in` seconds (typically 3600 seconds, or 1 hour). - There is no refresh token. To keep going, repeat **Step 1** to get a new token. - Tip: request a new token shortly before the old one expires so requests don't fail. --- ## Option B: API Key Add this header to **every** request: ``` Authorization: apikey ``` Replace `` with your `apikey`. Keep the word `apikey` and the space before your key. **Example** ```bash curl 'https://api.avetta.com/api/v1/connections' \ --header 'Authorization: apikey ' ```