Skip to content
Create or get a user

Create or get a user

Register your application’s user ID. Repeating this request returns the same user without changing their details.

POST/api/v1/users

Request#

TypeScript
const response = await fetch("https://api.smallworld.sh/api/v1/users", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "userId": "customer_123",
  "email": "customer@example.com"
}),
});
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.

Request body#

userIdstringrequired

Your user's unique identifier in this workspace. At most 512 characters, without surrounding whitespace or null bytes. The older name id is still accepted; sending both with different values is invalid.

emailstring | null

Email for a new user: a valid address of at most 254 characters after trimming. Omit, null, or an empty string stores null. Existing users are unchanged; use PATCH to update their email.

groupIdstring | null

Moves a new or an existing user into this group. Omit to leave their memberships unchanged, or send null to remove them from every group. The group must already exist. Not together with groupIds.

groupIdsstring[]

Replaces all of the user's memberships with this list, for a new or an existing user. An empty list removes them from every group, and duplicates count once. Every group must already exist. Not together with groupId.

Responses#

The user was created. You can now discover their tools or connect an integration.

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

Public user IDs are identifiers from your application, not Smallworld's internal database IDs. Derive them from your authenticated user on your backend.

Returns 201 when created, or 200 when this ID already exists. Repeated requests keep the existing email, even if you supply a different email.

User objects have groupIds and no longer have groupId. This is a breaking change: read user.groupIds wherever you read user.groupId, including the user in execution responses and the members of a group.

A user can belong to any number of groups. groupId is a move, also for existing users: a user with no group joins, and a user in exactly one other group leaves it and joins this one, with their open sessions that acted for the old group now acting for the new one. For a user in several groups it returns user_in_multiple_groups, also when it names a group they are already in. groupId: null removes the user from every group.

groupIds replaces the whole list in one step. When it replaces exactly one group with exactly one other, it is a move and the user's sessions follow. Otherwise sessions that acted for a removed group are closed. groupId: null closes them in the same way. Sending groupId together with groupIds is invalid.

An unknown group in groupId or groupIds returns group_not_found, and nothing is created or changed, not even the user. To add one group and keep the others, use PUT /users/:userId/groups/:groupId.

Create a user before loading their /worlds/:worldId/tools catalog. Execution and connect-session creation can also create users automatically.