Sapientia ERP

Developers

A plain JSON API over HTTPS, two ways in. Your own systems: create a key under Settings → API keys, choose its scopes and optionally bind it to one company; keys look like sk_live_erp_… (or sk_test_erp_… for test keys, which are accepted but flagged). Apps for other companies: register in the developer console and use OAuth 2.0; your app is listed in the marketplace once approved.

Authentication

curl https://erp.sapientiainformationsolutions.com/api/v1/companies \
  -H "Authorization: Bearer sk_live_erp_…"      # or an app's access token: sat_…

Every response is { "data": … } or { "error": { "code", "message" } }. Codes: unauthenticated (401), forbidden (403, missing scope or wrong company), rate_limited (429, apps only: per connected company, 120 calls a minute unless agreed otherwise), not_found, invalid_request (400/422), query_failed (500). Dates are YYYY-MM-DD; timestamps ISO 8601; money is PHP with two decimals.

Scopes

Idempotency

Daily summaries are keyed by company + app + date; channel orders by channel + external_id; tickets by channel + external_ref; journals accept an idempotency_key. Re-sending returns the original with replayed: true and HTTP 200.

Companies and accounts

GET/api/v1/companiesscope accounts:read

Companies the key can post to.

{ "data": [{ "id", "name", "tin", "base_currency" }] }
GET/api/v1/accountsscope accounts:read

Chart of accounts of a company.

Query: company (required unless the key is bound to one)

Journals

GET/api/v1/journalsscope journals:read

List journals.

Query: company · status=draft|submitted|posted|cancelled · from, to (posting_date) · limit (≤500)

POST/api/v1/journalsscope journals:write

Create a journal (draft, or posted when post=true and the key may post). If the company tracks stock (Inventory → Stock tracking), a line on a stock-tracked purchase account posts to its inventory account; send "skip_stock_map": true on a line (or "stock_map": false on the journal) to keep the account as sent.

{ "company": "<uuid>", "posting_date": "2026-10-12", "memo": "…", "reference": "…", "idempotency_key": "…", "post": true, "lines": [{ "account": "1010", "debit": 1000 }, { "account": "4010", "credit": 1000, "memo": "…" }] }
GET/api/v1/journals/{id}scope journals:read

One journal with lines.

POST/api/v1/journals/{id}/transitionscope journals:write

Move a journal through its workflow.

{ "action": "submit" | "post" | "reverse", "note": "…" }

App feeds (postings)

POST/api/v1/postings/daily-summaryscope postings:write

One call per business day: movements by bucket become one posted journal through the company's mapping; balances are kept for the sub-ledger report. Same day twice returns the same journal.

{ "company": "<uuid>", "app": "shop_daily", "date": "2026-10-11", "movements": { "sales": 12500, "fees": 1250, "payouts": 9800 }, "balances": { "escrow_held": 431, "wallet_balances": 3500 } }
POST/api/v1/postings/shift-closescope postings:write

POS shift close: sales by payment method, discounts, tips, cash drawer variance, pay ins/outs, partner goods, (optional) cost of the shop's own goods sold and customer accounts (pay later charges and payments), posted as one journal. cogs = { business key: amount at cost } with the same keys as sales; each posts Dr cost of sales / Cr inventory per the mapping's cogs block ("*" = fallback); zero or absent posts nothing, a negative amount reverses. Partner goods are not included in cogs. Customer accounts (pay later): on_account = [{ customer_id, customer_name, amount, receipt_no? }] are sales charged to a customer (at gross after discounts; already in sales, NOT in tenders), each posting Dr the mapping's on_account.account (receivable) with the customer; account_payments = [{ customer_id, customer_name, amount, method }] are customers paying their account (NOT in sales nor tenders), each posting Dr the tender's account (same tenders mapping, method = tender key) / Cr the receivable with the customer. The customer is matched by the POS customer id (party custom.pos_customer_id), else by name, else created as a customer; their charges and payments show on the customer's page, statement and the AR aging (payments pay the oldest charge first). Amounts must be > 0 and ids, names (and method) are required (400 invalid_request).

