Skip to content

API Conventions

This page describes the patterns and conventions used consistently across all Moon ERP API endpoints.

Content Type

All requests and responses use JSON. Include these headers on every request:

Content-Type: application/json
Accept: application/json

URL Structure

All API endpoints follow this pattern:

/api/{module}/{resource}

Examples:

MethodURLDescription
GET/api/core/branchesList all branches
POST/api/core/branchesCreate a branch
GET/api/core/branches/5Get branch by ID
PUT/api/core/branches/5Update a branch
DELETE/api/core/branches/5Delete a branch
GET/api/accounting/accountsList accounts
POST/api/accounting/journal-entriesCreate a journal entry

ID Fields

All resources use integer auto-incrementing primary keys. IDs are always returned as integers in JSON responses.

Pagination

List endpoints return paginated results using Laravel's standard pagination format. Control pagination with query parameters:

ParameterDefaultDescription
page1Page number
per_page15Number of items per page

Example Request

GET /api/core/users?page=2&per_page=10

Paginated Response Structure

json
{
  "data": [
    { "id": 11, "name": "User 11", "email": "user11@example.com" },
    { "id": 12, "name": "User 12", "email": "user12@example.com" }
  ],
  "links": {
    "first": "https://moon-erp.test/api/core/users?page=1",
    "last": "https://moon-erp.test/api/core/users?page=5",
    "prev": "https://moon-erp.test/api/core/users?page=1",
    "next": "https://moon-erp.test/api/core/users?page=3"
  },
  "meta": {
    "current_page": 2,
    "from": 11,
    "last_page": 5,
    "per_page": 10,
    "to": 20,
    "total": 50
  }
}

Single-resource endpoints (GET /api/.../resource/{id}, POST, PUT) return the resource directly inside a data wrapper:

json
{
  "data": {
    "id": 1,
    "name": "Main Branch"
  }
}

Localization

Moon ERP supports Arabic and English. The API defaults to Arabic.

Set the Accept-Language header to control the language of localized fields:

Header ValueEffect
Accept-Language: arArabic names and messages (default)
Accept-Language: enEnglish names and messages

Localized models expose all variants:

json
{
  "data": {
    "id": 1,
    "name": "المقر الرئيسي",
    "name_en": "Headquarters",
    "name_ar": "المقر الرئيسي"
  }
}

The name field reflects the locale requested via the header. The name_en and name_ar fields are always present so the client can display both if needed.

Date and Time Format

All date and time fields use ISO 8601 format with UTC timezone:

2026-02-16T10:30:00.000000Z

When sending dates in request bodies, use the same ISO 8601 format or YYYY-MM-DD for date-only fields.

Monetary Fields

Moon ERP supports multiple currencies with varying decimal precision:

CurrencyCodeDecimalsExample
Kuwaiti DinarKWD31234.567
Egyptian PoundEGP21234.56

All monetary fields in the database use decimal(12, 3) to accommodate KWD's three decimal places. API responses return monetary values as numbers (not strings):

json
{
  "amount": 1234.567,
  "currency_code": "KWD"
}

Soft Deletes

All resources use soft deletes. When you send a DELETE request, the record is marked as deleted but remains in the database. Soft-deleted records are excluded from list endpoints by default.

A successful delete returns:

json
{
  "message": "Deleted"
}

Boolean Fields

Boolean fields use true/false in both requests and responses. Common boolean fields include:

FieldDescription
is_activeWhether the resource is active
is_defaultWhether this is the default option
is_postedWhether a journal entry is posted
allow_manualWhether manual journal entries are allowed

In request bodies, send booleans as JSON true/false (not 1/0 or "true"/"false"):

json
{
  "is_active": true,
  "is_default": false
}

Filtering and Sorting

Many list endpoints support query parameters for filtering and sorting. Check individual endpoint documentation for supported parameters. Common patterns include:

GET /api/accounting/accounts?type=asset&is_active=true
GET /api/core/users?search=ahmed

HTTP Methods Summary

MethodUsageTypical Status Code
GETRetrieve resource(s)200 OK
POSTCreate a new resource201 Created
PUTUpdate an existing resource200 OK
DELETESoft-delete a resource200 OK

Moon ERP API Documentation