Skip to content
Move a user to a group

Move a user to a group

Move a represented user into a group: a user with no group joins it, and a user in one other group leaves that group for this one. An unknown user is created.

PUT/api/v1/groups/:groupId/users/:userId

Request#

TypeScript
const response = await fetch("https://api.smallworld.sh/api/v1/groups/team_42/users/customer_123", {
  method: "PUT",
  headers: { Authorization: `Bearer ${apiKey}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();

Use your server-side apiKey. Replace the example IDs.

Path parameters#

groupIdstringrequired

Your application's group ID, URL-encoded. At most 512 characters, with no surrounding whitespace or null bytes.

userIdstringrequired

Your application's user ID, URL-encoded. At most 512 characters, with no surrounding whitespace or null bytes. Encode the IDs . and .. as %2E and %2E%2E: curl sends these as written, but JavaScript's fetch removes them even when encoded.

Responses#

Returns id, nullable email, groupIds, and ISO 8601 createdAt and updatedAt timestamps. The ID is your application's identifier; groupIds lists your IDs for the user's current groups, ordered by ID, and is empty when they belong to none.

200 response
{
  "id": "customer_123",
  "email": "customer@example.com",
  "groupIds": [
    "team_42"
  ],
  "createdAt": "2026-10-10T12:00:00.000Z",
  "updatedAt": "2026-10-10T12:00:00.000Z"
}
More about this endpoint

This endpoint is a move. A user with no group joins this one. A user in exactly one other group leaves it and joins this one in one step. Moving a user to the only group they are in changes nothing, so a retry is safe.

A user in several groups can't be moved: the request returns user_in_multiple_groups, also when it names a group they are already in. To add a group and keep the others, use PUT /users/:userId/groups/:groupId. To replace all memberships, send groupIds to POST /users.

An unknown userId is created without an email. The group must already exist; for an unknown group, nothing is created.

A move succeeds while the user has a running command or a pending approval. Their open sessions that acted for the old group now act for the new one. A command running at that moment keeps running: a call prepared with the old group's connection ends when it is dispatched, pending saves to the old group's mounts are refused, and the next call uses the new group. A call waiting for approval on the old group's connection ends interrupted with errorCode integration_connection_stale.

A groupless session stays groupless after its user joins a group.

The Playground user can't change groups, and no other user can join the Playground Group.