Create a function version
const url = 'https://example.com/v1/a/adapters/edge/functions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"slug":"example","code":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/a/adapters/edge/functions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "slug": "example", "code": "example" }'Validates the code, bundles it and stores a new version of slug.
If the latest version of slug has exactly the same code, nothing is
bundled: the existing version is returned. Otherwise the version is the
latest one plus 1 (the first one is 1) and it becomes the latest.
Validation runs inside the request and can take seconds: forbidden
lexemes, deno check against the runtime globals, ESLint. Bundling
(deno install + deno bundle) runs inside the request too.
Permission
This operation needs the permission edge:function:manage.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Function name inside the account. Needs at least one [A-Za-z0-9_]
character and must not be by-id. Other characters are not rejected.
TypeScript or JavaScript module with a default export (or a
handler export). Rejected with 422 when it has a forbidden
lexeme, fails deno check against the runtime globals, or fails
ESLint. See FLOW.md for the lists.
Examplegenerated
{ "slug": "example", "code": "example"}Responses
Section titled “Responses”Version created, or the latest one reused
object
Keys found in the code as string literals of storage.get /
storage.unpack (reads) or storage.set (writes). Keys built at
runtime are not found.
Keys found in the code as string literals of storage.get /
storage.unpack (reads) or storage.set (writes). Keys built at
runtime are not found.
Example
{ "ok": true}Domain error. A failed bundle comes as 400 with
err_code: INTERNAL_SERVER_ERROR. On a run route a bundle that could
not be rebuilt is this 400 too.
object
Example
{ "ok": false, "err_code": "UNAUTHORIZED"}Unauthorized
Forbidden
The body, query or path params did not pass the zod schema
object
Zod issues as is
object
Example
{ "ok": false, "error": "Validation failed"}Unexpected error, for example a database or a disk failure. The body
has err_code: INTERNAL_SERVER_ERROR.
object
Example
{ "ok": false, "err_code": "UNAUTHORIZED"}Bad gateway (upstream adapter error)