Alpha (platform kernel). Suitable for demos and custom modules. Not for production or regulated workloads.
Core DevAlpha

RPC API

Path-based HTTP JSON under /api/rpc/ — authenticate once, then call {{model}}/{{method}} with an API key or session.

Source: sumeru/core/server/web/rpc_json.go, sumeru/core/server/api/rpc_body.go, sumeru/core/server/api/dispatch.go

Integrators use path-based HTTP JSON (not a flat POST /api/rpc body with model/method/args). The SWC browser client uses the same prefix with session cookies and CSRF.

Ops probes (outside RPC): GET /api/health (liveness), GET /api/ready (database) — plain JSON, not the RPC envelope below.

Quick start

Prerequisites

  • Running Sumeru instance (HTTPS in production; TLS enables HTTP/2 on the Go listener when configured).
  • Server db_name (e.g. sumeru) and a company id or name for X-Sumeru-Tenant (often 1).
  • A user allowed on that company with password sign-in enabled.

Replace https://erp.example.com, database name, tenant, and credentials in the examples below.

Step 1 — Authenticate

POST /api/rpc/auth.login with database and tenant headers. Do not send Authorization. On success, store data.api_key (sk_…) — shown once.

BASE="https://erp.example.com"DB="sumeru"TENANT="1"curl -sS -X POST "$BASE/api/rpc/auth.login" \  -H "Content-Type: application/json" \  -H "X-Sumeru-Database: $DB" \  -H "X-Sumeru-Tenant: $TENANT" \  -d '{    "context": { "lang": "en_US" },    "login": "integrator@example.com",    "password": "YOUR_PASSWORD"  }'

Success returns data.api_key and data.session_id. Store the API key in a secret manager.

Step 2 — Call a model method

API_KEY="sk_paste_from_login_response"curl -sS -X POST "$BASE/api/rpc/core.partner/search_read" \  -H "Content-Type: application/json" \  -H "X-Sumeru-Database: $DB" \  -H "X-Sumeru-Tenant: $TENANT" \  -H "Authorization: Bearer $API_KEY" \  -d '{    "domain": [["active", "=", true]],    "fields": ["name", "email"],    "limit": 5  }'

Check success": true and read data. Errors use the same envelope — see Response envelope.

Step 3 — Optional health check

curl -sS "$BASE/api/rpc/core.partner/health" \  -H "X-Sumeru-Database: $DB" \  -H "X-Sumeru-Tenant: $TENANT" \  -H "Authorization: Bearer $API_KEY"

Confirms the model is registered and lists public RPC method names. Details under Model health.

Conventions

Required headers

HeaderWhenRule
X-Sumeru-DatabaseAll /api/rpc/ callsMust match server db_name in config
X-Sumeru-TenantAll /api/rpc/ callsActive company id (e.g. 1) or exact core.company name
Content-TypePOST bodiesapplication/json
AuthorizationModel RPC, health GETBearer sk_… or X-API-Key: sk_…
Authorizationauth.loginMust be absent (400 if Bearer or session is treated as pre-auth auth)
X-CSRF-TokenSession cookie authRequired for SWC; omit for API key integrations

Example header set for model RPC:

http
http
POST /api/rpc/core.partner/search_read HTTP/1.1
        Host: localhost:8080
        Content-Type: application/json
        X-Sumeru-Database: sumeru
        X-Sumeru-Tenant: 1
        Authorization: Bearer sk_your_key_here

Response envelope

Every /api/rpc/ response uses:

json
json
{
          "success": true,
          "status_code": 200,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "OK",
          "data": {},
          "error": null
        }
  • success — business outcome (check this even when HTTP status is 200).
  • status_code — mirrors the intended HTTP semantics on the envelope.
  • data — method result on success; null on failure.
  • error — structured failure; shape depends on auth vs model RPC.

Model RPC error (example):

json
json
{
          "success": false,
          "status_code": 403,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "Access denied",
          "data": null,
          "error": {
            "code": "ACCESS_DENIED",
            "name": "sumeru.api.ACCESS_DENIED",
            "message": "Access denied",
            "context": { "code": "ACCESS_DENIED" }
          }
        }

SWC reads error.code or error.context.code for redirects and messaging.

Auth error (auth.login, tenant denial, MFA):

json
json
{
          "success": false,
          "status_code": 401,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "Authentication failed",
          "data": null,
          "error": {
            "code": "INVALID_CREDENTIALS",
            "type": "AuthenticationError",
            "context": {},
            "debug": "Authentication failed."
          }
        }

In dev_mode, debug may include more detail. Production returns a short generic debug string.

