Skip to main content
POST
/
organization
/
switch
Switch Organization
curl --request POST \
  --url https://apiweb.mile.app/api/v3/organization/switch \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "targetUserId": "507f1f77bcf86cd799439012"
}
'
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
  "expires_in": 31536000,
  "data": {
    "_id": "507f1f77bcf86cd799439012",
    "name": "John Doe",
    "email": "john@example.com",
    "organizationId": "507f1f77bcf86cd799439023"
  },
  "isHubSet": true,
  "organizations": [
    {
      "userId": "507f1f77bcf86cd799439011",
      "organizationId": "507f1f77bcf86cd799439022",
      "organizationName": "Acme Corp",
      "organizationLogo": "https://storage.mile.app/logos/acme.png",
      "roleName": "owner",
      "isCurrent": false
    },
    {
      "userId": "507f1f77bcf86cd799439012",
      "organizationId": "507f1f77bcf86cd799439023",
      "organizationName": "Beta Inc",
      "organizationLogo": null,
      "roleName": "admin",
      "isCurrent": true
    }
  ]
}

Authorizations

Authorization
string
header
required

Use a valid Bearer token to authenticate.

Body

application/json
targetUserId
string
required

The user ID to switch to. This can be obtained from the organizations array returned by Get User Organizations endpoint.

Response

Switch successful - returns new access token and user data

token
string

New access token for the target organization

expires_in
integer

Token expiration time in seconds

data
object

User data for the target organization

isHubSet
boolean

Whether user has hub assigned in the target organization

organizations
object[]

Updated list of all user's organizations