Skip to main content

Overview

This endpoint retrieves the profile information of the currently authenticated user. It requires a valid JWT token in the Authorization header.
This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Endpoint

GET /user/profile

Authentication

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

Request

No request body or query parameters are required.

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 user’s full name
email
string
required
The user’s email address
phone
string
The user’s phone number (can be null)

Example Request

curl -X GET https://api.servitech.com/en/user/profile \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
  -H "Accept-Language: en"

Example Response

200 - Success
{
  "success": true,
  "message": "User information retrieved successfully",
  "data": {
    "user": {
      "id": 1,
      "role": "user",
      "name": "John Doe",
      "email": "[email protected]",
      "phone": "+1234567890"
    }
  }
}
401 - Unauthorized
{
  "success": false,
  "message": "Unauthenticated",
  "data": null
}
500 - Server Error
{
  "success": false,
  "message": "An error occurred while retrieving user information",
  "data": null
}

Implementation Details

This endpoint is implemented in UserController.php:29 and uses the following:
  • Controller Method: UserController::profile()
  • Resource Transformation: UserResource
  • Authentication Guard: auth('api')
  • Route Name: user.profile

Build docs developers (and LLMs) love