Set a member's role in their personal space

Give one member or guest their own role in their personal space, overriding the organization's personal_space_role default Body: exactly one of preset_role / custom_role_id; a custom_role_id must name a role of this organization (404 otherwise). A member holds the chosen role plus, short of admin, agents:delete, skills:delete, integrations:delete and schedules:delete there. A guest holds it capped to operator (the permissions the chosen role shares with operator, plus the deletes), whatever role is set. The personal space is provisioned if the member has none yet. Owners and admins always hold admin in their own personal space: targeting one is 409 redundant_space_role. A change of the member's org role keeps the override, a guest's capped as above, except a promotion to owner or admin, which drops it. A dropped override is recorded in the org.member_role_updated audit entry (personalSpaceRoleCleared). Leaving or being removed drops it too; nothing restores a dropped override. A custom role named by an override cannot be deleted (409 role_in_use). Same guard as changeMemberRole (members:change-role).

PUT/api/orgs/{orgId}/members/{userId}/personal-space-role

Authorization

better-auth.session_token<token>

Cookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.

In: cookie

Path Parameters

orgId*string
userId*string

Request Body

application/json

curl -X PUT "https://your-instance/api/orgs/string/members/string/personal-space-role" \  -H "Content-Type: application/json" \  -d '{    "preset_role": "admin"  }'
{
  "userId": "string",
  "displayName": "string",
  "email": "string",
  "role": "owner",
  "joinedAt": "2019-08-24T14:15:22Z",
  "spaces": [
    {
      "id": "string",
      "name": "string",
      "source": "explicit",
      "role": null
    }
  ],
  "personal_space_role": null,
  "personal_space_default_role": {
    "preset_role": "admin",
    "name": "string"
  }
}

{
  "type": "https://docs.appstrate.dev/errors/validation-failed",
  "title": "Validation Failed",
  "status": 400,
  "detail": "name: Invalid input: expected string, received undefined (+2 more)",
  "code": "validation_failed",
  "request_id": "req_abc123",
  "errors": [
    {
      "field": "name",
      "code": "required",
      "message": "Invalid input: expected string, received undefined"
    },
    {
      "field": "email",
      "code": "invalid_format",
      "message": "Invalid email address"
    },
    {
      "field": "age",
      "code": "invalid_type",
      "message": "Invalid input: expected number, received string"
    }
  ]
}

{
  "type": "https://docs.appstrate.dev/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Invalid or missing session",
  "code": "unauthorized",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "Insufficient permissions",
  "code": "forbidden",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "Resource not found",
  "code": "not_found",
  "request_id": "req_abc123"
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string",
  "code": "string",
  "request_id": "string",
  "param": "string",
  "retry_after": 0,
  "login_refusal": "grant",
  "integration_diagnostic": "string",
  "errors": [
    {
      "field": "string",
      "code": "string",
      "message": "string",
      "title": "string",
      "line": 1,
      "column": 1,
      "candidate_connections": [
        {
          "id": "string",
          "label": "string",
          "account_id": "string",
          "owned_by_actor": true,
          "needs_reconnection": true,
          "scopes_granted": [
            "string"
          ],
          "missing_scopes": [
            "string"
          ]
        }
      ],
      "connection_id": "string",
      "missing_scopes": [
        "string"
      ],
      "remedy": "new_connection",
      "owned_by_actor": true,
      "required_scopes": [
        "string"
      ],
      "auth_key": "string",
      "required_auth_key": "string",
      "available_auth_keys": [
        "string"
      ],
      "source": "admin_pin",
      "connect_url": "http://example.com",
      "expiresAt": "2019-08-24T14:15:22Z",
      "packageId": "string"
    }
  ]
}