Get an Organization Token

Learn how to retrieve an organization token using the API.

Because most API calls are scoped to a specific organization, you also need an organization token to send API requests.

To get an organization token:

  1. Create a personal API token.

  2. Send a request to retrieve all organizations you belong to. Replace YOUR-PERSONAL-API-TOKEN with your token.

    curl -X GET "https://api.cobalt.io/orgs" \
        -H "Accept: application/vnd.cobalt.v2+json" \
        -H "Authorization: Bearer YOUR-PERSONAL-API-TOKEN" \
        | jq .
    
  3. From the output, save the token value for the desired organization. In our API documentation, you’ll see this as YOUR-V2-ORGANIZATION-TOKEN.

    Example response:

    {
      "data": [
        {
          "resource": {
            "id": "some_id",
            "name": "Name of your organization",
            "token": "YOUR-V2-ORGANIZATION-TOKEN"
          },
          "links": {
            "ui": {
              "url": "https://api.cobalt.io/links/link-to-web-app"
            }
          }
        }
      ],
      "pagination": {
        "next_page": "/orgs?cursor=a1b2c3d4",
        "prev_page": "/orgs?cursor=4d3c2b1a"
      }
    }
    

Include the organization token in the X-Org-Token header of your requests.

-H "X-Org-Token: YOUR-V2-ORGANIZATION-TOKEN"

For more information, see our API reference documentation on the organizations endpoint.

Last modified November 14, 2024