Skip to content

Tutorial: Edit an Existing User

This tutorial shows how to edit an existing user using the public API wrapper in People Cloud. The public endpoint forwards the request to the internal user update logic and will preserve platform behaviour such as company resolution and validations.


Step 1: Make a POST Request to edit a User

Send a POST request to the following public API endpoint (replace {id} with the user id):

POST /api/v1/user/{id}/edit

Authorization

This endpoint requires authentication. Use a Bearer token from an authenticated user.

Request Headers

Authorization: Bearer <your_token_here>
Accept: application/json
Content-Type: application/json

Request Body Structure

Common fields accepted by the user edit endpoint. Any omitted fields are typically left unchanged by the public wrapper.

  • name: Full name of the user.
  • email: User email address (must be unique when changed).
  • company: Object describing company. Provide { "name": "Company Oy" } to resolve/create a company, or { "id": 123 } to reference an existing company.
  • phone: Optional phone number.
  • type: User type (e.g. client, vendor, admin).
  • password: New password (optional). If provided, confirm_password must match.
  • confirm_password: Must match password when changing password.
  • is_verified: Optional boolean to set verification flag.

Example JSON

{
  "name": "Chaw Chaw",
  "email": "updated@example.com",
  "phone": "+358401234567",
  "company": { "name": "Updated Oy" },
  "type": "client",
  "password": "NewPass1234",
  "confirm_password": "NewPass1234"
}

Step 2: Edit the User (cURL example)

curl -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/user/15/edit" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "name": "Chaw Chaw",
    "email": "updated@example.com",
    "phone": "+358401234567",
    "company": { "name": "Updated Oy" },
    "type": "client",
    "password": "NewPass1234",
    "confirm_password": "NewPass1234"
  }'

Step 3: Evaluate response

On success the API returns a concise JSON message such as {"message":"Successfully edit user information"}.

Status Meaning Description
200 OK User updated successfully
401 Unauthorized The API token is invalid or missing
403 Conflict Email already exists
404 Not Found User id not found
422 Validation error One or more fields failed validation (e.g. password mismatch)
500 Server error Unexpected server-side error

Notes & Tips

  • When changing email, the public wrapper enforces uniqueness and returns 403 if the new email is already in use.
  • To update the company reference, provide a company object. Using company.name will attempt to resolve or create the company; using company.id will link an existing company.
  • If you supply password, also include confirm_password and ensure they match; otherwise the API returns 422.
  • The endpoint is protected by auth:api and isVerified middleware.