const { token } = await airstore.tokens.create('ws_abc123', { name: 'vm-mount' })
Tokens provide workspace-scoped authentication for the CLI and programmatic access. Use them to mount Airstore on headless VMs or CI runners without interactive login.
create()
Create a workspace token.
const result = await airstore.tokens.create('ws_abc123', {
name: 'production-vm',
expiresIn: 86400, // 24 hours
})
console.log(result.token) // "tok_xxxxxxxxxxxx"
console.log(result.info.external_id) // "tkn_abc123"
The raw token value is only returned at creation time. Store it securely.
Parameters
| Parameter | Type | Required | Default | Description |
|---|
workspaceId | string | Yes | — | Workspace external ID |
name | string | No | — | Display name for the token |
memberId | string | No | — | Member ID to associate the token with |
email | string | No | — | Email to auto-create a member if memberId not provided |
expiresIn | number | No | 0 | Expiration in seconds (0 = no expiration) |
Returns Promise<TokenCreated>
| Field | Type | Description |
|---|
token | string | Raw token value (shown once) |
info | Token | Token metadata |
info.external_id | string | Unique identifier |
info.name | string | Display name |
info.token_type | string | Token type |
info.created_at | string | ISO 8601 timestamp |
member_id | string | undefined | Auto-created member ID |
list()
List tokens in a workspace. Returns metadata only — raw token values are never exposed after creation.
const tokens = await airstore.tokens.list('ws_abc123')
for (const t of tokens) {
console.log(`${t.name} -- last used: ${t.last_used_at ?? 'never'}`)
}
Parameters
| Parameter | Type | Required | Description |
|---|
workspaceId | string | Yes | Workspace external ID |
Returns Promise<Token[]>
| Field | Type | Description |
|---|
external_id | string | Unique identifier |
name | string | Display name |
token_type | string | Token type |
created_at | string | ISO 8601 timestamp |
last_used_at | string | undefined | Last usage timestamp |
revoke()
Revoke a token. It stops working immediately.
await airstore.tokens.revoke('ws_abc123', 'tkn_abc123')
Parameters
| Parameter | Type | Required | Description |
|---|
workspaceId | string | Yes | Workspace external ID |
tokenId | string | Yes | Token external ID |
Returns Promise<void>