Intro to BluBracket APIs and API keys
How to access and use the BluBracket API.
In order to make requests into the event and alert APIs, you have to generate an API key, which you use to generate a token, and then you can setup any kind of integration that you would like to make authenticated requests into the Blu Event and Alert APIS.
Generating an auth token
Create an API key by navigating to Settings > API Keys
Enter a name for the key
Select Integration from the drop down
Select Create Key
Save the JSON/CSV file to your desktop
Open the JSON/CSV file and copy the value of the token
{ "api_keys": { "https://mycompany.blubracket.com": { "id": "BLU-a492144b-f118-4598-991e-f1d4d6209edf", "key": "TofsB.....EqwGg", "token": "QkxVL....xd0dn" } } }
Testing and using the API token
With the generated token, you can make requests directly to BluBracket APIs. You will need to set the Authorization header and use the provided token as Bearer token.
Here are some examples using curl:
curl -H "Authorization: Bearer TOKEN_FROM_STEP_2" --data '{"filters":[]}' https://mycompany.blubracket.com/api/public/event/search
curl -H "Authorization: Bearer TOKEN_FROM_STEP_2" --data '{"filters":[]}' https://mycompany.blubracket.com/api/public/alert/search
Note: As per ISO 8601, date formatting requires either the Z or the +00:00 be supplied at the end. This is required to determine that the datetime is in the UTC timezone.
Example Python code is shown below:
from datetime import datetime, timezone
datetime.now(timezone.utc).isoformat()
Output: 2021-07-20T23:45:06.342716+00:00