API · 2.0.0

Sessions

Conversation threads inside a Space.

5 operations. All requests need Authorization: Bearer sk_.... Responses use the standard envelope; see overview for shapes and error codes.

get/spaces/{slug}/sessions

List sessions in a Space

Parameters

NameInRequiredTypeDescription
slugpathyesstring

Responses

  • 200Sessions.
  • 400Validation failed. `error.code = VALIDATION_ERROR`. `error.details.errors` lists per-field issues from zod.
  • 401Missing or invalid auth. `error.code = AUTH_ERROR`.
  • 403Authenticated but not allowed (wrong role, not a member, or org scope mismatch). `error.code = FORBIDDEN`.
  • 404Resource does not exist or is invisible to the caller. `error.code = NOT_FOUND`.
  • 409Conflict — duplicate slug, race condition, or invalid state transition. `error.code = CONFLICT`.
  • 429Rate limit exceeded. `error.code = RATE_LIMIT`. Retry after the window listed in `Retry-After`.
  • 500Unexpected server error. `error.code = INTERNAL_ERROR`. Logged with the `requestId` echoed in metadata.
cURL example
curl -X GET https://switchy.build/api/spaces/:slug/sessions \
  -H 'Authorization: Bearer sk_live_...' \
post/spaces/{slug}/sessions

Create a session

Parameters

NameInRequiredTypeDescription
slugpathyesstring
Idempotency-KeyheadernostringOpaque client-generated UUID. The first request wins; identical follow-ups within 24h return the original response. Recommended on all POST endpoints.

Request body

FieldTypeRequiredDescription
namestringyes
descriptionstringno
participantUserIdsstring[]no
defaultAgentstringnoSlug of the default model/agent.

Responses

  • 201Created session.
  • 400Validation failed. `error.code = VALIDATION_ERROR`. `error.details.errors` lists per-field issues from zod.
  • 401Missing or invalid auth. `error.code = AUTH_ERROR`.
  • 403Authenticated but not allowed (wrong role, not a member, or org scope mismatch). `error.code = FORBIDDEN`.
  • 404Resource does not exist or is invisible to the caller. `error.code = NOT_FOUND`.
  • 409Conflict — duplicate slug, race condition, or invalid state transition. `error.code = CONFLICT`.
  • 429Rate limit exceeded. `error.code = RATE_LIMIT`. Retry after the window listed in `Retry-After`.
  • 500Unexpected server error. `error.code = INTERNAL_ERROR`. Logged with the `requestId` echoed in metadata.
cURL example
curl -X POST https://switchy.build/api/spaces/:slug/sessions \
  -H 'Authorization: Bearer sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
get/spaces/{slug}/sessions/{sessionId}

Get a session

Parameters

NameInRequiredTypeDescription
slugpathyesstring
sessionIdpathyesstringCUID

Responses

  • 200The session.
  • 400Validation failed. `error.code = VALIDATION_ERROR`. `error.details.errors` lists per-field issues from zod.
  • 401Missing or invalid auth. `error.code = AUTH_ERROR`.
  • 403Authenticated but not allowed (wrong role, not a member, or org scope mismatch). `error.code = FORBIDDEN`.
  • 404Resource does not exist or is invisible to the caller. `error.code = NOT_FOUND`.
  • 409Conflict — duplicate slug, race condition, or invalid state transition. `error.code = CONFLICT`.
  • 429Rate limit exceeded. `error.code = RATE_LIMIT`. Retry after the window listed in `Retry-After`.
  • 500Unexpected server error. `error.code = INTERNAL_ERROR`. Logged with the `requestId` echoed in metadata.
cURL example
curl -X GET https://switchy.build/api/spaces/:slug/sessions/:sessionId \
  -H 'Authorization: Bearer sk_live_...' \
patch/spaces/{slug}/sessions/{sessionId}

Update a session

Parameters

NameInRequiredTypeDescription
slugpathyesstring
sessionIdpathyesstringCUID

Request body

FieldTypeRequiredDescription
titlestringno
modelstringno

Responses

  • 200Updated session.
  • 400Validation failed. `error.code = VALIDATION_ERROR`. `error.details.errors` lists per-field issues from zod.
  • 401Missing or invalid auth. `error.code = AUTH_ERROR`.
  • 403Authenticated but not allowed (wrong role, not a member, or org scope mismatch). `error.code = FORBIDDEN`.
  • 404Resource does not exist or is invisible to the caller. `error.code = NOT_FOUND`.
  • 409Conflict — duplicate slug, race condition, or invalid state transition. `error.code = CONFLICT`.
  • 429Rate limit exceeded. `error.code = RATE_LIMIT`. Retry after the window listed in `Retry-After`.
  • 500Unexpected server error. `error.code = INTERNAL_ERROR`. Logged with the `requestId` echoed in metadata.
cURL example
curl -X PATCH https://switchy.build/api/spaces/:slug/sessions/:sessionId \
  -H 'Authorization: Bearer sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
delete/spaces/{slug}/sessions/{sessionId}

Archive a session

Soft-deletes the session. Messages remain in the DB for audit.

Parameters

NameInRequiredTypeDescription
slugpathyesstring
sessionIdpathyesstringCUID

Responses

  • 204Archived. No body.
  • 400Validation failed. `error.code = VALIDATION_ERROR`. `error.details.errors` lists per-field issues from zod.
  • 401Missing or invalid auth. `error.code = AUTH_ERROR`.
  • 403Authenticated but not allowed (wrong role, not a member, or org scope mismatch). `error.code = FORBIDDEN`.
  • 404Resource does not exist or is invisible to the caller. `error.code = NOT_FOUND`.
  • 409Conflict — duplicate slug, race condition, or invalid state transition. `error.code = CONFLICT`.
  • 429Rate limit exceeded. `error.code = RATE_LIMIT`. Retry after the window listed in `Retry-After`.
  • 500Unexpected server error. `error.code = INTERNAL_ERROR`. Logged with the `requestId` echoed in metadata.
cURL example
curl -X DELETE https://switchy.build/api/spaces/:slug/sessions/:sessionId \
  -H 'Authorization: Bearer sk_live_...' \