API · 2.0.0

Org

Members + invitations.

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

post/invitations/{token}/accept

Accept an invitation

Public endpoint — token is unguessable and one-time-use. Caller must be authenticated as the invitee email or the request fails 403.

Parameters

NameInRequiredTypeDescription
tokenpathyesstring

Responses

  • 200Accepted; caller is now a member.
  • 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/invitations/:token/accept \
  -H 'Authorization: Bearer sk_live_...' \
get/org/{orgId}/invitations

List pending invitations

Parameters

NameInRequiredTypeDescription
orgIdpathyesstringCUID

Responses

  • 200Invitations.
  • 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/org/:orgId/invitations \
  -H 'Authorization: Bearer sk_live_...' \
post/org/{orgId}/invitations

Invite a teammate

Parameters

NameInRequiredTypeDescription
orgIdpathyesstringCUID
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
emailstringyesInvitee email.
role"ADMIN" | "MEMBER"yes

Responses

  • 201Invitation created and emailed.
  • 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/org/:orgId/invitations \
  -H 'Authorization: Bearer sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
get/org/{orgId}/members

List org members

Parameters

NameInRequiredTypeDescription
orgIdpathyesstringCUID

Responses

  • 200Members.
  • 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/org/:orgId/members \
  -H 'Authorization: Bearer sk_live_...' \
patch/org/{orgId}/members/{userId}

Change a member's role

Parameters

NameInRequiredTypeDescription
orgIdpathyesstringCUID
userIdpathyesstringCUID

Request body

FieldTypeRequiredDescription
roleRoleyes

Responses

  • 200Updated member.
  • 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/org/:orgId/members/:userId \
  -H 'Authorization: Bearer sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
delete/org/{orgId}/members/{userId}

Remove a member from the org

Parameters

NameInRequiredTypeDescription
orgIdpathyesstringCUID
userIdpathyesstringCUID

Responses

  • 204Removed.
  • 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/org/:orgId/members/:userId \
  -H 'Authorization: Bearer sk_live_...' \