Responses may include X-Request-ID when the client sent one.

Browser clients (SWC)

The web app signs in at /web/login, then calls POST /api/rpc/{{model}}/{{method}} with cookie sumeru_session, X-CSRF-Token from window.__SWC_BOOTSTRAP__.csrfToken, and database/tenant headers from bootstrap. Integrators should prefer auth.login + Bearer instead of scraping cookies.

Production checklist

  • Use HTTPS; rotate API keys via the UI or re-login; revoke compromised keys.
  • Do not put keys in query strings or client-side storage.
  • Respect ACLs: the key runs as its user — test with a dedicated integration account.
  • Handle 429 / rate limits when rate_limit_rpm is set.

What not to do

  • Do not use flat POST /api/rpc or legacy {ok, result} responses — they are removed.
  • Do not log raw api_key values or passwords.
  • Do not assume frozen error codes pre-1.0; check error.code and HTTP status.

Operations

Each operation uses the headers in Required headers and the response envelope.

Authenticate

POST/api/rpc/auth.login

Virtual auth endpoint (not an ORM model). POST only.

Request

http
http
POST /api/rpc/auth.login HTTP/1.1
        Content-Type: application/json
        X-Sumeru-Database: sumeru
        X-Sumeru-Tenant: 1
json
json
{
          "context": { "lang": "en_US" },
          "login": "user@example.com",
          "password": "YOUR_PASSWORD"
        }
FieldRequiredNotes
loginyesNon-empty string
passwordyesNon-empty string
contextnoOptional; context.lang accepted for future i18n

Respects auth.local_enabled (403 when password sign-in is disabled). Failed attempts use login lockout (same as web login). Users with TOTP required receive MFA_REQUIRED (403).

Success (200)

json
json
{
          "success": true,
          "status_code": 200,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "User authenticated successfully",
          "data": {
            "uid": 25,
            "username": "user@example.com",
            "name": "API User",
            "session_id": "a1b2c3…",
            "api_key": "sk_…"
          },
          "error": null
        }

A Set-Cookie for sumeru_session may be returned for browser clients. Never log api_key or raw passwords.

Failure (401) — error.code INVALID_CREDENTIALS, error.type AuthenticationError.

Model health

GET/api/rpc/{{model}}/health

GET only. Same database, tenant, and authentication as model POST (Bearer or session + CSRF).

http
http
GET /api/rpc/core.partner/health HTTP/1.1
        X-Sumeru-Database: sumeru
        X-Sumeru-Tenant: 1
        Authorization: Bearer sk_your_key_here

Success (200)

json
json
{
          "success": true,
          "status_code": 200,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "Model health OK",
          "data": {
            "model": "core.partner",
            "registered": true,
            "rpc_methods": ["call", "create", "create_many", "onchange", "read", "read_group", "search", "search_read", "unlink", "unlink_many", "write", "write_many"]
          },
          "error": null
        }

Unknown model → 404 with MODEL_NOT_FOUND. Wrong verb on other paths → 405.

Model RPC

POST/api/rpc/{{model}}/{{method}}
  • {{model}} — registered ORM name (e.g. core.partner, crm.lead).
  • {{method}} — public allowlist below.

Body: flat JSON per method. Optional top-level context, and for reads limit, offset, order where supported.

Auth: API key or session; then UserAllowedCompany for X-Sumeru-Tenant. Invalid API key → 401, message Invalid apikey. Tenant not allowed → 403.

Public methods summary

MethodRequired body fieldsOptionalTypical data
searchdomaincontext, limit, offset (via kwargs)[{id, …}, …]
search_readdomain, fieldslimit, offset, order, contextProjected records
readidsfields, contextRecords
createvaluescontextNew id (int)
writeids, valuescontexttrue
unlinkidscontexttrue
create_manyvalues (array) or recordscontext[id, …]
write_manyids, valuescontexttrue
unlink_manyidscontexttrue
read_groupdomain, groupby, fields (or single spec)contextGroup rows
onchangevalues, fieldcontextOnchange patch object
callid, methodvals, contexttrue or {redirect: "…"}

Default limit is 500 (hard cap). Same ACL and record rules as the web UI.

Method request bodies

Replace {{model}} with any registered model (examples use core.partner unless noted).

POST/api/rpc/{model}/search

Returns matching records (all stored columns subject to field ACL redaction).

Required bodyOptionalTypical data
domaincontext, limit, offsetArray of record maps

Example (core.partner):

json
json
{
  "domain": [["active", "=", true]],
  "context": { "lang": "en_US" },
  "limit": 50,
  "offset": 0
}

search_read

