Create a user group via API

Create User Group

Create a user group and receive a userGroupId for use in events (metadata.usergroup) and leaderboards. Auth: JWT or API key — see API reference.

ℹ️

JWT: `sub` claim

With JWT authentication, the sub claim is required and must not be empty — otherwise the request is rejected before it reaches this endpoint. For POST /usergroup, sub has no effect on the created group; it is not used as a user ID. Use any stable service identifier (e.g. backend-integration), not an end-user ID.

Endpoint

POST /usergroup

Request Body

{
  "userGroupId": "your-usergroup-id",
  "title": {
    "default": "Region Unterfranken",
    "de": "Region Unterfranken"
  },
  "description": {
    "default": "Users in Unterfranken",
    "de": "Nutzer in Unterfranken"
  }
}

Omit userGroupId to let the API generate one (e.g. ug_a1b2c3d4e5f6).

Field Descriptions

FieldTypeRequiredDescription
userGroupIdstringNoYour identifier (a-z, A-Z, 0-9, _, -, max 128). Not "default".
titleobjectYesDisplay name; requires default and de.
descriptionobjectNoOptional; same language keys as title.

Example Request

curl -X POST "/v1/usergroup" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userGroupId": "your-usergroup-id",
    "title": {
      "default": "Region Unterfranken",
      "de": "Region Unterfranken"
    }
  }'

Response

{
  "message": "User group created successfully",
  "userGroupId": "your-usergroup-id",
  "createdAt": 1740000000000
}

Status Codes

CodeDescription
201Created
400Invalid body or userGroupId
401Missing or invalid auth
409userGroupId already exists
500Server error

Use the group when sending events:

"metadata": { "usergroup": ["your-usergroup-id"] }