Configure APIs and Response Fields API
Purpose and preconditions
This page describes API and response-field configuration inside menu configs. Admin pages can maintain these pieces incrementally with menus.loadApis/actions/responses; config-as-code can declare load, actions, and response inside MenuConfigInput. Public code no longer needs to create API bindings directly. permission-core compiles internal endpoint contracts when the menu config is saved.
Before using it:
- You have a menu config, either from
menus.configs.create()or a completeMenuConfigInput. - API resources use
ApiResourceinapi:METHOD:/pathform. - Response fields are declared in config before role-menu grants select them.
What Do You Want to Do?
Signatures
Signature markers: load.resource: ApiResource, actions[].resource: ApiResource | UiResource, and response?: ResponseProjectionConfigInput. For ordinary incremental APIs, bind actorId/requestId once with pc.scope(scope, defaults), then call the object methods directly; the system derives the idempotency key while performing internal preview and commit automatically. Use explicit expected/previewToken from the matching preview*() method for cascade delete, grant-revoking delete, or rejected auto-commit.
Parameters
MenuLoadInput
MenuActionInput
ResponseProjectionConfigInput
ResponseProjectionInput can be a field array or an object with { target, preserve, fields }. That is the inline convenience form for MenuConfigInput.load[].response and actions[].response; menus.responses.set() should use object form, such as response: { fields: [...] }.
Method details: page load APIs
MenuConfigInput.load
- Purpose: Declare backend APIs required when entering a view.
- Parameters:
load.resourceis anApiResource;load.responsedeclares grantable response fields. - State impact: Saving the config creates an internal endpoint contract; selecting
include.loads: truein a role grant creates invoke permission sources. - Raw return: The field has no standalone return. Results appear in
menus.config.preview/saveplans and snapshots.
Example:
Method details: page action APIs
MenuConfigInput.actions
- Purpose: Declare buttons, toolbar actions, or row operations under a view.
- Parameters:
actions[].resourceisApiResource | UiResource; useapi:when the action calls the backend. - State impact: Saving the config creates grantable actions; selecting
include.actions: truecreates action or API permission sources. - Raw return: The field has no standalone return. User-side state is read with
subject.menus.getActionMap().
Example:
Method details: response fields
MenuConfigInput.response
- Purpose: Define which fields in an API response can be granted to roles.
- Parameters: Array form declares fields directly; object form uses
target/preserve/fieldsfor paginated or nested responses. When callingmenus.responses.set()incrementally, wrap it in object form:response: { fields: [...] }. - State impact: Saving the config creates field inventory. After role grants select
responseFields,filterResponse()returns only those fields. - Raw return: Field declarations appear in
MenuConfigSnapshotload/action responses; runtime projection appears inSubjectRuntimeResult.data.
Array form:
Paginated form:
Responses and side effects
load/actions/response are config fields, not standalone mutation envelopes. Their validation and compiled results surface through these APIs:
Failures and limits
load.resource must be an api: resource. actions[].resource must use a supported resource scheme. Field paths cannot be empty or unsafe, and role grants cannot select undeclared fields. preserve bypasses field grants, so keep it for structural fields, not sensitive business fields.
For incremental response-field configuration, remember that menus.responses.set() expects input.response to be a ResponseProjectionConfigInput object, not an array. For a direct-object response, write { fields: [...] }.
Example
Related
See Manage Menus, Authorize Role Menus, and Menus API.