POST/api/rpc/{model}/search_read

Search and project fields in one call.

Required bodyOptionalTypical data
domain, fieldslimit, offset, order, contextProjected records

Example (core.partner):

json
json
{
  "domain": [["customer_rank", ">", 0]],
  "fields": ["name", "email", "phone", "company_id"],
  "limit": 20,
  "offset": 0,
  "order": "name asc",
  "context": { "lang": "en_US" }
}

read

POST/api/rpc/{model}/read

Read known ids.

Required bodyOptionalTypical data
idsfields, contextRecords; omit fields for all allowed columns. Missing ids → NOT_FOUND.

Example (core.partner):

json
json
{
  "ids": [14, 15],
  "fields": ["name", "email"],
  "context": {}
}

create

POST/api/rpc/{model}/create

Create one record.

Required bodyOptionalTypical data
valuescontextNew integer id in data

Example (core.partner):

json
json
{
  "values": {
    "name": "New Partner Ltd",
    "email": "hello@newpartner.example",
    "company_id": 1
  },
  "context": {}
}

write

POST/api/rpc/{model}/write

Update records.

Required bodyOptionalTypical data
ids, valuescontextdata: true

Example (core.partner):

json
json
{
  "ids": [14],
  "values": { "phone": "+1-555-0199" },
  "context": {}
}
POST/api/rpc/{model}/unlink

Delete records.

Required bodyOptionalTypical data
idscontextdata: true

Example (core.partner):

json
json
{
  "ids": [99],
  "context": {}
}

create_many

POST/api/rpc/{model}/create_many

Batch create.

Required bodyOptionalTypical data
values (array) or recordscontextdata: [id, …]

Example (core.partner):

json
json
{
  "values": [
    { "name": "Batch A" },
    { "name": "Batch B" }
  ],
  "context": {}
}

write_many

POST/api/rpc/{model}/write_many

Same body shape as write (shared values for all ids).

Required bodyOptionalTypical data
ids, valuescontextdata: true

Example (core.partner):

json
json
{
  "ids": [14, 15],
  "values": { "active": true },
  "context": {}
}
POST/api/rpc/{model}/unlink_many

Same body shape as unlink.

Required bodyOptionalTypical data
idscontextdata: true

Example (core.partner):

json
json
{
  "ids": [14, 15],
  "context": {}
}

read_group

POST/api/rpc/{model}/read_group

Aggregations; measures sum or count.

Required bodyOptionalTypical data
domain, groupby, fields (or spec)contextGroup rows

Example (core.partner):

json
json
{
  "domain": [["active", "=", true]],
  "groupby": ["company_id"],
  "fields": [
    { "name": "id_count", "field": "id", "measure": "count" }
  ],
  "context": {}
}

onchange

POST/api/rpc/{model}/onchange

Form field change hooks (SWC uses this too).

Required bodyOptionalTypical data
values, fieldcontextOnchange patch object

Example (core.partner):

json
json
{
  "values": { "name": "Partial", "country_id": 233 },
  "field": "country_id",
  "context": {}
}

call

POST/api/rpc/{model}/call

Invokes orm.RegisterObjectAction handlers (toolbar object buttons).

Required bodyOptionalTypical data
id, methodvals, contextdata: true or { redirect: "…" }

Example (crm.lead):

json
json
{
  "id": 42,
  "method": "action_merge_wizard",
  "vals": { "active_ids": "3,7" },
  "context": {}
}

Example model: POST /api/rpc/crm.lead/call. vals is a string map passed to orm.RunObjectAction.

search_read success (200) — example envelope:

json
json
{
          "success": true,
          "status_code": 200,
          "timestamp": "2026-10-16T12:00:00+05:30",
          "message": "OK",
          "data": [
            {
              "id": 14,
              "name": "Acme Corp",
              "email": "contact@acme.example",
              "phone": "+1-555-0100",
              "company_id": 1
            }
          ],
          "error": null
        }

Removed legacy shapes

The following are not registered on the live router:

  • Flat POST /api/rpc with model, method, args, kwargs in one body
  • JSON-RPC params wrapper
  • Response shape { "ok", "result", "error" }

Use path URLs and the envelope documented above.

Security

  • RPC runs with the authenticated user (session or API key owner) and active tenant company in ORM context.
  • Model ACL, record rules, field ACL, and portal RPC model restrictions apply.
  • Rate limiting: config rate_limit_rpm applies to the /api/rpc/ prefix and login (see configuration reference).

Observability

Prometheus: sumeru_rpc_requests_total, sumeru_rpc_duration_seconds (GET /metrics with system group).

See also