@extends('layouts.app') @section('title', 'API Documentation') @section('content')
@include('admin.partials.sidebar')
@include('admin.partials.topbar')

API Documentation

REST API untuk integrasi dengan sistem eksternal

API Overview

Base URL: {{ url('/api') }}

Format: JSON

Authentication: Bearer Token (Laravel Sanctum)

Response Format

{
    "success": true,
    "data": { ... },
    "message": "Optional message"
}

Error Response

{
    "success": false,
    "message": "Error description",
    "errors": { "field": ["error message"] }
}

HTTP Status Codes

200Success
201Created
401Unauthorized
422Validation Error
500Server Error

Authentication

POST /api/customer/login

Login pelanggan untuk mendapatkan access token

Request Body:

{
    "username": "pppoe_username atau phone atau email",
    "password": "password"
}

Response:

{
    "success": true,
    "token": "1|abc123...",
    "customer": { "id": 1, "name": "John Doe", ... }
}
POST /api/admin/login

Login admin untuk mendapatkan access token

{
    "email": "admin@example.com",
    "password": "password"
}

Menggunakan Token

Sertakan token di header untuk endpoint yang memerlukan autentikasi:

Authorization: Bearer YOUR_TOKEN_HERE

Customer API

GET /api/customer/profile Auth Required

Mendapatkan profil pelanggan yang sedang login

PUT /api/customer/profile Auth Required

Update profil pelanggan (phone, email, password)

GET /api/customer/invoices Auth Required

Daftar invoice pelanggan. Query: ?status=paid|unpaid&per_page=10

GET /api/customer/invoices/{id} Auth Required

Detail invoice tertentu

GET /api/customer/tickets Auth Required

Daftar tiket support pelanggan

POST /api/customer/tickets Auth Required

Buat tiket support baru

{
    "subject": "Koneksi lambat",
    "category": "technical", // billing, technical, general, complaint
    "priority": "medium", // low, medium, high
    "message": "Deskripsi masalah..."
}

Admin API

GET /api/admin/dashboard

Statistik dashboard (total customers, revenue, invoices)

GET /api/admin/customers

Daftar pelanggan. Query: ?status=active&search=nama&per_page=15

POST /api/admin/customers

Buat pelanggan baru

PUT /api/admin/customers/{id}

Update data pelanggan

GET /api/admin/invoices

Daftar invoice. Query: ?status=unpaid&customer_id=1

POST /api/admin/invoices/{id}/pay

Tandai invoice sebagai lunas

Webhooks

POST /api/webhooks/midtrans

Webhook untuk notifikasi pembayaran Midtrans

POST /api/webhooks/xendit

Webhook untuk notifikasi pembayaran Xendit

Health Check

GET /api/health

Cek status API server

@endsection