Upload Edge Function Source

POST /v1/account/edge-functions/{fn_uuid}/source

Save new JavaScript source for an edge function and queue its build. The source passes an AI security check first; then it is stored, the function's status becomes building, and a build job compiles it to a WebAssembly bundle. The call returns 202 Accepted as soon as the build is queued — poll Get Edge Function until status is ready (with a new bundle_hash) or failed.

When the build is ready, enabled edge-function rules already attached to the function are moved to the new bundle automatically. If the build fails, those rules keep running the previous build.

Requires the endpoints:write permission on the active account and the edge_functions plan entitlement. A function paused over the plan (disabled_by_plan: true) can't be rebuilt.

Path parameters

fn_uuid string (uuid) Req
The function's uuid, from List Edge Functions.

Request body

source string Req
The JavaScript source, not blank, at most 524,288 bytes (512 KiB). The whole request body is capped at 1 MiB.

Response (202 Accepted)

{"edge_function": { … }} — the function with the new source and status: "building" (fields: the edge function object).

Deprecated: until the sunset this response also carries the legacy integer id and *_id fields. Don't use them; read uuid and the *_uuid fields.

Errors

400 Bad Request
invalid JSON body or source is required.
401 Unauthorized
Missing or invalid auth.
403 Forbidden
The caller lacks endpoints:write, the plan doesn't include edge_functions (code entitlement_required), or the account is suspended (code account_suspended).
404 Not Found
edge function not found — unknown uuid, another account's function, or an application's function.
409 Conflict
The function is paused over the plan (code quota_paused, with quota_paused_key: "edge_functions").
413 Payload Too Large
source too large (max 524288 bytes).
415 Unsupported Media Type
The request has no Content-Type: application/json header.
422 Unprocessable Entity
source failed the AI security check (or the check could not run). Nothing was changed.
500 Internal Server Error
failed to load edge function or failed to save source.
502 Bad Gateway
The source could not be stored (upload to storage failed) and the function's status returns to draft (ready when it has a built bundle); or the build could not be queued (failed to enqueue build, build queue is not configured) and the function's status becomes failed. Retry the upload.
503 Service Unavailable
object storage is not configured.
Request
curl -X POST "https://api.ngris.com/v1/account/edge-functions/019b1f24-1a62-7d27-8411-538ed86e2a62/source" \ -H "X-API-KEY: <your_api_key>" \ -H "Content-Type: application/json" \ -d '{"source": "<JavaScript source, as one JSON string>"}'
Response — 202 Accepted
{ "edge_function": { "uuid": "019b1f24-1a62-7d27-8411-538ed86e2a62", "account_uuid": "019b24b5-135e-7590-888e-e7cfa7e28ff3", "name": "add-security-headers", "source": "function readRequest() { … }\n…", "bundle_key": "accounts/4821/edgefn/019b1f24-1a62-7d27-8411-538ed86e2a62/bundle.wasm", "bundle_hash": "5f2c8e0b9a7d4c31e6f80a2b4d9c7e15a3f6b8d02c4e9a7f1b3d5c8e0a2f4b6d", "entry": "default", "phase": "on_http_response", "timeout_ms": 50, "memory_mb": 64, "status": "building", "created_at": "2026-10-12T09:14:03Z", "updated_at": "2026-10-14T16:05:31Z", "disabled_by_plan": false } }