docs(sessions): add POST /api/sessions reference#186
Conversation
Documents the first endpoint ported in the open-agents -> api migration
(api PR #514). Establishes the reference shape for the Agent Sessions
endpoint family — subsequent ports (list, chats, etc.) will land in
this same group.
Files:
api-reference/openapi/sessions.json
New OpenAPI 3.1 spec for the agent-sessions endpoint family.
Documents GET /api/sessions/{sessionId} with the full Session
schema (camelCase wire format that mirrors what api returns).
Auth: x-api-key header or Bearer token.
Response codes: 200 / 401 / 403 / 404.
api-reference/sessions/get.mdx
Frontmatter-only, per repo convention. References the OpenAPI
spec — Mintlify auto-generates the page from there.
docs.json
Adds an "Agent Sessions" group under the API Reference tab,
immediately after Sandboxes. One entry today; subsequent route
ports add their pages here.
Naming note in the schema: the Session.userId field is documented
explicitly as "named userId for client compatibility; on the server
side this is account_id". Captures the wire-format-vs-schema name
difference that exists during the cutover window so consumers reading
the docs alongside the database schema do not get confused.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cture)
Hoists agent + sandbox concepts out of three different tabs into a
single dedicated top-level. Addresses the structural problem where
"Content" had become a junk drawer for anything sandbox- or
agent-shaped, and agent concepts were scattered across five locations
(Quickstart > Agents, Artists > Tasks, Content > Sandboxes,
Content > Agent Sessions, Content > Content Agent, Accounts > Agent
Onboarding).
Moves into new "Agents & Sandboxes" tab (in this order — onboarding
first, primitives last):
Agent Onboarding ← was Accounts > Agent Onboarding
Agents ← was Quickstart > Agents (intro pages)
Tasks ← was Artists > Tasks
Content Agent ← was Content > Content Agent
Sandboxes ← was Content > Sandboxes
Agent Sessions ← stayed under Content (added in this PR)
Tab placement: between Social Media and Accounts. The workflow tabs
(Artists, Research, Releases, Content, Social Media) stay together;
Agents & Sandboxes sits as the platform's differentiated capability
just before the platform-mechanics tab (Accounts).
Net effect on each existing tab:
Quickstart Agents group removed → just "Getting started" now
Artists Tasks group removed (background-job concept lives
with the agents that drive it)
Content Three groups removed (Content Agent, Sandboxes,
Agent Sessions). Content is now coherent: creation,
posts/comments, image, transcribe.
Accounts Agent Onboarding removed (moved to its true home)
No MDX file paths change — all moves are within docs.json. External
deep links to specific pages stay valid; only tab/group anchors
change.
This is Phase 1 of a four-phase restructure outlined in PR
discussion. Phases 2-4 (rationalize Content remainder, split Accounts
into Platform + Tools & Reference, rebalance Releases) are deferred
to follow-up PRs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Phase 2 — Content tab: fold the single-page Image and Transcribe groups into Content Creation. They are content-creation utilities; one-page groups under Content were over-segmentation that made the tab look fuller than it is. Image generation and audio transcription now sit alongside the other generate-* / transcribe-* endpoints they belong with. Phase 3 — extract Tools & Reference: pull Connectors and AI (model catalog) out of the Accounts tab into a new top-level "Tools & Reference" tab. Both are dev-reference content, not account mechanics. Accounts is now coherent: account-mechanics only (Accounts, Organizations, Workspaces, Subscriptions, Admins, Pulses, Notifications). Phase 4 (rebalance Releases) intentionally skipped: Releases is sparsely populated (1 group, ~8 pages) but architecturally fine. Folding it into Artists or artificially growing it is cosmetic. Will fill in as more endpoints land. Final structure (9 tabs): Quickstart Getting started Artists Workflows · Artists · Fans Research 8 groups (unchanged) Releases Songs & Catalogs Content Content Creation · Posts & Comments ← Phase 2 Social Media Social · Spotify · Apify Agents & Sandboxes 6 groups (added in Phase 1) Accounts 7 groups, account mechanics only ← Phase 3 Tools & Reference Connectors · AI ← Phase 3 (NEW) No MDX file paths change — all moves are within docs.json. External deep links to specific pages stay valid; only tab/group anchors change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The "Agent" prefix was redundant. Every other artifact for this surface
already uses the bare term:
- URL: /api/sessions/{sessionId}
- OpenAPI file: sessions.json
- Folder: api-reference/sessions/
- MDX title: "Get Session"
- Schema type: Session
The "Agents & Sandboxes" tab already establishes context, so "Sessions"
under that tab reads naturally and unambiguously. Only places the old
label appeared:
docs.json (group label)
api-reference/openapi/sessions.json (title + description)
The Stripe checkout-session endpoints under Accounts > Subscriptions
remain at their distinct path (/api/subscriptions/sessions), so there
is no nav-level collision.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The 403 ownership detail is already documented in the responses
section ("Forbidden - the authenticated account does not own this
session") — restating it in the description was redundant prose.
Description is now one sentence.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
api PR #514 returns {status:"error", error:"..."} for all error
responses (401/404/403). The OpenAPI Error schema only documented
{error}. Add the status discriminator so the docs match what the
endpoint actually emits.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds comprehensive OpenAPI v3.1 documentation and navigation integration for a Sessions API endpoint, including security schemes, request/response schemas, error definitions, and a new MDX documentation page with updated site navigation structure. ChangesSessions API Documentation & Navigation Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
2 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="api-reference/openapi/sessions.json">
<violation number="1" location="api-reference/openapi/sessions.json:1">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**
This new file exceeds the 100-line maximum by a large margin (469 lines).</violation>
<violation number="2" location="api-reference/openapi/sessions.json:256">
P2: This spec mixes OpenAPI 3.1 with 3.0 `nullable` fields. Convert nullable schemas to `type` arrays including `"null"` (or switch the document to OpenAPI 3.0.x).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }, | ||
| "activeStreamId": { | ||
| "type": "string", | ||
| "nullable": true, |
There was a problem hiding this comment.
P2: This spec mixes OpenAPI 3.1 with 3.0 nullable fields. Convert nullable schemas to type arrays including "null" (or switch the document to OpenAPI 3.0.x).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At api-reference/openapi/sessions.json, line 256:
<comment>This spec mixes OpenAPI 3.1 with 3.0 `nullable` fields. Convert nullable schemas to `type` arrays including `"null"` (or switch the document to OpenAPI 3.0.x).</comment>
<file context>
@@ -0,0 +1,469 @@
+ },
+ "activeStreamId": {
+ "type": "string",
+ "nullable": true,
+ "description": "Id of an in-flight assistant stream, if one is active."
+ },
</file context>
| @@ -0,0 +1,469 @@ | |||
| { | |||
There was a problem hiding this comment.
P2: Custom agent: Enforce Clear Code Style and Maintainability Practices
This new file exceeds the 100-line maximum by a large margin (469 lines).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At api-reference/openapi/sessions.json, line 1:
<comment>This new file exceeds the 100-line maximum by a large margin (469 lines).</comment>
<file context>
@@ -0,0 +1,469 @@
+{
+ "openapi": "3.1.0",
+ "info": {
</file context>
There was a problem hiding this comment.
Shouldn't only the POST be in this PR?
Documents the create-session endpoint: optional body fields for repo
binding + commit/push overrides, transactional return of `{session, chat}`,
and 200/400/401/500 error envelope.
Also fills in four Session fields the GET reference was missing
(autoCommitPushOverride, autoCreatePrOverride, prNumber, prStatus) and
adds the new Chat schema for the initial chat row created alongside
the session. Captured the live shape from sandbox.recoupable.com so
the spec mirrors the open-agents response that downstream clients
will eventually cut over from.
Error envelope stays as `{error}` to match open-agents (no
status:error divergence here — that's a deliberate compatibility
choice for frontend cutover).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
72325c3 to
15fb54b
Compare
|
Restacked to address the scope feedback:
Re: the two automated comments —
|
Live capture from open-agents (
|
Spec ↔ live response — actual diffRe-running the comparison properly. My earlier comment said "every field is covered" — that's true at the presence level but masks several real divergences. Where the spec disagrees with open-agents
Error states actually returned (not in spec)
The spec's 400 description ("malformed JSON or field failed validation") is broadly accurate. None of the specific messages above are documented. Probably fine — clients should treat 400 as a class, not match on Empty / no-response cases
VerdictSpec is field-complete for the 200 success path against open-agents. The divergences above are mostly about the spec targeting
|
|
Closing the loop on the previous comparison comment — re-read against the api codebase rather than the open-agents probe:
Net: spec is consistent with the api codebase. The divergences from the open-agents probe are all "spec targets |
Per PR feedback: this PR is scoped to POST only. Removes the GET endpoint page, OpenAPI path, GetSessionResponse schema, and the nav reference to it. The GET docs ship in PR #185. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (5)
api-reference/openapi/sessions.json (3)
26-81: ⚡ Quick winAdd an
operationIdto the POST operation.Without an
operationId, Mintlify generates an anchor ID from the method + path, SDK generators emit unpredictable function names, and any futurex-mintmetadata overrides have no stable target.✏️ Suggested addition
"post": { "summary": "Create session", + "operationId": "createSession", "description": "Creates a new agent session..."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api-reference/openapi/sessions.json` around lines 26 - 81, Add a stable operationId to the POST /sessions operation so SDKs and Mintlify anchors have a predictable target; update the POST operation object (the "Create session" endpoint) by adding an "operationId" field (e.g., "createSession" or "createSessionWithInitialChat") that uniquely identifies this operation and matches your naming conventions so future x-mint overrides and code generators produce consistent function names.
272-278: 💤 Low valueStatic analysis:
globalSkillRefsarray is missingmaxItems.Checkov rule
CKV_OPENAPI_21flags arrays without amaxItemsconstraint. For a documentation spec this is likely a false positive (there's no business-driven maximum), but if the real API enforces a limit, addingmaxItemshere would improve spec accuracy and prevent client libraries from generating unbounded arrays.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api-reference/openapi/sessions.json` around lines 272 - 278, The array schema for "globalSkillRefs" is missing a maxItems constraint; update the "globalSkillRefs" schema in the OpenAPI document to include a suitable "maxItems" value that reflects the API's real limit (or a conservative documented maximum) so clients and linters won't treat the array as unbounded, e.g., add "maxItems": <number> to the array definition for globalSkillRefs.
2-2: 🏗️ Heavy lift
nullable: trueis not valid in OpenAPI 3.1 — usetypearrays instead.
nullable: truewas removed in OpenAPI v3.1 in favor of type arrays with the value"null". The spec declares"openapi": "3.1.0"at line 2, so everynullable: trueoccurrence throughoutChatandSessionis non-conformant and will be silently ignored by strict OAS 3.1 validators and code-generators.The correct 3.1 pattern is:
- "type": "string", - "nullable": true + "type": ["string", "null"]Nullable + enum is especially broken.
lifecycleState(lines 287–299) andprStatus(lines 343–350) combinenullable: truewith anenumthat does not containnull. With OpenAPI 3.1,nullis not handled as valid for such a field — generators throwIllegalArgumentExceptionon null values instead of returning null. When a schema is marked nullable and also defines an enum, the enum must explicitly contain a null value.The correct 3.1 pattern for nullable enums:
"lifecycleState": { - "type": "string", - "nullable": true, + "type": ["string", "null"], "enum": [ "provisioning", "active", "hibernating", "hibernated", "restoring", "archived", "failed", + null ] }(Applies identically to
prStatus.)Also applies to: 184-203, 240-383
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api-reference/openapi/sessions.json` at line 2, The OpenAPI file declares "openapi": "3.1.0" so all uses of nullable: true are invalid; update the Chat and Session schemas (and any other schemas between the noted ranges) to replace nullable: true with type arrays that include "null" (e.g., change "type": "string", "nullable": true to "type": ["string","null"]) and for enum fields like lifecycleState and prStatus ensure the enum explicitly includes null (or change the type to ["string","null"] and add null to the enum values) so the schema is valid under OpenAPI 3.1; locate schemas by their names Chat, Session and the properties lifecycleState and prStatus to apply these changes consistently.api-reference/sessions/create.mdx (2)
1-4: 💤 Low valueMissing
descriptionin frontmatter.The
**/*.mdxguideline calls for "clear, self-documenting titles and descriptions." Adescriptionfield improves SEO metadata and navigation tooltips in Mintlify.--- title: "Create Session" +description: "Create a new agent session and an initial chat in a single transaction." openapi: "/api-reference/openapi/sessions.json POST /api/sessions" ---🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api-reference/sessions/create.mdx` around lines 1 - 4, Add a description key to the MDX frontmatter so the page has SEO and tooltip metadata; update the frontmatter block that currently contains title: "Create Session" and openapi: "/api-reference/openapi/sessions.json POST /api/sessions" by adding a descriptive string (e.g., description: "Create a new API session for authentication and token management") directly under the title line, preserving YAML syntax and quoting, so the page follows the **/*.mdx guideline for clear titles and descriptions.
3-3: 💤 Low valueConsider registering the spec in
docs.jsoninstead of inlining the path here.The coding guideline specifies
openapi: 'METHOD /path'(without a spec file path). Mintlify supports setting a default OpenAPI spec for a navigation group via"openapi": "/path/to/spec.json"at the group level, then referencing endpoints as"GET /path"in the pages array oropenapi: "POST /api/sessions"in MDX frontmatter.Registering the spec once in
docs.jsonunder theSessionsgroup keeps the MDX files path-agnostic and the spec location in a single authoritative place:// docs.json — Sessions group { "group": "Sessions", + "openapi": "/api-reference/openapi/sessions.json", "pages": [ - "api-reference/sessions/create" + "POST /api/sessions" ] }// api-reference/sessions/create.mdx openapi: "/api-reference/openapi/sessions.json POST /api/sessions" +openapi: "POST /api/sessions"As per coding guidelines,
api-reference/**/*.mdxpages should use the formatopenapi: 'METHOD /path'.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api-reference/sessions/create.mdx` at line 3, The frontmatter in create.mdx currently inlines the spec file path with the method ("openapi: \"/api-reference/openapi/sessions.json POST /api/sessions\""); change it to the guideline format "openapi: 'POST /api/sessions'" and instead register the spec file once in docs.json under the Sessions navigation group (set the group's "openapi" to "/api-reference/openapi/sessions.json") so pages remain path-agnostic; update create.mdx's openapi value and ensure other api-reference/*.mdx pages follow the same "METHOD /path" format.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api-reference/openapi/sessions.json`:
- Around line 26-81: Add a stable operationId to the POST /sessions operation so
SDKs and Mintlify anchors have a predictable target; update the POST operation
object (the "Create session" endpoint) by adding an "operationId" field (e.g.,
"createSession" or "createSessionWithInitialChat") that uniquely identifies this
operation and matches your naming conventions so future x-mint overrides and
code generators produce consistent function names.
- Around line 272-278: The array schema for "globalSkillRefs" is missing a
maxItems constraint; update the "globalSkillRefs" schema in the OpenAPI document
to include a suitable "maxItems" value that reflects the API's real limit (or a
conservative documented maximum) so clients and linters won't treat the array as
unbounded, e.g., add "maxItems": <number> to the array definition for
globalSkillRefs.
- Line 2: The OpenAPI file declares "openapi": "3.1.0" so all uses of nullable:
true are invalid; update the Chat and Session schemas (and any other schemas
between the noted ranges) to replace nullable: true with type arrays that
include "null" (e.g., change "type": "string", "nullable": true to "type":
["string","null"]) and for enum fields like lifecycleState and prStatus ensure
the enum explicitly includes null (or change the type to ["string","null"] and
add null to the enum values) so the schema is valid under OpenAPI 3.1; locate
schemas by their names Chat, Session and the properties lifecycleState and
prStatus to apply these changes consistently.
In `@api-reference/sessions/create.mdx`:
- Around line 1-4: Add a description key to the MDX frontmatter so the page has
SEO and tooltip metadata; update the frontmatter block that currently contains
title: "Create Session" and openapi: "/api-reference/openapi/sessions.json POST
/api/sessions" by adding a descriptive string (e.g., description: "Create a new
API session for authentication and token management") directly under the title
line, preserving YAML syntax and quoting, so the page follows the **/*.mdx
guideline for clear titles and descriptions.
- Line 3: The frontmatter in create.mdx currently inlines the spec file path
with the method ("openapi: \"/api-reference/openapi/sessions.json POST
/api/sessions\""); change it to the guideline format "openapi: 'POST
/api/sessions'" and instead register the spec file once in docs.json under the
Sessions navigation group (set the group's "openapi" to
"/api-reference/openapi/sessions.json") so pages remain path-agnostic; update
create.mdx's openapi value and ensure other api-reference/*.mdx pages follow the
same "METHOD /path" format.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7dcccf3-5ef6-4359-98dd-f765f0c31587
📒 Files selected for processing (3)
api-reference/openapi/sessions.jsonapi-reference/sessions/create.mdxdocs.json
PR #174's nav structure was written Apr 27, before three pages were added to main: - api-reference/ai/models (added by #177 on May 1) - api-reference/sessions/create (added by #186 on May 3) - api-reference/sessions/get (added by #185 on May 4) These pages exist on disk but had no nav entry in the combined PR, which would orphan them once #189 lands. Adding them in: - Accounts tab → new "Sessions" group placed after "Sandboxes" (matches main's grouping of sessions with sandboxes) - Chat tab → new "Models" group at the end (closest semantic fit; main grouped this under "Tools & Reference" which doesn't exist in our restructured 9-tab layout) Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
POST /api/sessions(create session + initial chat in one transaction)Sessionfields the GET reference was missing:autoCommitPushOverride,autoCreatePrOverride,prNumber,prStatusChatschema for the initial chat returned alongside the session{error}to match open-agents — nostatus:"error"divergence here, which is a deliberate compatibility choice for the eventual frontend cutoverProvenance
Captured the live response shape from
https://sandbox.recoupable.com(open-agents production) so the spec mirrors what downstream clients are already consuming. Cross-referenced withapps/web/lib/db/schema.tsin open-agents for nullability + enum constraints.Notes for reviewers
This branch was cut from
mainand includes cherry-picked nav commits (the Phase 1-3 restructure + the GET endpoint reference) so the docs render coherently in isolation. PR #185 (docs/get-session-by-id) carries the same nav commits — whichever lands first, the other will rebase cleanly because the cherry-picked commits are byte-identical.Test plan
npx mintlify@latest devrenders without errorsCreate Sessionpage appears underAgents & Sandboxes › SessionsSession,Chat, andErrorschemas render correctly in the auto-generated reference🤖 Generated with Claude Code
Summary by cubic
Adds the API reference for creating sessions via POST
/api/sessions, including an OpenAPI 3.1 spec and a docs page. Aligns theSessionschema, adds aChatschema, and updates the nav under Agents & Sandboxes › Sessions./api/sessionsthat creates a session (starts inprovisioning) and an initial empty chat; returns{ session, chat }.title,repoOwner,repoName,branch/isNewBranch,cloneUrl,sandboxType:"vercel",autoCommitPush,autoCreatePr.x-api-keyor Bearer; responses 200/400/401/500 with{ status:"error", error }.Sessionschema addsautoCommitPushOverride,autoCreatePrOverride,prNumber,prStatus; includes newChatschema.docs.json.Written for commit bdf89d9. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation