Upgrade from 9.4 to 9.5
RESTHeart 9.5 introduces a breaking change in the restheart-accounts module: all user-facing terminology for multi-team management has been unified from "tenant" to "team".
This page provides a migration guide for deployments using restheart-accounts.
What changed
REST API endpoints
| 9.4 | 9.5 |
|---|---|
|
|
|
|
Request and response field names changed accordingly:
-
Request body:
tenantId→teamId -
Response / JWT claim:
tenant→team(configurable viateam-claim-name)
MongoDB document fields
Users collection (users):
| 9.4 | 9.5 |
|---|---|
|
|
|
|
Invitations collection (auth_invitations):
| 9.4 | 9.5 |
|---|---|
|
|
The teams collection is unchanged.
Configuration (restheart-default-config.yml)
| 9.4 | 9.5 |
|---|---|
|
|
|
|
|
|
SPI changes (custom MembershipProvider implementations)
| 9.4 | 9.5 |
|---|---|
|
|
|
|
The MembershipProvider interface method signatures are unchanged.
Plugin class renames
| 9.4 | 9.5 |
|---|---|
|
|
|
|
Migration steps
1. Migrate MongoDB data
Run the following commands against your database before upgrading RESTHeart:
// Migrate user documents
db.users.updateMany({}, [
{ $set: { team: "$tenant", teams: "$tenants" } },
{ $unset: ["tenant", "tenants"] }
]);
// Migrate invitation documents
db.auth_invitations.updateMany({}, [
{ $set: { teamId: "$orgId" } },
{ $unset: ["orgId"] }
]);
|
Tip
|
Test the migration on a staging database first. The updateMany with aggregation pipeline is idempotent — running it twice is safe (the second run matches zero documents).
|
2. Update RESTHeart configuration
In restheart.yml, rename:
# Before (9.4)
accountsConfig:
tenant-claim-name: tenant
# ...
getTenantsService:
enabled: true
switchTenantService:
enabled: true
# After (9.5)
accountsConfig:
team-claim-name: team
# ...
getTeamsService:
enabled: true
switchTeamService:
enabled: true
3. Update front-end and API clients
If your front-end or API clients reference:
-
The
tenantJWT claim → change toteam(or whatever you set inteam-claim-name) -
GET /auth/tenants→GET /auth/teams -
POST /auth/switch-tenant→POST /auth/switch-team -
Request body
{ "tenantId": … }→{ "teamId": … }
4. Update custom plugins
If you have custom @RegisterPlugin interceptors or services that read user.tenant or user.tenants, update them to user.team / user.teams.
If you implement a custom MembershipProvider:
-
Replace
TenantRefwithTeamRef -
Replace
Membership.tenantId()withMembership.teamId()