An open-source, faster Devin alternative
TypeScript
docs: API reference for tags + usage
Igor Zalutski86481892593a
diff --git a/docs/api-reference/sandboxes/get-tags.mdx b/docs/api-reference/sandboxes/get-tags.mdxnew file mode 100644index 00000000..2b2a1b2d--- /dev/null+++ b/docs/api-reference/sandboxes/get-tags.mdx@@ -0,0 +1,22 @@+---+title: 'Get Sandbox Tags'+api: 'GET /api/sandboxes/{id}/tags'+---++Read the current tag set for a sandbox.++<ParamField path="id" type="string" required>+ Sandbox ID.+</ParamField>++<ResponseExample>+```json 200+{+ "tags": { "env": "prod", "team": "payments" },+ "tagsLastUpdatedAt": "2026-04-19T14:02:00Z"+}+```+</ResponseExample>++A sandbox with no tags returns `"tags": {}` and `"tagsLastUpdatedAt":+null`.diff --git a/docs/api-reference/sandboxes/get.mdx b/docs/api-reference/sandboxes/get.mdxindex 5a29cd1c..1ae7c8c6 100644--- a/docs/api-reference/sandboxes/get.mdx+++ b/docs/api-reference/sandboxes/get.mdx@@ -15,7 +15,13 @@ Get sandbox details by ID. Available on both control plane and worker."sandboxID": "sb-abc123","status": "running","region": "use2",- "workerID": "w-use2-abc123"+ "workerID": "w-use2-abc123",+ "tags": { "env": "prod", "team": "payments" },+ "tagsLastUpdatedAt": "2026-04-19T14:02:00Z"}```</ResponseExample>++`tags` and `tagsLastUpdatedAt` are always present — empty object and+`null` respectively when no tags are set. Update them with+[`PUT /api/sandboxes/{id}/tags`](/api-reference/sandboxes/set-tags).diff --git a/docs/api-reference/sandboxes/list.mdx b/docs/api-reference/sandboxes/list.mdxindex a77f8390..b18858d6 100644--- a/docs/api-reference/sandboxes/list.mdx+++ b/docs/api-reference/sandboxes/list.mdx@@ -12,8 +12,14 @@ List all running sandboxes."sandboxID": "sb-abc123","status": "running","region": "use2",- "workerID": "w-use2-abc123"+ "workerID": "w-use2-abc123",+ "tags": { "env": "prod" },+ "tagsLastUpdatedAt": "2026-04-19T14:02:00Z"}]```</ResponseExample>++Each entry carries `tags` (always present, empty object when unset)+and `tagsLastUpdatedAt` (null when unset). To filter by tag, use+[`GET /api/usage?groupBy=sandbox&filter[tag:<key>]=<value>`](/api-reference/usage/get-usage).diff --git a/docs/api-reference/sandboxes/set-tags.mdx b/docs/api-reference/sandboxes/set-tags.mdxnew file mode 100644index 00000000..84f47602--- /dev/null+++ b/docs/api-reference/sandboxes/set-tags.mdx@@ -0,0 +1,41 @@+---+title: 'Set Sandbox Tags'+api: 'PUT /api/sandboxes/{id}/tags'+---++Replace the full tag set for a sandbox. Partial updates are not+supported — GET, modify, PUT. `{}` clears all tags.++<ParamField path="id" type="string" required>+ Sandbox ID.+</ParamField>++<ParamField body="<tagKey>" type="string">+ Each top-level key in the body is a tag name; the value is a+ string. Flat map only — nested objects are rejected.+</ParamField>++### Validation++- At most 50 tag keys per sandbox.+- Keys: 1–128 characters, `A–Z a–z 0–9 _ . - :`. `:` is allowed as+ a user namespace separator.+- Values: 0–256 UTF-8 characters.+- The `oc:` key prefix is reserved for future system-set tags.++<ResponseExample>+```json 200+{+ "tags": { "env": "staging", "team": "growth" },+ "tagsLastUpdatedAt": "2026-04-22T20:31:14Z"+}+```+</ResponseExample>++<Note>+Retagging rewrites attribution going forward: a sandbox re-tagged+from `team=payments` to `team=growth` will appear under `growth` in+every subsequent /usage query, including for time before the retag.+Surface `tagsLastUpdatedAt` alongside spend in dashboards so readers+can see when tags changed.+</Note>diff --git a/docs/api-reference/usage/get-sandbox-usage.mdx b/docs/api-reference/usage/get-sandbox-usage.mdxnew file mode 100644index 00000000..09640d72--- /dev/null+++ b/docs/api-reference/usage/get-sandbox-usage.mdx@@ -0,0 +1,42 @@+---+title: 'Sandbox Usage Drilldown'+api: 'GET /api/sandboxes/{id}/usage'+---++Per-sandbox GB-second spend over a window, plus tag set and+lifetime bounds. Works for torn-down sandboxes — scale events and+tags persist.++<ParamField path="id" type="string" required>+ Sandbox ID.+</ParamField>++<ParamField query="from" type="string">+ ISO-8601 lower bound. Default: now minus 30 days.+</ParamField>++<ParamField query="to" type="string">+ ISO-8601 upper bound. Default: now. Window must be ≤ 90 days.+</ParamField>++<ResponseExample>+```json 200+{+ "sandboxId": "sb-abc",+ "alias": "my-agent",+ "status": "running",+ "from": "2026-03-23T00:00:00Z",+ "to": "2026-04-22T00:00:00Z",+ "memoryGbSeconds": 12345.6,+ "diskOverageGbSeconds": 789.0,+ "tags": { "env": "prod", "team": "payments" },+ "tagsLastUpdatedAt": "2026-04-19T14:02:00Z",+ "firstStartedAt": "2026-03-25T09:13:02Z",+ "lastEndedAt": null+}+```+</ResponseExample>++`firstStartedAt` / `lastEndedAt` come from session records clamped to+the query window. `lastEndedAt` is `null` while any session for this+sandbox is open.diff --git a/docs/api-reference/usage/get-usage.mdx b/docs/api-reference/usage/get-usage.mdxnew file mode 100644index 00000000..110b3a98--- /dev/null+++ b/docs/api-reference/usage/get-usage.mdx@@ -0,0 +1,89 @@+---+title: 'Usage Aggregator'+api: 'GET /api/usage'+---++Aggregate GB-second spend grouped by sandbox or by tag. Dollars are+not exposed — Stripe owns pricing, and this endpoint returns the same+physical quantities the invoice is computed from.++<Note>+Freshness: accurate to the minute for cleanly-shutdown sandboxes.+A silently-dead worker leaves scale events open until the worker+restarts; until then, accrual keeps going. This is the same behavior+as the Stripe pipeline.+</Note>++<ParamField query="groupBy" type="string" required>+ `sandbox` for top sandboxes, or `tag:<key>` for spend by tag value.+ Keys may contain `:` — everything after the first `:` is the tag+ key (so `groupBy=tag:team:payments` groups by the key+ `team:payments`).+</ParamField>++<ParamField query="from" type="string">+ ISO-8601 inclusive lower bound. Default: now minus 30 days. Max+ window: 90 days.+</ParamField>++<ParamField query="to" type="string">+ ISO-8601 exclusive upper bound. Default: now.+</ParamField>++<ParamField query="filter[tag:<key>]" type="string">+ Repeatable. Comma-separated values OR within a key; multiple+ `filter[...]` params AND across keys. Empty value (`filter[tag:team]=`)+ matches sandboxes without the `team` key.+</ParamField>++<ParamField query="sort" type="string">+ `-memoryGbSeconds` (default) or `-diskOverageGbSeconds`.+</ParamField>++<ParamField query="limit" type="integer">+ Max items per page. Default 50, max 500.+</ParamField>++<ParamField query="cursor" type="string">+ Opaque cursor from a prior response's `nextCursor`.+</ParamField>++<ResponseExample>+```json groupBy=sandbox+{+ "from": "2026-03-23T00:00:00Z",+ "to": "2026-04-22T00:00:00Z",+ "groupBy": "sandbox",+ "total": { "memoryGbSeconds": 20000, "diskOverageGbSeconds": 360 },+ "items": [+ {+ "sandboxId": "sb-abc",+ "alias": "my-agent",+ "status": "running",+ "tags": { "env": "prod", "team": "payments" },+ "tagsLastUpdatedAt": "2026-04-19T14:02:00Z",+ "memoryGbSeconds": 8000,+ "diskOverageGbSeconds": 120+ }+ ],+ "nextCursor": null+}+```++```json groupBy=tag:team+{+ "from": "2026-03-23T00:00:00Z",+ "to": "2026-04-22T00:00:00Z",+ "groupBy": "tag:team",+ "total": { "memoryGbSeconds": 19000, "diskOverageGbSeconds": 340 },+ "untagged": { "memoryGbSeconds": 1000, "diskOverageGbSeconds": 20, "sandboxCount": 2 },+ "items": [+ { "tagKey": "team", "tagValue": "payments",+ "memoryGbSeconds": 8000, "diskOverageGbSeconds": 120, "sandboxCount": 12 },+ { "tagKey": "team", "tagValue": "growth",+ "memoryGbSeconds": 4000, "diskOverageGbSeconds": 50, "sandboxCount": 5 }+ ],+ "nextCursor": null+}+```+</ResponseExample>diff --git a/docs/api-reference/usage/list-tags.mdx b/docs/api-reference/usage/list-tags.mdxnew file mode 100644index 00000000..747b045d--- /dev/null+++ b/docs/api-reference/usage/list-tags.mdx@@ -0,0 +1,25 @@+---+title: 'List Tag Keys'+api: 'GET /api/tags'+---++List all tag keys set on any sandbox in the org, with per-key counts+of tagged sandboxes and distinct values. Useful for building+group-by pickers without querying the full tag set.++<ResponseExample>+```json 200+{+ "keys": [+ { "key": "team", "sandboxCount": 17, "valueCount": 4 },+ { "key": "env", "sandboxCount": 23, "valueCount": 3 }+ ]+}+```+</ResponseExample>++<Note>+Tag keys on torn-down sandboxes are retained so historical drilldowns+keep resolving. As a result `sandboxCount` may include sandboxes+that are no longer active.+</Note>diff --git a/docs/mint.json b/docs/mint.jsonindex 873400d8..d10cbda2 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -206,7 +206,17 @@"api-reference/sandboxes/delete","api-reference/sandboxes/set-timeout","api-reference/sandboxes/hibernate",- "api-reference/sandboxes/wake"+ "api-reference/sandboxes/wake",+ "api-reference/sandboxes/get-tags",+ "api-reference/sandboxes/set-tags"+ ]+ },+ {+ "group": "Usage",+ "pages": [+ "api-reference/usage/get-usage",+ "api-reference/usage/get-sandbox-usage",+ "api-reference/usage/list-tags"]},{