In this guide, we’ll create a Users Management API using Laravel 12, JWT authentication, and User CRUD operations.
We’ll also test everything step by step with Postman.
Step 1: Install JWT Authentication
Run in your project root:
Publish the configuration:
Generate a secret key:
Step 2: Update User Model
Edit app/Models/User.php
:
Step 3: Authentication Controller
Create the controller:
Update app/Http/Controllers/Api/AuthController.php
:
Step 4: User CRUD Controller
Generate controller:
Edit app/Http/Controllers/Api/UserController.php
:
Step 5: Define API Routes
Edit routes/api.php
:
Step 6: Configure JWT Middleware
In app/Http/Kernel.php
, add:
Step 7: Test with Postman
👉 Base URL: http://127.0.0.1:8000/api
1. Register User
POST /auth/register
Body (JSON):
2. Login User
POST /auth/login
Body (JSON):
Response:
Copy the token
.
3. Get Profile
GET /auth/profile
Headers:
4. Logout
POST /auth/logout
Headers:
5. List Users
GET /users
Headers:
6. Create User
POST /users
Headers:
Body (JSON):
7. Show User
GET /users/2
Headers:
8. Update User
PUT /users/2
Headers:
Body (JSON):
9. Delete User
DELETE /users/2
Headers:
✅ Conclusion
You now have:
-
JWT Authentication (register, login, profile, logout)
-
Full User CRUD (list, create, show, update, delete)
-
Complete Postman examples with request/response JSON
🚀 This is production-ready and can be extended with:
-
Password reset 🔑
-
Email verification 📧
-
User activity logs 📊
-
API rate limiting ⚡
Want the full source code?
Download the complete Laravel 12 JWT API Authentication example on my GitHub repo here.
Happy Coding!