Skip to content

Users API

Endpoints for user management. Most endpoints require admin authentication.

List Users

Get a paginated list of users.

http
GET /api/users

Query Parameters:

ParameterTypeDescription
pageintPage number (default: 1)
limitintItems per page (default: 20, max: 100)
searchstringSearch by name or email
rolestringFilter by role

Response:

json
{
  "data": [
    {
      "id": 1,
      "email": "user@example.com",
      "name": "John Doe",
      "roles": ["ROLE_USER"],
      "notificationsEnabled": true,
      "emailNotificationsEnabled": true,
      "createdAt": "2024-01-15T10:30:00+00:00"
    }
  ],
  "meta": {
    "currentPage": 1,
    "totalPages": 5,
    "totalItems": 100,
    "itemsPerPage": 20
  }
}

Admin Only

This endpoint requires ROLE_ADMIN.

Get User

Get a single user by ID.

http
GET /api/users/{id}

Response:

json
{
  "id": 1,
  "email": "user@example.com",
  "name": "John Doe",
  "street": "123 Main St",
  "postalCode": "12345",
  "city": "Amsterdam",
  "country": "Netherlands",
  "roles": ["ROLE_USER"],
  "notificationsEnabled": true,
  "emailNotificationsEnabled": true,
  "profilePicture": "/api/user/profile-picture/abc123.jpg",
  "createdAt": "2024-01-15T10:30:00+00:00"
}

Update User

Update user information.

http
PATCH /api/users/{id}

Request Body:

json
{
  "name": "Jane Doe",
  "street": "456 Oak Ave",
  "postalCode": "54321",
  "city": "Rotterdam",
  "country": "Netherlands",
  "notificationsEnabled": false,
  "emailNotificationsEnabled": true
}

All fields are optional - only provided fields are updated.

Delete User

Delete a user account.

http
DELETE /api/users/{id}

Response: 204 No Content

Cascading Delete

Deleting a user will also delete:

  • All products owned by the user
  • All receipts for those products
  • All warranty claims where user is customer
  • All device tokens

Current User Endpoints

Get Current User

Get the authenticated user's profile.

http
GET /api/me

Response: Same as Get User

Update Current User

Update the authenticated user's profile.

http
PATCH /api/me

Request Body: Same as Update User

Delete Current User

Delete the authenticated user's account.

http
DELETE /api/me

Profile Picture

Upload Profile Picture

Upload a profile picture for the current user.

http
POST /api/user/profile-picture
Content-Type: multipart/form-data

Form Data:

FieldTypeDescription
filefileImage file (jpg, png, gif, webp)

Response:

json
{
  "profilePicture": "/api/user/profile-picture/abc123.jpg"
}

Get Profile Picture

Get a user's profile picture.

http
GET /api/user/profile-picture/{filename}

Response: Image file with appropriate content-type header.

User Roles

RoleDescription
ROLE_USERDefault role, can manage own products and claims
ROLE_SUPPLIERCan be assigned to claims and respond to customers
ROLE_ADMINFull access to all users, products, and claims

Role Hierarchy

  • ROLE_ADMIN inherits all permissions from ROLE_SUPPLIER and ROLE_USER
  • ROLE_SUPPLIER inherits permissions from ROLE_USER

MyWarranties - Warranty Management System