Quick Start
Get up and running with the Moon ERP API in three steps.
Prerequisites
- A running Moon ERP instance (e.g.,
https://moon-erp.test) - A REST client (curl, Postman, or your Flutter app)
Step 1: Register a Company & User
Create a new company account by sending a POST request to /api/auth/register.
bash
curl -X POST https://moon-erp.test/api/auth/register \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"company_id": 1,
"name": "Ahmed Hamdi",
"name_ar": "أحمد حمدي",
"email": "ahmed@example.com",
"password": "secret1234",
"password_confirmation": "secret1234",
"phone": "+201234567890"
}'dart
import 'dart:convert';
import 'package:http/http.dart' as http;
final response = await http.post(
Uri.parse('https://moon-erp.test/api/auth/register'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: jsonEncode({
'company_id': 1,
'name': 'Ahmed Hamdi',
'name_ar': 'أحمد حمدي',
'email': 'ahmed@example.com',
'password': 'secret1234',
'password_confirmation': 'secret1234',
'phone': '+201234567890',
}),
);
final data = jsonDecode(response.body);
final token = data['token'];Response 201 Created
json
{
"data": {
"id": 1,
"name": "Ahmed Hamdi",
"name_en": "Ahmed Hamdi",
"name_ar": "أحمد حمدي",
"email": "ahmed@example.com",
"phone": "+201234567890",
"locale": "ar",
"is_active": true,
"roles": ["employee"],
"permissions": [],
"created_at": "2026-02-16T10:30:00.000000Z",
"updated_at": "2026-02-16T10:30:00.000000Z"
},
"token": "1|abc123def456..."
}Save the token value -- you will need it for all subsequent API calls.
Step 2: Login (Returning Users)
If you already have an account, authenticate via POST /api/auth/login.
bash
curl -X POST https://moon-erp.test/api/auth/login \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"email": "ahmed@example.com",
"password": "secret1234"
}'dart
final response = await http.post(
Uri.parse('https://moon-erp.test/api/auth/login'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: jsonEncode({
'email': 'ahmed@example.com',
'password': 'secret1234',
}),
);
final data = jsonDecode(response.body);
final token = data['token'];Response 200 OK
json
{
"data": {
"id": 1,
"name": "Ahmed Hamdi",
"name_en": "Ahmed Hamdi",
"name_ar": "أحمد حمدي",
"email": "ahmed@example.com",
"phone": "+201234567890",
"locale": "ar",
"is_active": true,
"company": { "id": 1, "name": "Moon Corp" },
"branch": null,
"roles": ["employee"],
"permissions": [],
"created_at": "2026-02-16T10:30:00.000000Z",
"updated_at": "2026-02-16T10:30:00.000000Z"
},
"token": "2|xyz789..."
}Step 3: Make Your First API Call
Use the token from step 1 or 2 to fetch the dashboard summary.
bash
curl -X GET https://moon-erp.test/api/core/dashboard \
-H "Accept: application/json" \
-H "Authorization: Bearer 2|xyz789..."dart
final response = await http.get(
Uri.parse('https://moon-erp.test/api/core/dashboard'),
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer $token',
},
);
final dashboard = jsonDecode(response.body);Response 200 OK
json
{
"data": {
"company": { "id": 1, "name": "Moon Corp" },
"counts": {
"users": 5,
"branches": 2,
"accounts": 48,
"journal_entries": 120
}
}
}Next Steps
- Read the Authentication guide for details on token management, logout, and profile updates.
- Review API Conventions to understand pagination, localization, and date formats.
- See Error Handling for how the API reports errors.