{ "company": "<uuid>", "idempotency_key": "kk-2026-10-16-pm", "business_date": "2026-10-16", "sales": { "cafe": 2095, "beantol": 850 }, "tenders": { "cash": 1652, "gcash": 2019 }, "partner_sales": [{ "key": "keto-kakanin", "name": "Keto Kakanin", "gross": 726 }], "cogs": { "cafe": 812.40, "beantol": 1540.00 }, "on_account": [{ "customer_id": "<pos customer uuid>", "customer_name": "YDG", "amount": 3200, "receipt_no": "000412" }], "account_payments": [{ "customer_id": "<pos customer uuid>", "customer_name": "Cakes by Grace", "amount": 1500, "method": "unionbank" }] }
{ "data": { "id", "number", "status": "posted" }, "summary": { "gross_sales", "tenders", "over_short", "cost_of_sales", "on_account", "account_payments", … }, "replayed": false }  (422 mapping_incomplete when cogs is sent but the mapping has no cogs rule for a key and no "*", or on_account / account_payments are sent and the mapping has no on_account: { "account": "1100" })

Orders and catalogue (e-commerce)

POST/api/v1/ordersscope orders:write

Push a shop order to a sales channel. Deduped on channel + external_id (replayed: true). Becomes customer, sales order, invoice and receipt per the channel's settings.

{ "company": "<uuid>", "channel": "shopify", "order": { "external_id": "1001", "number": "#1001", "ordered_at": "2026-10-12T10:00:00+08:00", "customer": { "name": "Ana Cruz", "email": "ana@example.com", "phone": "0917…" }, "ship_to": "12 Mango Ave, Cebu City", "payment_method": "gcash", "paid": true, "discount": 50, "shipping_fee": 80, "platform_fee": 0, "lines": [{ "sku": "BEANS-250", "name": "House blend 250g", "qty": 2, "unit_price": 450 }] } }
{ "data": { "channel_order_id", "status": "invoiced", "sales_order_id", "invoice_id", "payment_id", "total", "warning" }, "replayed": false }  (422 with status "failed" and error when a SKU is unknown)
GET/api/v1/ordersscope orders:read

List channel orders.

Query: company · channel (key) · status · from · limit

GET/api/v1/orders/{id}scope orders:read

One channel order with its raw payload and links.

POST/api/v1/orders/{id}/shipscope orders:write

Mark shipped; creates the shipment (and the delivery when stock has not left yet).

{ "tracking_no": "JT123", "carrier": "J&T Express" }
GET/api/v1/itemsscope items:read

Catalogue for a storefront: sku, barcode, name, price (party price list when party is given), stock on hand.

Query: company · party (optional customer id for its price list) · updated_since (ISO timestamp)

Sales and purchases

GET/api/v1/invoicesscope invoices:read

Sales invoices with totals, paid and balance.

Query: company · status=draft|posted|paid|cancelled · from, to (invoice_date) · party · updated_since · limit (≤500)

GET/api/v1/billsscope bills:read

Supplier bills with totals, paid and balance.

Query: company · status · from, to (bill_date) · party · updated_since · limit (≤500)

GET/api/v1/paymentsscope payments:read

Receipts (kind=receipt) and payments (kind=payment).

Query: company · status · from, to (payment_date) · party · updated_since · limit (≤500)

GET/api/v1/partiesscope parties:read

Customers and suppliers this company deals with.

Query: company · kind=customer|supplier · q (name contains) · updated_since · limit (≤1000)

POST/api/v1/partiesscope parties:write

Add a customer or supplier. The same TIN (or name, without a TIN) among the company's parties returns the existing one with replayed: true.

{ "company": "<uuid>", "kind": "customer", "name": "Dela Cruz Trading", "tin": "123-456-789-000", "email": "…", "phone": "…", "terms_days": 30 }

Support

POST/api/v1/ticketsscope tickets:write

Open a helpdesk ticket from an app. Same external_ref returns the existing ticket.

{ "company": "<uuid>", "subject": "Order late", "body": "…", "priority": "high", "channel": "api", "external_ref": "order-77", "contact": { "name", "email", "phone" }, "category": "Delivery", "tags": ["delivery"] }

Reports

GET/api/v1/reports/trial-balancescope reports:read

Trial balance for a range.

Query: company · from · to

Webhooks

GET/api/v1/webhooksscope webhooks:manage

Your subscriptions.

POST/api/v1/webhooksscope webhooks:manage

Subscribe a URL to events. Deliveries are signed with HMAC-SHA256 of the body using the subscription secret (header X-Sapientia-Signature) and retried with back-off.

{ "url": "https://example.com/hook", "events": ["journal.posted", "order.received", "order.shipped", "order.cancelled"], "description": "…" }
DELETE/api/v1/webhooks/{id}scope webhooks:manage

