API · 2.0.0

Keys

API keys minted for use from SDKs and external MCP clients.

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

get/keys

List API keys for the active org

Responses

  • 200Keys (no secrets).
  • 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/keys \
  -H 'Authorization: Bearer sk_live_...' \
post/keys

Mint an API key

Returns the raw key once. After this response it can only be rotated, not retrieved.

Request body

FieldTypeRequiredDescription
namestringyes
scopesstring[]yes

Responses

  • 201Created. `secret` shown once.
  • 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/keys \
  -H 'Authorization: Bearer sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{ ... }'