Shardflux Tool tokens API
Short-lived tokens for the workspace tools (exec, PTY, files, git, browser) served at the workspace’s cell_endpoint, and agent sessions.
Short-lived tokens for the workspace tools (exec, PTY, files, git, browser) served at the workspace’s cell_endpoint, and agent sessions.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/shardflux-dev:shardflux-dev-tool-tokens-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Shardflux Tool tokens API
version: 0.1.0
description: 'The public Shardflux HTTP API, as called by the TypeScript and Python SDKs and the CLI. Authenticate every request with a project API key: `Authorization: Bearer sfk__`. Error responses use the ErrorBody schema. Workspace tools (exec, PTY, processes, files, git, browser) are served by the workspace’s cell at `cell_endpoint` with a tool token from POST /v1/workspaces/{workspace_id}/tool-tokens and are not part of this document.'
servers:
- url: https://api.shardflux.dev
description: Production
tags:
- name: Tool tokens
description: Short-lived tokens for the workspace tools (exec, PTY, files, git, browser) served at the workspace’s cell_endpoint, and agent sessions.
paths:
/v1/workspaces/{workspace_id}/tool-tokens:
post:
operationId: postV1WorkspacesWorkspaceIdToolTokens
summary: Issue a workspace tool token (ES256, <= 15 min) for the cell gateway
tags:
- Tool tokens
description: 'Creates or reuses the agent session for (workspace, principal, agent_label) and signs a token with claims iss, aud, sub, pty, org, prj, ws, epoch, tools, sid, iat, exp, jti (verify with GET /v1/.well-known/tool-token-keys). `tools` must be a subset of the API key’s tool permissions (users: of their role). A suspended workspace gets a token too: the cell serves it only the reads of its disk (`files` read, stat, list and search, `X-Served-From: disk`) and answers every other call 409 `workspace_not_running` (wake the workspace; its resume moves the ownership epoch). 409 with the active operation when the workspace is neither running nor suspended; on 409 `stale_epoch` from the cell, request a new token.'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
agent_label:
type: string
minLength: 1
maxLength: 100
pattern: ^[^\u0000-\u001f\u007f]+$
description: Attribution label; one agent session per (workspace, principal, label).
tools:
type: array
items:
type: string
enum:
- exec
- files
- pty
- process
- git
- browser
- computer
description: 'computer: the workspace desktop; a tool token carries it only while the workspace’s computer use is on.'
uniqueItems: true
minItems: 1
maxItems: 7
additionalProperties: false
parameters:
- schema:
type: string
format: uuid
in: path
name: workspace_id
required: true
description: UUIDv7, lowercase canonical form.
security:
- apiKey: []
responses:
'201':
description: Default Response
content:
application/json:
schema:
$ref: '#/components/schemas/ToolToken'
4XX:
description: Default Response
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBody'
examples:
not_found:
$ref: '#/components/examples/not_found'
rate_limited:
$ref: '#/components/examples/rate_limited'
validation_failed:
$ref: '#/components/examples/validation_failed'
5XX:
description: Default Response
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBody'
examples:
not_found:
$ref: '#/components/examples/not_found'
rate_limited:
$ref: '#/components/examples/rate_limited'
validation_failed:
$ref: '#/components/examples/validation_failed'
/v1/workspaces/{workspace_id}/agent-sessions:
get:
operationId: getV1WorkspacesWorkspaceIdAgentSessions
summary: List the attributed agent sessions of a workspace
tags:
- Tool tokens
parameters:
- schema:
type: integer
minimum: 1
maximum: 200
default: 50
in: query
name: limit
required: false
- schema:
type: string
maxLength: 200
in: query
name: cursor
required: false
- schema:
type: string
format: uuid
in: path
name: workspace_id
required: true
description: UUIDv7, lowercase canonical form.
security:
- apiKey: []
responses:
'200':
description: Default Response
content:
application/json:
schema:
type: object
required:
- data
- next_cursor
properties:
data:
type: array
items:
type: object
required:
- id
- workspace_id
- agent_label
- principal_type
- principal_id
- created_at
- last_token_issued_at
- tokens_issued
- revoked_at
properties:
id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
workspace_id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
agent_label:
type: string
principal_type:
anyOf:
- type: string
enum:
- user
- type: string
enum:
- api_key
principal_id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
created_at:
type: string
format: date-time
description: RFC 3339 UTC timestamp with Z.
last_token_issued_at:
anyOf:
- type: string
format: date-time
description: RFC 3339 UTC timestamp with Z.
- type: 'null'
tokens_issued:
type: integer
revoked_at:
anyOf:
- type: string
format: date-time
description: RFC 3339 UTC timestamp with Z.
- type: 'null'
additionalProperties: false
next_cursor:
anyOf:
- type: string
- type: 'null'
additionalProperties: false
4XX:
description: Default Response
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBody'
examples:
not_found:
$ref: '#/components/examples/not_found'
rate_limited:
$ref: '#/components/examples/rate_limited'
validation_failed:
$ref: '#/components/examples/validation_failed'
5XX:
description: Default Response
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBody'
examples:
not_found:
$ref: '#/components/examples/not_found'
rate_limited:
$ref: '#/components/examples/rate_limited'
validation_failed:
$ref: '#/components/examples/validation_failed'
components:
schemas:
ToolToken:
type: object
required:
- token
- token_type
- expires_at
- issued_at
- kid
- audience
- workspace_id
- agent_session_id
- ownership_epoch
- tools
- cell_endpoint
properties:
token:
type: string
description: 'Compact ES256 JWS; send as `Authorization: Bearer` to the cell gateway.'
token_type:
type: string
enum:
- Bearer
expires_at:
type: string
format: date-time
description: RFC 3339 UTC timestamp with Z.
issued_at:
type: string
format: date-time
description: RFC 3339 UTC timestamp with Z.
kid:
type: string
audience:
type: string
workspace_id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
agent_session_id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
ownership_epoch:
type: integer
tools:
type: array
items:
type: string
enum:
- exec
- files
- pty
- process
- git
- browser
- computer
description: 'computer: the workspace desktop; a tool token carries it only while the workspace’s computer use is on.'
cell_endpoint:
type: string
additionalProperties: false
ErrorBody:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
- request_id
- retryable
properties:
code:
type: string
enum:
- bad_request
- token_invalid
- unauthenticated
- invalid_credentials
- entitlement_required
- card_required
- allowance_exhausted
- quota_exceeded
- forbidden
- feature_unavailable
- mfa_required
- email_unverified
- csrf_failed
- step_up_required
- not_found
- conflict
- stale_epoch
- payload_too_large
- unsupported_media_type
- validation_failed
- idempotency_mismatch
- rate_limited
- internal_error
- capacity_pending
- dependency_unavailable
- authorization_pending
- slow_down
- access_denied
- expired_token
description: Closed set of error codes (docs/INTEGRATION_CONTRACTS.md).
message:
type: string
description: Safe, human-readable text.
request_id:
type: string
retryable:
type: boolean
operation_id:
type: string
format: uuid
description: UUIDv7, lowercase canonical form.
details:
type: object
properties: {}
additionalProperties: true
description: 'Operation-specific fields. Block-volume reasons: volume_kind_mismatch, volume_in_use, block_volumes_not_enabled, block_volumes_unsupported_base, block_volumes_schema_unavailable, block_volume_restart_required, block_volume_default_not_supported, not_supported_with_block_volumes, fork_source_volume_unavailable. fork_source_volume_unavailable is non-retryable: a generation captured by the fork source checkpoint is unavailable; choose another checkpoint. volume_in_use includes attachment_id and workspace_id when visible; detaching holders are retryable with retry_after_seconds (1–5). Block quota limits: workspace_disk_gib_max and block_volume_attachments_per_workspace (2).'
additionalProperties: false
additionalProperties: false
examples:
not_found:
summary: Resource outside the caller’s tenant or nonexistent
value:
error:
code: not_found
message: Project not found.
request_id: req-2f1c9a7e44d1
retryable: false
rate_limited:
summary: Durable rate limit exhausted (Retry-After header is also set)
value:
error:
code: rate_limited
message: Too many requests. Try again later.
request_id: req-9b0e1d2c3f4a
retryable: true
details:
retry_after_seconds: 42
validation_failed:
summary: Request body failed schema validation
value:
error:
code: validation_failed
message: Request validation failed.
request_id: req-5a6b7c8d9e0f
retryable: false
details:
issues:
- path: /body
message: must have required property 'password'
securitySchemes:
apiKey:
type: http
scheme: bearer
bearerFormat: sfk_<key_id>_<secret>
externalDocs:
description: Endpoint reference
url: https://docs.shardflux.dev/reference/http-api/endpoints