Creating APIs
Three ways to expose behaviour to clients and the workspace UI.
1. RPC API (recommended for integrations)
Use path-based POST /api/rpc/ for external CRUD and integrations: authenticate with auth.login, then call {model}/{method} with an API key. Full quick start, headers, and every public method are documented in the RPC API reference. For UI-created keys and header forms, see API keys. RPC enforces the same ACLs and record rules as the web UI.
2. Custom HTTP routes
Register addon routes from init() using sumeru/core/server/router:
| Auth mode | Use when |
|---|---|
AuthNone | Public endpoints (careful) |
AuthSession | Browser or cookie client |
AuthAPIKey | Machine clients |
How-to: Custom HTTP route.
CSRF: Web POST handlers that mutate state require a CSRF token (core/server/web/csrf.go). API-key and GET routes follow different rules.
3. Object actions (workspace buttons)
Register handlers for toolbar buttons on forms and lists:
orm.RegisterObjectAction("crm.lead", "action_set_won", func(ctx context.Context, ids []int64) error {
// ...
return nil
})Wire the button in XML with type="object" and name="action_set_won". Used heavily in CRM and Accounting modules.
Choosing an approach
| Need | Use |
|---|---|
| External system CRUD | RPC API + API key |
| Printable report or file download | Custom HTTP route |
| User clicks button on a record | Object action |
| React to another module's data change | Event bus subscription |