Remove a subscription.

Webhook events

journal.posted (journals:read), order.received (orders:read), order.shipped (orders:read), order.cancelled (orders:read). Each delivery is a POST with JSON { "id", "event", "created_at", "data" } and headers X-ERP-Event, X-ERP-Timestamp and X-ERP-Signature: v1=<hex>, where hex = HMAC-SHA256(secret, timestamp + "." + body). Reject timestamps older than five minutes. Failed deliveries retry after 1, 5, 15, 60, 240 and 720 minutes. An app's subscriptions only carry events of the company it is connected to, and only events whose read scope it holds.

Apps for other companies: OAuth 2.0

Authorization code flow with PKCE (S256 only) and a client secret. A company owner or admin approves your app for one company on a Sapientia consent screen that lists your scopes in plain words; they can disconnect it any time, which revokes every token at once. Every API call an app makes is written to the company's app activity log.

Quick start

  1. Sign in (any Sapientia account, or start a trial) and open the developer console. Registering creates your developer organisation and a sandbox tenant with sample customers, items, invoices and bills.
  2. Register an app: name, redirect URIs (matched exactly; https, or http on localhost), scopes, optional webhook URL and events, logo and pricing. Copy the client secret: it is shown once and stored hashed.
  3. Switch to your sandbox from the company menu and run the flow below. Until Sapientia approves the app, only your sandbox can connect it.
  4. Submit for review. Once approved it is listed in the marketplace and any company can install it. Asking for more scopes later sends the app back to review; companies keep the approved scopes and re-consent to new ones.

1. Send the user to the consent screen

code_verifier  = base64url(32 random bytes)            # keep it server-side
code_challenge = base64url(sha256(code_verifier))

GET https://erp.sapientiainformationsolutions.com/oauth/authorize
  ?response_type=code
  &client_id=app_…
  &redirect_uri=https%3A%2F%2Fyourapp.example%2Fcallback
  &scope=invoices:read%20parties:read
  &state=<random, check it on return>
  &code_challenge=<code_challenge>
  &code_challenge_method=S256

The user signs in if needed, picks the company and approves. You get ?code=sac_…&state=… on your redirect URI, or ?error=access_denied. Codes expire after two minutes and work once; using one twice revokes the tokens it issued.

2. Exchange the code

curl https://erp.sapientiainformationsolutions.com/oauth/token \
  -u "app_…:scs_…" \
  -d grant_type=authorization_code \
  -d code=sac_… \
  -d redirect_uri=https://yourapp.example/callback \
  -d code_verifier=<code_verifier>

{ "access_token": "sat_…", "token_type": "Bearer", "expires_in": 3600,
  "refresh_token": "srt_…", "scope": "invoices:read parties:read",
  "company_id": "<uuid>", "installation_id": "<uuid>" }

3. Call the API

curl "https://erp.sapientiainformationsolutions.com/api/v1/invoices?status=posted" -H "Authorization: Bearer sat_…"

An access token is bound to the one company it was granted for (the company parameter may be left out). Each call needs its endpoint's scope; you get 403 forbidden otherwise.

4. Refresh, and revoke

curl https://erp.sapientiainformationsolutions.com/oauth/token -u "app_…:scs_…" -d grant_type=refresh_token -d refresh_token=srt_…
curl https://erp.sapientiainformationsolutions.com/oauth/revoke -u "app_…:scs_…" -d token=srt_…

Refresh tokens last 60 days and rotate: every refresh returns a new pair and the old refresh token stops working. Presenting a used refresh token again is treated as theft and revokes the whole chain, so store the newest one atomically. A refresh may pass a narrower scope, never a wider one. Revoking a refresh token revokes its chain. Client credentials may also be sent in the body as client_id and client_secret. Errors follow RFC 6749: { "error": "invalid_grant", "error_description": "…" }.

Scopes in plain words

Webhooks for apps

Set a webhook URL and events on the app: each connected company gets a subscription signed with your app's webhook secret (developer console → Show webhook signing secret). Apps can also manage extra subscriptions with webhooks:manage; they see and delete only their own.

Pricing and review

Apps are free, included in the plan, or paid per connected company per month. Paid apps are billed on the company's Sapientia invoice; your revenue share is recorded per invoice and settled with Sapientia separately. Review checks the listing, the scopes against what the app does, the privacy policy and the support link.