Deployment
Deploying an Agentic Function compiles it into an immutable version and exposes it as an authenticated HTTP endpoint.
The run API
An Agentic Function answers at a stable path keyed by its slug — POST /v1/run/{slug}.
There is no version in the URL: the endpoint always runs the active
deployment, so promoting or rolling back a version never changes the call:
curl -X POST https://api.fnai.dev/v1/run/classify \
-H "Authorization: Bearer $FN_KEY" \
-H "Content-Type: application/json" \
-d '{"input": {"ticket": "…"}}'
To discover what the active deployment accepts and returns, ask for its
contract — GET /v1/run/{slug}/contract.
The response is your typed output under output, plus a meta block:
{
"status": "success",
"output": {
"category": "billing",
"priority": "high",
"confidence": 0.94
},
"meta": {
"version": "v3",
"latency_ms": 142,
"cost_usd": 0.003,
"tokens": 1840,
"trace_id": "run_8f3c2a1d"
}
}
status is success or failed; on a failure the reason is in error. Note
that an execution failure is still a 200 — the HTTP status covers API-level
problems (401 bad key, 404 unknown or undeployed Agentic Function, 422 input that
doesn't match the contract, 504 execution timeout), so check status, not just
the response code. meta.trace_id addresses the full run — pass it to fn logs
or the API to replay exactly what happened.
Authentication
Requests are authenticated with a bearer token. Create scoped API keys per
environment in your dashboard, and pass them as
Authorization: Bearer <key>. Keys can be restricted to specific Agentic
Functions.
Environments
A deploy targets a named environment — typically development, staging, and
production. Each environment keeps its own version history and aliases, so
shipping to staging never touches production traffic.
Aliases & rollback
Because the endpoint addresses the Agentic Function, not a version, promoting and rolling back are pointer moves behind a call that never changes:
fn promote classify --to v3
fn rollback classify --to v2
Callers keep hitting POST /v1/run/classify throughout; meta.version in the
response tells you which version actually answered.
Rollback is instant because every version already exists; you are only moving a pointer.