Skip to main content
POST
/
session
/
switch-workspace
Switch active workspace
curl --request POST \
  --url https://api.wacht.dev/session/switch-workspace \
  --cookie session_id=
{
  "status": 200,
  "message": "",
  "data": {
    "id": "123456789012345678",
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z",
    "signin_attempts": [
      {
        "id": "555555555555555555",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-15T10:30:00Z",
        "method": "email_otp",
        "completed": true,
        "current_step": "verify_otp"
      }
    ],
    "signins": [
      {
        "id": "987654321098765432",
        "user_id": "123456789012345678",
        "session_id": "123456789012345678",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-15T10:30:00Z",
        "expires_at": "2024-01-15T11:30:00Z",
        "active_organization_membership_id": "111111111111111111",
        "active_workspace_membership_id": "222222222222222222",
        "active_organization_membership": {
          "id": "111111111111111111",
          "organization_id": "777777777777777777",
          "roles": [
            {
              "id": "888888888888888888",
              "name": "Admin",
              "permissions": [
                "organization:admin",
                "organization:manage"
              ]
            }
          ]
        },
        "active_workspace_membership": {
          "id": "222222222222222222",
          "workspace_id": "999999999999999999",
          "organization_membership_id": "111111111111111111",
          "roles": [
            {
              "id": "101010101010101010",
              "name": "Editor",
              "permissions": [
                "workspace:read",
                "workspace:write"
              ]
            }
          ]
        }
      }
    ],
    "signup_attempts": [
      {
        "id": "666666666666666666",
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-15T10:30:00Z"
      }
    ],
    "active_signin_id": "987654321098765432",
    "active_signin": {
      "id": "987654321098765432",
      "user_id": "123456789012345678",
      "session_id": "123456789012345678",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z",
      "expires_at": "2024-01-15T11:30:00Z",
      "active_organization_membership_id": "111111111111111111",
      "active_workspace_membership_id": "222222222222222222",
      "active_organization_membership": {
        "id": "111111111111111111",
        "organization_id": "777777777777777777",
        "roles": [
          {
            "id": "888888888888888888",
            "name": "Admin",
            "permissions": [
              "organization:admin",
              "organization:manage"
            ]
          }
        ]
      },
      "active_workspace_membership": {
        "id": "222222222222222222",
        "workspace_id": "999999999999999999",
        "organization_membership_id": "111111111111111111",
        "roles": [
          {
            "id": "101010101010101010",
            "name": "Editor",
            "permissions": [
              "workspace:read",
              "workspace:write"
            ]
          }
        ]
      }
    }
  },
  "session": {
    "id": "123456789012345678",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  },
  "errors": [
    {
      "code": "INVALID_CREDENTIALS",
      "message": "Invalid credentials. Please try again."
    }
  ]
}

Authorizations

session_id
string
cookie
required

Session-based authentication using cookies

Query Parameters

workspace_id
string

Workspace ID to switch to. Empty string to clear selection.

Response

Workspace switched successfully

status
integer

HTTP status code

Example:

200

message
string

Response message (empty on success)

Example:

""

data
object
session
object

Minimal session info included in every response

errors
object[] | null

Error details (null on success)