An open-source, faster Devin alternative
TypeScript
Docs: per-field response documentation with Mintlify ResponseField
Igor Zalutski3831d5604d41
diff --git a/docs/api-reference/usage/get-sandbox-usage.mdx b/docs/api-reference/usage/get-sandbox-usage.mdxindex 29e514f2..721d6408 100644--- a/docs/api-reference/usage/get-sandbox-usage.mdx+++ b/docs/api-reference/usage/get-sandbox-usage.mdx@@ -8,6 +8,8 @@ envelope totals. Allocated memory is the tier the sandbox wasprovisioned at, integrated over time; used memory is the actualresident memory consumed by the sandbox process, sampled every 60s.+## Request+<ParamField path="id" type="string" required>Sandbox ID.</ParamField>@@ -20,6 +22,127 @@ resident memory consumed by the sandbox process, sampled every 60s.RFC3339 upper bound. Default: now. Window must be ≤ 30 days.</ParamField>+## Response++<ResponseField name="sandboxId" type="string" required>+ Echo of the requested sandbox ID.+</ResponseField>++<ResponseField name="alias" type="string">+ The sandbox's display name (set at create time). Absent if no alias+ was provided.+</ResponseField>++<ResponseField name="from" type="string" required>+ RFC3339 lower bound of the window the response covers — either the+ caller's `from`, or the server default (`now - 1h`) when omitted.+</ResponseField>++<ResponseField name="to" type="string" required>+ RFC3339 upper bound. Either the caller's `to`, or the server+ default (`now`) when omitted.+</ResponseField>++<ResponseField name="totals" type="object" required>+ Envelope totals for the full window. Each additive field equals the+ sum of the matching field across `points[]` — useful for getting+ the headline numbers without iterating.++ <Expandable title="properties">+ <ResponseField name="memoryAllocatedGbSeconds" type="number" required>+ Total GiB-seconds the sandbox was provisioned for. This is the+ physical quantity the bill is computed from. For a sandbox at+ 1 GiB running for 1 hour, this is `3600`.+ </ResponseField>++ <ResponseField name="memoryUsedGbSeconds" type="number" required>+ Total GiB-seconds the sandbox actually consumed (integrated+ resident memory). Compare against `memoryAllocatedGbSeconds` to+ see headroom — `1 - used/allocated` is wasted provisioning.+ </ResponseField>++ <ResponseField name="uptimeSeconds" type="integer" required>+ Number of seconds the sandbox was provisioned (i.e., had an+ open scale event) within the window. A 1-hour window where the+ sandbox ran the whole time returns `3600`.+ </ResponseField>++ <ResponseField name="memoryAllocatedPeakMb" type="integer" required>+ Maximum provisioned memory tier (MiB) seen in the window.+ Reflects the highest size the sandbox was resized to.+ </ResponseField>++ <ResponseField name="memoryUsedPeakMb" type="integer" required>+ Maximum measured resident memory (MiB) in any sample during the+ window. Useful for detecting workloads that briefly approached+ their tier ceiling.+ </ResponseField>+ </Expandable>+</ResponseField>++<ResponseField name="points" type="object[]" required>+ Time-ordered array of 1-minute buckets covering `[from, to)`.+ Buckets are minute-aligned in UTC. Boundary buckets are clamped to+ the original window — a mid-minute `from` produces a partial first+ bucket whose integrals reflect only the overlap with the requested+ range.++ Minutes where the sandbox was not provisioned (before first start,+ after final stop) appear with all fields at `0` rather than as+ missing entries — gaps read as continuous flat zero on a chart.++ <Expandable title="properties">+ <ResponseField name="ts" type="string" required>+ RFC3339 timestamp of the bucket start (minute-aligned, UTC).+ The bucket covers `[ts, ts + 1 minute)`.+ </ResponseField>++ <ResponseField name="memoryAllocatedGbSeconds" type="number" required>+ Provisioned memory integrated over this minute, in GiB-seconds.+ Summing this across all points reproduces+ `totals.memoryAllocatedGbSeconds` exactly.+ </ResponseField>++ <ResponseField name="memoryUsedGbSeconds" type="number" required>+ Measured resident memory integrated over this minute, in+ GiB-seconds. Same compositional property — summing reproduces+ `totals.memoryUsedGbSeconds`.+ </ResponseField>++ <ResponseField name="uptimeSeconds" type="integer" required>+ Seconds within this minute the sandbox was provisioned. Usually+ `60`; `0` when not running; a fractional value (e.g., `30`)+ appears in the resize or start/stop bucket where the sandbox+ began or ended part-way through the minute.+ </ResponseField>++ <ResponseField name="allocatedMemoryMb" type="integer" required>+ Time-weighted average of the provisioned memory tier (MiB)+ across this bucket. When a resize falls inside the bucket, this+ shows the blend (e.g., 30s at 2048 + 30s at 4096 → `3072`).+ Designed to render directly as a step line on a chart.+ </ResponseField>++ <ResponseField name="usedMemoryMbAvg" type="integer" required>+ Average measured resident memory (MiB) across samples that fell+ in this bucket. The natural Y value for a "memory used" chart.+ </ResponseField>++ <ResponseField name="usedMemoryMbPeak" type="integer" required>+ Maximum measured resident memory (MiB) across samples in this+ bucket. Catches sub-minute spikes that the average smooths out.+ </ResponseField>+ </Expandable>+</ResponseField>++### Units++All `*GbSeconds` fields are **GiB-seconds** (binary, 2<sup>30</sup>+bytes/GiB), not decimal GB. For a sandbox provisioned at 1024 MiB+running for one minute, `memoryAllocatedGbSeconds` is+`1024/1024 × 60 = 60`. For a measured RSS of 612 MiB,+`memoryUsedGbSeconds` is `612/1024 × 60 ≈ 35.86`.+<ResponseExample>```json 200{@@ -36,64 +159,31 @@ resident memory consumed by the sandbox process, sampled every 60s.},"points": [{- "ts": "2026-05-27T00:00:00Z",- "memoryAllocatedGbSeconds": 60.0,- "memoryUsedGbSeconds": 35.86,- "uptimeSeconds": 60,- "allocatedMemoryMb": 1024,- "usedMemoryMbAvg": 612,- "usedMemoryMbPeak": 720+ "ts": "2026-05-27T00:00:00Z",+ "memoryAllocatedGbSeconds": 60.0,+ "memoryUsedGbSeconds": 35.86,+ "uptimeSeconds": 60,+ "allocatedMemoryMb": 1024,+ "usedMemoryMbAvg": 612,+ "usedMemoryMbPeak": 720},{- "ts": "2026-05-27T00:01:00Z",- "memoryAllocatedGbSeconds": 60.0,- "memoryUsedGbSeconds": 40.02,- "uptimeSeconds": 60,- "allocatedMemoryMb": 1024,- "usedMemoryMbAvg": 683,- "usedMemoryMbPeak": 742+ "ts": "2026-05-27T00:01:00Z",+ "memoryAllocatedGbSeconds": 60.0,+ "memoryUsedGbSeconds": 40.02,+ "uptimeSeconds": 60,+ "allocatedMemoryMb": 1024,+ "usedMemoryMbAvg": 683,+ "usedMemoryMbPeak": 742}]}```</ResponseExample>-### Units--All `*GbSeconds` fields are **GiB-seconds** (binary, 2<sup>30</sup>-bytes/GiB), not decimal GB. For a sandbox provisioned at 1024 MiB-running for one minute, `memoryAllocatedGbSeconds` is-`1024/1024 × 60 = 60`. For a measured RSS of 612 MiB,-`memoryUsedGbSeconds` is `612/1024 × 60 ≈ 35.86`.--### Reading the response--`totals.memoryAllocatedGbSeconds` is what the bill is computed from —-the same physical quantity the Stripe pipeline reports. `totals.memoryUsedGbSeconds`-is the integrated actual RSS; the ratio between the two tells you-whether the sandbox is over-provisioned.--Each point's `memoryAllocatedGbSeconds` and `memoryUsedGbSeconds`-integrate over that 1-minute bucket — summing them across any-subrange reconstructs the integral for that subrange. `totals.*` is-the server-side sum across all returned points. Snapshot scalars-(`allocatedMemoryMb`, `usedMemoryMb{Avg,Peak}`) are time-weighted-averages over the bucket and are intended for chart rendering.--### Bucket semantics--- Buckets are minute-aligned in UTC, not aligned to `from`. The first- and last buckets may be partial if `from` / `to` are mid-minute.-- Minutes where the sandbox is not running emit zero-points- (`uptimeSeconds: 0`, all integrals `0`) rather than nulls — gaps- read as continuous flat zero on a chart.-- When a sandbox is resized mid-bucket, `allocatedMemoryMb` shows the- time-weighted average across the bucket; subsequent buckets reflect- the new tier.-### Use the aggregator for cross-sandbox questions-To rank sandboxes by spend (or, soon, by actual usage), use-[`GET /api/usage`](/api-reference/usage/get-usage) — that endpoint-serves cross-sandbox aggregates and supports filter/sort/cursor. The-per-sandbox endpoint here is for "look at this one sandbox in detail."+To rank sandboxes by spend, use [`GET /api/usage`](/api-reference/usage/get-usage)+— that endpoint serves cross-sandbox aggregates and supports+filter/sort/cursor. The per-sandbox endpoint here is for "look at+this one sandbox in detail."diff --git a/docs/api-reference/usage/get-usage.mdx b/docs/api-reference/usage/get-usage.mdxindex 20e9e6b7..52f8b618 100644--- a/docs/api-reference/usage/get-usage.mdx+++ b/docs/api-reference/usage/get-usage.mdx@@ -4,24 +4,25 @@ api: 'GET /api/usage'---Aggregate 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.+— the platform returns the same physical quantities the invoice is+computed from. For per-sandbox time-series drilldown (memory+utilization over time, 1-minute resolution), see+[`GET /api/sandboxes/:id/usage`](/api-reference/usage/get-sandbox-usage).<Note>All `*GbSeconds` fields are **GiB-seconds** (binary, 2<sup>30</sup>bytes/GiB), not decimal GB. For a sandbox provisioned at 1024 MiB-running for one second, `memoryGbSeconds` is 1.+running for one second, `memoryGbSeconds` is `1`.</Note><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.+Freshness: accurate to the minute under normal conditions. A sandbox+that exited uncleanly continues to accrue against its provisioned+tier until the platform reconciles state — the same behavior the+billing pipeline uses, so the numbers here match the invoice.</Note>-For per-sandbox time-series drilldown (memory utilization over time,-1-minute resolution), see [`GET /api/sandboxes/:id/usage`](/api-reference/usage/get-sandbox-usage).+## Request<ParamField query="groupBy" type="string" required>`sandbox` for top sandboxes, or `tag:<key>` for spend by tag value.@@ -31,12 +32,12 @@ For per-sandbox time-series drilldown (memory utilization over time,</ParamField><ParamField query="from" type="string">- ISO-8601 inclusive lower bound. Default: now minus 30 days. Max+ RFC3339 inclusive lower bound. Default: now minus 30 days. Maxwindow: 90 days.</ParamField><ParamField query="to" type="string">- ISO-8601 exclusive upper bound. Default: now.+ RFC3339 exclusive upper bound. Default: now.</ParamField><ParamField query="filter[tag:<key>]" type="string">@@ -60,6 +61,115 @@ For per-sandbox time-series drilldown (memory utilization over time,Opaque cursor from a prior response's `nextCursor`.</ParamField>+## Response++<ResponseField name="from" type="string" required>+ RFC3339 echo of the effective window lower bound.+</ResponseField>++<ResponseField name="to" type="string" required>+ RFC3339 echo of the effective window upper bound.+</ResponseField>++<ResponseField name="groupBy" type="string" required>+ Echo of the requested `groupBy` value.+</ResponseField>++<ResponseField name="total" type="object" required>+ Aggregate across **all rows matching the window and filters**, not+ just the current page. Use this for headline numbers; sum `items[]`+ if you need a per-page subtotal instead.++ <Expandable title="properties">+ <ResponseField name="memoryGbSeconds" type="number" required>+ Total provisioned memory × time across matching sandboxes, in+ GiB-seconds.+ </ResponseField>++ <ResponseField name="diskOverageGbSeconds" type="number" required>+ Total disk-overage × time. Disk usage within the free+ allowance does not contribute; this is the billable excess.+ </ResponseField>+ </Expandable>+</ResponseField>++<ResponseField name="items" type="object[]" required>+ Paginated rows, sorted by `sort` (default: largest first).++ When `groupBy=sandbox`, each row is one sandbox:++ <Expandable title="groupBy=sandbox row">+ <ResponseField name="sandboxId" type="string" required>+ The sandbox identifier.+ </ResponseField>+ <ResponseField name="alias" type="string">+ Display name set at create time. Absent when none was provided.+ </ResponseField>+ <ResponseField name="status" type="string">+ Current sandbox status (e.g., `running`, `hibernated`,+ `stopped`). Absent when no session exists.+ </ResponseField>+ <ResponseField name="tags" type="object" required>+ Current tag set on the sandbox. Empty object when none.+ </ResponseField>+ <ResponseField name="tagsLastUpdatedAt" type="string">+ RFC3339 timestamp of the most recent tag change, or `null` if+ no tags exist.+ </ResponseField>+ <ResponseField name="memoryGbSeconds" type="number" required>+ Provisioned memory × time for this sandbox in the window.+ </ResponseField>+ <ResponseField name="diskOverageGbSeconds" type="number" required>+ Disk overage × time for this sandbox.+ </ResponseField>+ </Expandable>++ When `groupBy=tag:<key>`, each row is one tag value:++ <Expandable title="groupBy=tag row">+ <ResponseField name="tagKey" type="string" required>+ The tag key from the request (e.g., `team`).+ </ResponseField>+ <ResponseField name="tagValue" type="string" required>+ The tag value for this group.+ </ResponseField>+ <ResponseField name="memoryGbSeconds" type="number" required>+ Total provisioned memory × time across sandboxes carrying+ `tagKey=tagValue`.+ </ResponseField>+ <ResponseField name="diskOverageGbSeconds" type="number" required>+ Total disk overage × time for the same group.+ </ResponseField>+ <ResponseField name="sandboxCount" type="integer" required>+ Distinct sandboxes contributing to this row.+ </ResponseField>+ </Expandable>+</ResponseField>++<ResponseField name="untagged" type="object">+ Only present when `groupBy=tag:<key>`. Sibling bucket for sandboxes+ that lack the grouping key — without it, untagged sandboxes would+ silently disappear from the rollup. Same shape as a tag row minus+ `tagKey`/`tagValue`.++ <Expandable title="properties">+ <ResponseField name="memoryGbSeconds" type="number" required>+ Total provisioned memory × time across untagged sandboxes.+ </ResponseField>+ <ResponseField name="diskOverageGbSeconds" type="number" required>+ Total disk overage × time.+ </ResponseField>+ <ResponseField name="sandboxCount" type="integer" required>+ Distinct sandboxes in the untagged bucket.+ </ResponseField>+ </Expandable>+</ResponseField>++<ResponseField name="nextCursor" type="string">+ Opaque cursor to pass as `cursor=` on the next request, or `null`+ when no further pages exist.+</ResponseField>+<ResponseExample>```json groupBy=sandbox{