Skip to main content
GET
/
api
/
user
curl --request GET \
  --url http://localhost:8000/api/user \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Accept: application/json'
{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "email_verified_at": "2024-03-04T10:30:00.000000Z",
  "created_at": "2024-03-01T08:15:00.000000Z",
  "updated_at": "2024-03-04T10:30:00.000000Z"
}

Overview

Returns the authenticated user’s profile information. This endpoint requires a valid Sanctum authentication token.

Authentication

This endpoint uses Laravel Sanctum for authentication. You must include a valid Bearer token in the Authorization header.
Authorization
string
required
Bearer token obtained from login or registration

Response

id
integer
required
Unique identifier for the user
name
string
required
User’s full name
email
string
required
User’s email address
email_verified_at
string | null
Timestamp when the email was verified (ISO 8601 format). Null if email is not verified.
created_at
string
required
Timestamp when the user account was created (ISO 8601 format)
updated_at
string
required
Timestamp when the user account was last updated (ISO 8601 format)
curl --request GET \
  --url http://localhost:8000/api/user \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Accept: application/json'
{
  "id": 1,
  "name": "John Doe",
  "email": "[email protected]",
  "email_verified_at": "2024-03-04T10:30:00.000000Z",
  "created_at": "2024-03-01T08:15:00.000000Z",
  "updated_at": "2024-03-04T10:30:00.000000Z"
}

Error responses

401 Unauthorized
Returned when the request does not include a valid authentication token or the token has expired.

Implementation details

The endpoint is protected by the auth:sanctum middleware as defined in /home/daytona/workspace/source/Backend/routes/api.php:6. The response excludes sensitive fields defined in the User model’s $hidden property:
  • password - User’s hashed password
  • remember_token - Laravel’s remember token

Next.js integration

When using the Next.js frontend, this endpoint is typically called after successful authentication to populate the user context:
const { data: user } = useSWR('/api/user', fetcher);
See the Frontend Authentication Guide for more details on implementing user profile fetching in your Next.js application.

Build docs developers (and LLMs) love