Skip to main content

Overview

This endpoint allows authenticated users to update their basic profile information including name and phone number. Email cannot be updated through this endpoint.
This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Endpoint

PUT /user/profile

Authentication

This endpoint requires authentication using a JWT Bearer token.
Authorization: Bearer {token}

Request Body

name
string
required
The user’s full name
  • Minimum length: 2 characters
  • Validation: Required, must be a string
phone
string
The user’s phone number
  • Maximum length: 20 characters
  • Validation: Optional, nullable, must be a string if provided

Response

success
boolean
required
Indicates whether the request was successful
message
string
required
A message describing the result (localized based on Accept-Language header)
data
object
required
user
object
required
id
integer
required
The unique identifier for the user
role
string
required
The user’s role (e.g., “admin”, “user”)
name
string
required
The updated user’s full name
email
string
required
The user’s email address (unchanged)
phone
string
The updated user’s phone number (can be null)

Example Request

curl -X PUT https://api.servitech.com/en/user/profile \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
  -H "Accept-Language: en" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Smith",
    "phone": "+1234567890"
  }'

Example Response

200 - Success
{
  "success": true,
  "message": "User information updated successfully",
  "data": {
    "user": {
      "id": 1,
      "role": "user",
      "name": "John Smith",
      "email": "[email protected]",
      "phone": "+1234567890"
    }
  }
}
401 - Unauthorized
{
  "success": false,
  "message": "Unauthenticated",
  "data": null
}
422 - Validation Error
{
  "success": false,
  "message": "The given data was invalid",
  "data": {
    "errors": {
      "name": [
        "The name field is required."
      ],
      "phone": [
        "The phone must not be greater than 20 characters."
      ]
    }
  }
}
500 - Server Error
{
  "success": false,
  "message": "An error occurred while updating user information",
  "data": null
}

Validation Rules

The following validation rules are applied to the request:
FieldRulesDescription
namerequired, string, min:2User’s full name (minimum 2 characters)
phonenullable, string, max:20User’s phone number (optional, max 20 characters)
The email field cannot be updated through this endpoint. To change the email address, the user must contact support.

Implementation Details

This endpoint is implemented in UserController.php:55 and uses the following:
  • Controller Method: UserController::updateBasicInformation()
  • Request Validation: UpdateUserRequest (defined in app/Http/Requests/User/UpdateUserRequest.php:24)
  • Resource Transformation: UserResource
  • Authentication Guard: auth('api')
  • Route Name: user.profile.update
  • Mass Assignable Fields: name, phone (defined in User.php:25)

Build docs developers (and LLMs) love