Astro API

Get started with the Astro API

In this quick introduction to the Astro API, you’ll make some simple requests to retrieve details about your Organization and create a Workspace API token.


  • An Astro account.
  • An Organization API token with the Organization Owner role. Astronomer recommends that you create a new API token for this tutorial.
  • An Astro Workspace.
  • A method for making API requests. This tutorial assumes you’re using curl, but you can also use tools such as Postman.

Step 1: Make your first API request

To access most endpoints, you need to provide an Organization ID to the API as a path parameter. One of the few requests that doesn’t require an Organization ID is the List Organizations request, which means that you can programmatically retrieve an Organization ID.

To retrieve the Organization ID through the API, run the following command:

$curl --location '' \
>--header 'Authorization: Bearer <your-organization-api-token>'

If the command was successful, then you receive a response that begins similarly to the following:

2 "organizations": [
3 {
4 "billingEmail": "",
5 "createdAt": "2022-11-22T04:37:12T",
6 "createdBySubject": {
7 "apiTokenName": "my-token",
8 "avatarUrl": "https://avatar.url",
9 "fullName": "Jane Doe",
10 "id": "clm8qv74h000008mlf08scq7k",
11 "subjectType": "USER",
12 "username": ""
13 },
14 "id": "clmaxoarx000008l2c5ayb9pt",
15 "isScimEnabled": false,
17 ],

Copy the top-level id from this response. This is your Organization ID.

While you could have retrieved this value manually from the Astro UI, using the API lets you script this workflow and execute it on a regular basis.

Step 2: Request Workspace details from the API

Using the Organization ID you copied, you can now find the ID for the Workspace where you want to create your API token.

Run the following command to list all Workspaces in your Organization:

$curl --location '<your-organization-id>/workspaces' \
>--header 'Authorization: Bearer <your-api-token>'

If the command succeeds, the API returns a list of Workspaces similar to the following:

2 "workspaces": [
3 {
4 "cicdEnforcedDefault": true,
5 "createdAt": "2023-09-08T12:00:00Z",
6 "createdBy": {
7 "apiTokenName": "my-token",
8 "avatarUrl": "https://avatar.url",
9 "fullName": "Jane Doe",
10 "id": "clm8qv74h000008mlf08scq7k",
11 "subjectType": "USER",
12 "username": ""
13 },
14 "description": "This is a test workspace",
15 "id": "clm8t5u4q000008jq4qoc3036",
16 "name": "My Workspace",
17 "organizationId": "clm8t5u4q000008jq4qoc3036",
18 "organizationName": "My Organization",
19 "updatedAt": "2023-09-08T13:30:00Z",
20 "updatedBy": {
21 "apiTokenName": "my-token",
22 "avatarUrl": "https://avatar.url",
23 "fullName": "Jane Doe",
24 "id": "clm8qv74h000008mlf08scq7k",
25 "subjectType": "USER",
26 "username": ""
27 }
28 }
29 ]

In the response for your specific Workspace, copy the top-level id. This is your Workspace ID.

If the API returns too many Workspaces, add some pagination parameters to your URL. For example, to limit your results to only the 20 most recently updated Workspaces, you can run:

$curl --location '<your-organization-id>/workspaces?limit=20&sorts=updatedAt:asc' \
>--header 'Authorization: Bearer <your-organization-api-token>'

Step 3: Update your token description using the API

Now that you have both an Organization ID and a Workspace ID, you can create a Workspace API token using the Astro API.

  1. Run the following command to create a new Workspace API token:

    $curl --location '<your-organization-id>/tokens' \
    >--header 'Content-Type: application/json' \
    >--header 'Authorization: Bearer <your-organization-api-token>' \
    >--data '{
    > "description": "I wrote this description using the Astro API!",
    > "entityId": "<your-workspace-id>",
    > "name": "My new API token",
    > "role": "WORKSPACE_MEMBER",
    > "type": "WORKSPACE"

    If the request was successful, the API will return a response with your new token’s details.

  2. In the Astro UI, go to Workspace Settings > Access Management > API Tokens and find your Workspace API token. You should see your updated description under Description.