Users

Operations around User management.

Endpoints

POST /api/users
GET /api/admin/users
POST /api/users/:userId
GET /api/users/:userId
DELETE /api/users/:userId
GET /api/users/:userId/websites
GET /api/users/:userId/teams

POST /api/users

Creates a user.

Parameters

  • username: (string) The user's username.
  • password: (string) The user's password.
  • role: (string) Choose from admin | user | view-only.

Request body

{
  "username": "admin",
  "password": "umami",
  "role": "admin"
}

Sample response

{
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "username": "demo",
    "role": "user"
}

GET /api/admin/users

Returns all users. Admin access is required.

Sample response

[
  {
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "username": "admin",
    "role": "admin",
    "createdAt": "0000-00-00T00:00:00.000Z"
  }
]

GET /api/users/:userId

Gets a user by ID.

Sample response

{
  "username" : "xxxxxxxxxxx",
  "id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "role" : "user",
  "createdAt" : "0000-00-00T00:00:00.000Z"
}

POST /api/users/:userId

Updates a user.

Parameters

  • username: (optional string) The user's username.
  • password: (optional string) The user's password.
  • role: (optional string) Select from admin, user, view-only.

Request body

{
  "username": "admin",
  "password": "umami",
  "role": "admin"
}

Sample response

{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "username": "admin",
  "role": "admin",
  "createdAt": "0000-00-00T00:00:00.000Z"
}

DELETE /api/users/:userId

Deletes a user.

Sample response

ok

GET /api/users/:userId/websites

Gets all websites that belong to a user.

Parameters

  • query: (optional string) Search text.
  • page: (optional number, default 1) Determines page.
  • pageSize: (optional string) Determines how many results to return.
  • orderBy: (optional string, default name) Order by column name.

Sample response

{
  "data": [
    {
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "updatedAt": "0000-00-00T00:00:00.00Z",
      "user": {
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "username": "xxxxx"
      },
      "domain": "xxxxxxx",
      "teamId": null,
      "resetAt": null,
      "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "createdBy": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "shareId": "xxxxxxxxxxxxx",
      "createdAt": "0000-00-00T00:00:00.00Z",
      "name": "xxxxx",
      "deletedAt": null
    }
  ],
  "orderBy": "name",
  "count": 3,
  "pageSize": 10,
  "page": 1
}

GET /api/users/:userId/teams

Gets all teams that belong to a user.

Parameters

  • query: (string | optional) Search text.
  • page: (number | optional, default 1) Determines page.
  • pageSize: (string | optional) Determines how many results to return.
  • orderBy: (string | optional, default name) Order by column name.

Sample response

{
  "data": [
    {
      "_count": {
        "website": 0,
        "teamUser": 1
      },
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "logoUrl": null,
      "deletedAt": null,
      "teamUser": [
        {
          "teamId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
          "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
          "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
          "role": "team-owner",
          "updatedAt": "0000-00-00T00:00:00.00Z",
          "createdAt": "0000-00-00T00:00:00.00Z",
          "user": {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "username": "xxxxx"
          }
        }
      ],
      "accessCode": "team_xxxxxxxxxxx",
      "createdAt": "0000-00-00T00:00:00.00Z",
      "updatedAt": "0000-00-00T00:00:00.00Z",
      "name": "xxxxxx"
    }
  ],
  "count": 8,
  "pageSize": 10,
  "page": 1
}