Skip to content

Users API

User management endpoints for creating, reading, updating, and deleting users.

Status

These endpoints are planned and not yet implemented.

Endpoints

List Users

Returns a paginated list of users. Requires authentication.

http
GET /api/users

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
pageSizeinteger10Items per page (max 100)
searchstring-Search by name or email

Success Response 200 OK

json
{
  "data": [
    {
      "id": 1,
      "email": "user@example.com",
      "firstName": "John",
      "lastName": "Doe",
      "createdAt": "2026-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "total": 1,
    "page": 1,
    "pageSize": 10
  }
}

Error Response 401 Unauthorized

User is not authenticated.


Get User

Returns a single user by their ID.

http
GET /api/users/{id}

Path Parameters

ParameterTypeDescription
idguidUser ID

Success Response 200 OK

json
{
  "data": {
    "id": 1,
    "email": "user@example.com",
    "firstName": "John",
    "lastName": "Doe",
    "createdAt": "2026-01-01T00:00:00Z"
  },
  "error": null,
  "meta": {
    "timestamp": "2026-01-12T10:00:00Z",
    "requestId": "abc-123"
  }
}

Error Response 404 Not Found

User does not exist.


Create User

Creates a new user account.

http
POST /api/users

Request Body

json
{
  "email": "newuser@example.com",
  "password": "securePassword123",
  "firstName": "John",
  "lastName": "Doe"
}

Validation Rules

FieldRules
emailRequired, valid email format, unique
passwordRequired, min 8 characters
firstNameRequired, max 50 characters
lastNameRequired, max 50 characters

Success Response 201 Created

json
{
  "data": {
    "id": 2,
    "email": "newuser@example.com"
  },
  "error": null,
  "meta": {
    "timestamp": "2026-01-12T10:00:00Z",
    "requestId": "def-456"
  }
}

Error Response 400 Bad Request

json
{
  "data": null,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input",
    "details": [
      { "field": "email", "message": "Email already exists" }
    ]
  },
  "meta": {
    "timestamp": "2026-01-12T10:00:00Z",
    "requestId": "ghi-789"
  }
}

Update User

Updates an existing user.

http
PUT /api/users/{id}

Path Parameters

ParameterTypeDescription
idguidUser ID

Request Body

json
{
  "firstName": "Jane",
  "lastName": "Smith"
}

Success Response 200 OK

json
{
  "data": {
    "id": 1,
    "email": "user@example.com",
    "firstName": "Jane",
    "lastName": "Smith"
  },
  "error": null,
  "meta": {
    "timestamp": "2026-01-12T10:00:00Z",
    "requestId": "jkl-012"
  }
}

Error Response 404 Not Found

User does not exist.


Delete User

Deletes a user account. Requires admin privileges.

http
DELETE /api/users/{id}

Path Parameters

ParameterTypeDescription
idguidUser ID

Success Response 204 No Content

No response body.

Error Responses

StatusDescription
403 ForbiddenAdmin access required
404 Not FoundUser does not exist

Frontend Integration

typescript
// features/users/hooks/useUsers.ts
export function useUsers(params?: { page?: number; search?: string }) {
  return useQuery({
    queryKey: ['users', params],
    queryFn: () => usersApi.getAll(params),
  });
}

export function useCreateUser() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: (data: CreateUserRequest) => usersApi.create(data),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['users'] });
    },
  });
}

Built with VitePress | v1.1.0