Development
March 16, 2021 ยท View on GitHub
Cobalt REST API: https://app.swaggerhub.com/apis/CobaltLab/Cobalt_Public_API/1.3.0
Short version for the 2-step authentication process:
- Generate an API key under Profile in your Cobalt account.
- That key is used to Bearer authorize to the /orgs endpoint, which returns an object with an orgToken.
- orgToken is then used to get anything more detailed than /orgs (eg. /findings, /pentests, etc).
More details below under Authentication.
Prerequisites
Nothing special. Standard tools.
Authentication
The API is read-only. To use it manually from Swagger:
- From the profile dropdown on your Cobalt account, create a personal API token.
- With your token copied locally (once you leave the page you won't be able to copy it), you can head to Swagger.
- Make sure to point to Production (https://api.cobalt.io) from the drop-down
- Authorize with your API token in the API_KEY_AUTH field.
- Eexecute the /orgs endpoint via the Execute button on the API page.
- Note the organization token.
- Return back to the Authorize section and add the org token and Authorize that as part of your OrgToken (i.e. X-Org-Token) header. Now, all subsequent requests to /assets, /findings, /pentests, etc will be scoped to your personal API token and the appropriate org token
To use the API via code:
- From the profile dropdown on your Cobalt account, generate an API key.
- Copy the API key locally once it is displayed, because you won't be able to after you leave the generation page.
- Execute https://api.cobalt.io/orgs with a header included of
'Authorization': 'Bearer API_KEY_AUTH', where API_KEY_AUTH is what you made on step one. - The reply object will include
data.data[0].resource.token, which is a string for your orgToken. - For all other /GET requests to the API, include a header of
'X-Org-Token': 'ORG_TOKEN'.