REST API

CartUser exposes 72+ REST endpoints under /api. Same API powers the user app, seller app, delivery app, and your custom integrations. Auth via Laravel Sanctum bearer tokens.

In-app reference
Full endpoint list with parameters + example responses is built into admin panel: Admin โ†’ API Documentation. This page is a high-level overview.

Base URL

https://yourdomain.com/api

Authentication

Public endpoints

These work without token:

Protected endpoints (token required)

Include in header:

Authorization: Bearer {token}
Accept: application/json

Getting a token

POST /api/login
Content-Type: application/json

{
    "username": "[email protected]",
    "password": "123123"
}

Response:

{
    "success": true,
    "data": {
        "access_token": "1|aBcD1234...",
        "user": { ... }
    }
}

Endpoint groups

Auth

Config

Products

Cart

Wishlist

Checkout

Orders

Profile

Addresses

Wallet & transactions

Reward points

Chat

Support tickets

Shop / sellers

Error responses

// Validation error (422)
{
    "success": false,
    "data": {
        "errors": ["Email field is required"]
    },
    "message": "Validation failed"
}

// Auth error (401)
{
    "success": false,
    "message": "Unauthenticated"
}

// Not found (404)
{
    "success": false,
    "message": "Resource not found"
}

// Server error (500)
{
    "success": false,
    "message": "Server error message"
}

Standard success format

{
    "success": true,
    "data": {
        "products": [ ... ],
        "pagination": {
            "current_page": 1,
            "total": 50
        }
    },
    "message": "Success"
}

Pagination

List endpoints use ?page=N query param. Page size set in admin (default 10). Response includes pagination meta.

Rate limits

Default: 60 requests/minute per IP. Adjust in kode/app/Providers/RouteServiceProvider.php.

CORS

CORS is enabled for all origins by default. Restrict in kode/config/cors.php:

'allowed_origins' => ['https://yourapp.com'],

Testing with curl

# Login
curl -X POST https://yourdomain.com/api/login \
  -H "Content-Type: application/json" \
  -d '{"username":"[email protected]","password":"123123"}'

# Use token
curl https://yourdomain.com/api/profile \
  -H "Authorization: Bearer 1|aBcD1234..." \
  -H "Accept: application/json"

Postman collection

Generate a Postman collection from your installation:

cd /home/user/public_html/kode
php artisan export:postman

Output: storage/app/cartuser.postman_collection.json. Import into Postman.