ESC
Advanced

API Reference

Overview

FreshStay provides a RESTful API secured with Laravel Sanctum for building mobile apps or integrating with external services.

Authentication

All API requests require a Bearer token. Obtain a token via the login endpoint:

BASH
POST /api/v1/auth/login
Content-Type: application/json

{
    "email": "user@example.com",
    "password": "your_password"
}

Response:

JSON
{
    "token": "1|abc123...",
    "user": {
        "id": 1,
        "name": "John Doe",
        "email": "user@example.com"
    }
}

Use the token in subsequent requests:

BASH
Authorization: Bearer 1|abc123...

Endpoints

Properties

Method Endpoint Description
GET /api/v1/properties List properties with filters
GET /api/v1/properties/{id} Get property details
POST /api/v1/properties Create a new property
PUT /api/v1/properties/{id} Update a property
DELETE /api/v1/properties/{id} Delete a property

Bookings

Method Endpoint Description
GET /api/v1/bookings List user's bookings
POST /api/v1/bookings Create a new booking
GET /api/v1/bookings/{id} Get booking details
PUT /api/v1/bookings/{id}/cancel Cancel a booking

Users

Method Endpoint Description
GET /api/v1/user Get current user
PUT /api/v1/user Update current user
POST /api/v1/user/avatar Upload avatar
**Note:** Rate limiting is set to 60 requests per minute per user. Contact support if you need a higher limit.

Error Handling

The API returns standard HTTP status codes:

Code Description
200 Success
201 Created
401 Unauthorized
403 Forbidden
404 Not Found
422 Validation Error
429 Too Many Requests
500 Server Error
**Tip:** All validation errors return a `422` status with a JSON body containing field-specific error messages.

Was this page helpful?