ApiToken

Create an API token

POST
Create an API token. An API token is an alphanumeric token that grants programmatic access to Astro for automated workflows. An API token can be scoped to an Organization or a Workspace.

Path parameters

organizationIdstringRequired
The ID of the Organization where you want to create the token.

Request

This endpoint expects an object.
name
stringRequired
The name of the API token.
role
stringRequired
The role of the API token.
type
enumRequired
The scope of the API token.
Allowed values: DEPLOYMENTWORKSPACEORGANIZATION
description
stringOptional
The description for the API token.
entityId
stringOptional

The ID of the Workspace or Deployment to which the API token is scoped. It is required if Type is WORKSPACE or DEPLOYMENT.

tokenExpiryPeriodInDays
integerOptional
The expiry period of the API token in days. If not specified, the token will never expire.

Response

This endpoint returns an object
createdAt
datetime

The time when the API token was created in UTC, formatted as YYYY-MM-DDTHH:MM:SSZ.

description
string
The description of the API token.
id
string
The API token's ID.
name
string
The name of the API token.
shortToken
string
The short value of the API token.
startAt
datetime

The time when the API token will become valid in UTC, formatted as YYYY-MM-DDTHH:MM:SSZ.

type
enum
The type of the API token.
Allowed values: DEPLOYMENTWORKSPACEORGANIZATION
updatedAt
datetime

The time when the API token was last updated in UTC, formatted as YYYY-MM-DDTHH:MM:SSZ.

createdBy
objectOptional
endAt
datetimeOptional

The time when the API token expires in UTC, formatted as YYYY-MM-DDTHH:MM:SSZ.

expiryPeriodInDays
integerOptional
The expiry period of the API token in days.
lastUsedAt
datetimeOptional

The time when the API token was last used in UTC, formatted as YYYY-MM-DDTHH:MM:SSZ.

roles
list of objectsOptional
The roles of the API token.
token
stringOptional
The value of the API token.
updatedBy
objectOptional
POST
1curl -X POST https://api.astronomer.io/iam/v1beta1/organizations/organizationId/tokens \
2 -H "Authorization: Bearer <token>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "name": "My token",
6 "role": "WORKSPACE_OWNER",
7 "type": "DEPLOYMENT",
8 "description": "This is my API token",
9 "entityId": "clm8pxjjw000008l23jm08hyu",
10 "tokenExpiryPeriodInDays": 30
11}'
Response
1{
2 "createdAt": "2022-11-22T04:37:12Z",
3 "description": "my token description",
4 "id": "clm8q7f6q000008lcgyougpsk",
5 "name": "My token",
6 "shortToken": "short-token",
7 "startAt": "2022-11-22T04:37:12Z",
8 "type": "DEPLOYMENT",
9 "updatedAt": "2022-11-22T04:37:12Z",
10 "createdBy": {
11 "id": "clm8qv74h000008mlf08scq7k",
12 "apiTokenName": "my-token",
13 "avatarUrl": "https://avatar.url",
14 "fullName": "Jane Doe",
15 "subjectType": "USER",
16 "username": "user1@company.com"
17 },
18 "endAt": "2022-11-22T04:37:12Z",
19 "expiryPeriodInDays": 30,
20 "lastUsedAt": "2022-11-22T04:37:12Z",
21 "roles": [
22 {
23 "entityId": "clm8sgvai000008l794psbkdv",
24 "entityType": "DEPLOYMENT",
25 "role": "WORKSPACE_MEMBER"
26 }
27 ],
28 "token": "token",
29 "updatedBy": {
30 "id": "clm8qv74h000008mlf08scq7k",
31 "apiTokenName": "my-token",
32 "avatarUrl": "https://avatar.url",
33 "fullName": "Jane Doe",
34 "subjectType": "USER",
35 "username": "user1@company.com"
36 }
37}