Overview
Laravel Breeze API provides RESTful endpoints for authentication, user management, and email verification. All routes follow Laravel’s standard naming conventions.Route Files
Routes are defined in two main files:routes/api.php- Protected API routesroutes/auth.php- Authentication routes
Authentication Routes
All authentication routes are defined inroutes/auth.php.
Registration
routes/auth.php
POST /register
Middleware: guest (unauthenticated users only)
Request Body:
204 No Content
Description: Creates a new user account and automatically logs them in.
Login
routes/auth.php
POST /login
Middleware: guest
Request Body:
204 No Content
Rate Limiting: 5 attempts per minute
Description: Authenticates a user and establishes a session.
Logout
routes/auth.php
POST /logout
Middleware: auth (authenticated users only)
Response: 204 No Content
Description: Invalidates the user’s session and logs them out.
Forgot Password
routes/auth.php
POST /forgot-password
Middleware: guest
Request Body:
Reset Password
routes/auth.php
POST /reset-password
Middleware: guest
Request Body:
Email Verification
routes/auth.php
GET /verify-email/{id}/{hash}
Middleware:
auth- User must be authenticatedsigned- URL must be signedthrottle:6,1- 6 requests per minute
{FRONTEND_URL}/dashboard?verified=1
Description: Verifies the user’s email address when they click the link in their verification email.
Resend Verification Email
routes/auth.php
POST /email/verification-notification
Middleware:
auth- User must be authenticatedthrottle:6,1- 6 requests per minute
Protected API Routes
Protected routes require authentication via Laravel Sanctum.Get Authenticated User
routes/api.php
GET /api/user
Middleware: auth:sanctum
Response:
Making Authenticated Requests
CSRF Protection
Before making authenticated requests, fetch a CSRF token:Example with Axios
Route Naming
All routes use Laravel’s named route convention:| Endpoint | Route Name |
|---|---|
POST /register | register |
POST /login | login |
POST /logout | logout |
POST /forgot-password | password.email |
POST /reset-password | password.store |
GET /verify-email/{id}/{hash} | verification.verify |
POST /email/verification-notification | verification.send |
Middleware Groups
Guest Middleware
Prevents authenticated users from accessing routes:/register/login/forgot-password/reset-password
Auth Middleware
Requires authentication:/logout/api/user/email/verification-notification
Throttle Middleware
Rate limiting configuration:- Login attempts: 5 per minute (enforced in LoginRequest)
- Email verification: 6 per minute
- Verification resend: 6 per minute
Error Responses
401 Unauthorized
422 Validation Error
429 Too Many Requests
Next Steps
Controllers
Learn about controller implementation
Testing
Test your API endpoints