Add the following code in the routes/api.php file : PHP Copy the telegram philippines girl code // routes/api.php Route::post('/me', [AuthController::class, 'me']); Then add this code to the AuthController: PHP Copy the code // app/Http/Controllers/AuthController.php public function me(Request $request) { return $request->user(); } This code is pretty simple. We just return the currently authenticated user account. Restricting endpoint to authenticated user accounts only As you may have guessed, the endpoint /me should be accessible only to authenticated user accounts. Luckily for us, this is possible thanks to Authenticated Protection sanctum. So we will update the path as follows: PHP Copy the code // routes/api.

php Route::post('/me', [AuthController::class, 'me'])->middleware('auth:sanctum'); This ensures that requests sent to this endpoint contain a valid API token in their header. Before testing the API, let's uncomment the line below in app/Providers/RouteServiceProvider.php : PHP Copy the code // app/Providers/RouteServiceProvider.php protected $namespace = 'App\\Http\\Controllers'; API Testing It's time to test what we've built. I'll show you instructions using Insomnia , but you're free to use any HTTP client you feel comfortable with. First, make sure the application is running: Bash Copy the code php artisan serve The application should be running on and we can access the API on