*api / n-api
*api is the general HTTP gateway directive. It supports GET-style loading, non-GET JSON requests, and file-input uploads.
- Non-clickable elements auto-run once.
- Button-like elements run on click.
<input type="file">runs on file selection.- Non-GET JSON requests send a Sercrod request envelope.
*responsemaps parsed responses into host data.
<button
type="button"
*api="/api/save"
method="POST"
body="form"
*params="{ source: 'settings' }"
*dry-run
*response="'result'">
Preview save
</button>
GET and body rules
GET requests do not send a JSON body. If *dry-run or non-empty *params is used with GET, Sercrod warns because those markers need a request body.
File input upload
<input
type="file"
name="avatar"
*api="/api/avatar"
*params="{ kind: 'avatar' }"
*response="'upload_result'">
For file inputs, Sercrod sends FormData. When *params or *dry-run is present, it appends JSON fields named sercrod, data, and params.
Native integration results
Use *api when a project-specific JavaScript function produces
data that should be sent to an application endpoint. Standard push
registration uses *push="/api/push" and does not require this
lower-level pattern.
<serc-rod data='{"nativeResult":null,"sendResult":null}'>
<button type="button" onclick="readProjectBridge()">Read project bridge</button>
<button
type="button"
*api="/api/native-result"
method="POST"
body="nativeResult"
*response="'sendResult'">
Send result
</button>
</serc-rod>
The project bridge should only obtain the platform result and assign host
data. Private provider credentials remain outside *api and
outside Sercrod client code.
Response placement
Every successful response is mirrored to $response. Without *response, normal host data is not changed.