Skip to main content
PUT
/
tenant
/
{tenantId}
/
admin
/
user
/
{userId}
/
selectTenant
/
{selectedId}
SetTenant
curl --request PUT \
  --url https://api.example.com/tenant/{tenantId}/admin/user/{userId}/selectTenant/{selectedId}
{
  "isSuccess": true,
  "isFailure": false,
  "error": null,
  "value": {
    "id": 42,
    "name": "Example"
  }
}

Description

This endpoint changes the active tenant context for a user who belongs to multiple tenants.

Input

  • tenantId (path, required): Identifier of the tenant initiating the context change
  • userId (path, required): Identifier of the user whose context is being changed
  • selectedId (path, required): Identifier of the tenant that should become active
  • cancellationToken (optional): Token to cancel the asynchronous operation

Output

Returns a Result<MultiTenantUserModel> containing the updated multi-tenant user state.

Examples

Request:
PUT /api/tenant/1024/users/4242/set-tenant/512
Response (200 OK):
{
  "data": {
    "tenantId": 512,
    "userId": 4242,
    "userName": "[email protected]",
    "tenants": [
      { "id": 1024, "name": "Acme Corp", "isUserEnabled": true },
      { "id": 512, "name": "Globex", "isUserEnabled": true }
    ],
    "invitations": []
  },
  "isSuccess": true
}

Errors

  • 400 Bad Request: Invalid identifiers
  • 401 Unauthorized: Authentication credentials are missing or invalid
  • 403 Forbidden: User lacks permission to change tenant contexts
  • 404 Not Found: User or target tenant does not exist
  • 500 Internal Server Error: Unexpected server error occurred

Notes

  • User must be a member of the target tenant
  • Context change affects subsequent operations

Path Parameters

tenantId
integer<int64>
required

Identifier of the tenant initiating the context change.

userId
integer<int64>
required

Identifier of the user whose context is being changed.

selectedId
integer<int64>
required

Identifier of the tenant that should become active.

Response

Tenant context updated successfully.

Wrapper for API operation results containing success status, error information, and return value.

isSuccess
boolean

True if the operation completed successfully, false otherwise.

Example:

true

isFailure
boolean

True if the operation failed, false otherwise.

Example:

false

error
object

Error information returned when the operation fails.

Example:
{
"code": "ValidationError",
"message": "The request parameters failed validation.",
"info": [
"The Name field is required.",
"The Id field must be greater than 0."
]
}
value
object

The result value returned when the operation is successful.

Example:
{
"tenants": [
{
"id": 1024,
"name": "Acme Corp",
"isUserEnabled": true
}
],
"invitations": [
{
"id": 9001,
"tenant": {
"id": 512,
"name": "Globex",
"isUserEnabled": false
},
"invitorFirstName": "Dana",
"invitorLastName": "Scully"
}
],
"tenantId": 1024,
"userId": 4242,
"userName": "[email protected]"
}