Skip to main content

Update User

Description

Update an existing user.

Authentication

  • Required: Yes
  • Roles: Any authenticated user

Request

Headers

PUT /v1/customer/user/:id
Authorization: Bearer <token>
Content-Type: application/json

Path Parameters

ParameterTypeRequiredDescription
idnumberYesUser ID

Request Body

{
"firstName": "John",
"lastName": "Doe",
"username": "johndoe",
"password": "newpassword123",
"email": "john@example.com",
"phoneNumber": "0123456789",
"description": "Updated user description",
"roleId": 1
}

Field Descriptions

All fields are optional for updates:

firstName:

  • Type: string
  • Required: No
  • Description: User's first name (1-50 characters)

lastName:

  • Type: string
  • Required: No
  • Description: User's last name (1-50 characters)

username:

  • Type: string
  • Required: No
  • Description: Unique username (3-50 characters, alphanumeric and underscores only)

password:

  • Type: string
  • Required: No
  • Description: User's password (6-100 characters)

email:

  • Type: string
  • Required: No
  • Description: User's email address (valid email format)

phoneNumber:

  • Type: string
  • Required: No
  • Description: User's phone number (minimum 5 characters)

description:

  • Type: string
  • Required: No
  • Description: User description (maximum 500 characters)

roleId:

  • Type: number
  • Required: No
  • Description: User's role ID (positive integer)

Response

Success Response (200)

{
"data": {
"id": 1,
"firstName": "John",
"lastName": "Doe",
"username": "johndoe",
"email": "john@example.com",
"phoneNumber": "0123456789",
"description": "Updated user description",
"roleId": 1,
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
}

Error Responses

Error Codes

  • E010_BAD_RESOURCE_NOT_EXISTS: User not found
  • E003_BAD_USER_EXISTS: Username already exists
  • E006_BAD_DUPLICATE_PHONE: Phone number already exists
  • E007_BAD_DUPLICATE_EMAIL: Email address already exists

Example Usage

curl -X PUT https://api.stepx.io.vn/v1/customer/user/1 \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com"
}'
const response = await fetch('https://api.stepx.io.vn/v1/customer/user/1', {
method: 'PUT',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
firstName: 'John',
lastName: 'Doe',
email: 'john@example.com'
})
});

const data = await response.json();