Functions
Functions: create, read, configure and delete. Reachable with a team API key.
postCreate a function
Creates a function owned by `ownerTeam` (a team URN or slug) and assigns its hostname, `<name>.fns.xnr.app`. Names are never chosen. `displayName` is required (at most 64 characters, no control characters). `kind` is required (`KIND_NODE`, `KIND_GO` or `KIND_STATIC`) and cannot be changed later. Settings that do not apply to the kind are refused with `INVALID_ARGUMENT`: a port, entrypoint, packages or env on a static function, `staticDir` on a non-static one, `mainPackage` on a non-Go one. `source` says where the code lives, once and for good. Left out, or `SOURCE_MODE_PLATFORM`, the workspace is scaffolded with a working hello-world project for the kind and is edited in the console. `SOURCE_MODE_EXISTING_REPO` attaches `repo` through a team connection, and `SOURCE_MODE_NEW_REPO` creates the repository through the provider and writes the scaffold into it. A first deploy starts in the background, so the returned function usually has no `activeVersionId` yet; follow the deploy with `ListVersions` or `GetFunction`. A failure to apply `source` does not undo the function: it is created, and the reason comes back in `sourceError` with an OK status so the caller keeps the record. A `function.create` event is recorded in the team's activity feed. Needs the editor role in the owning team. A team API key may leave `ownerTeam` empty to create in its own team, and needs the editor role there; a signed-in user must name the team. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:edit`
postDelete a function
Deletes the function. Its hostname stops serving, and what it held on the platform is released: the App behind every version, and the workspace that owns their snapshots. The platform clean-up is best effort, so a platform outage does not block the delete. Needs the editor role in the owning team. A `function.delete` event is recorded in the activity feed. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:edit`
postGet a function
Returns one function by `functionId`, or by `name` (its assigned hostname label) when no id is given. One of the two is required (`INVALID_ARGUMENT`). The response embeds the active and latest versions, as `ListFunctions` does. Needs the viewer role in the owning team. An unknown function is `NOT_FOUND`; one in a team the caller cannot read is `PERMISSION_DENIED`. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:read`
postList functions
Lists functions sorted by their hostname label (`name`), each with its `activeVersion` and `latestVersion` embedded so a status column needs no call per row. `ownerTeam` (a team URN or slug) narrows the listing to one team and needs the viewer role there; a team the caller is not in answers `NOT_FOUND`. Left empty, the listing covers every team in the caller's teams claim, or an API key's own team. `search` is a case-insensitive substring match on `name`. Pages default to 50 functions and are capped at 500 (`limit`). Pass `nextCursor` back as `cursor`; an empty `nextCursor` means the last page. The cursor is opaque, and a function created during a paged walk can shift later pages. `total` counts every function matching `ownerTeam` and `search` across all pages, so a `limit` 1 request is enough to show a count. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:read`
postUpdate a function
Applies a partial update: only the fields named in `updateMask` are written, and everything else is left alone. An empty mask is `INVALID_ARGUMENT`, and so is a path that is not writable: the writable paths are `display_name`, `owner_team`, `build`, `scaling`, `env`, `git_branch`, `git_subdirectory`, `git_access_token`, `git_webhook_secret`, `set_secrets` and `clear_secrets`. `displayName` is validated as at creation. `build` and `scaling` each replace their whole block when named. `env` replaces the whole map. `set_secrets` merges into the stored secrets and `clear_secrets` removes secrets by name; secret values are stored encrypted and only their names come back, in `secretKeys`. Settings that do not apply to the function's kind are refused with `INVALID_ARGUMENT`. `git_branch` and `git_subdirectory` change where a connected repository deploys from. A function with no repository is `FAILED_PRECONDITION`. `git_access_token` and `git_webhook_secret` are write-only: an empty string clears them. A running version keeps the environment it was created with, so env and secret changes go live with the next version (`CreateVersion` with a redeploy source). Needs the editor role in the owning team. Moving the function with `owner_team` also needs the admin role in the destination team. A `function.update` event records which settings and secret names changed, never their values. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:edit`
Move or rename a path POST
Moves or renames a file or directory within the workspace. The only writable path in `updateMask` is `new_path`: an empty mask, or a mask naming anything else, is `INVALID_ARGUMENT`. Neither `path` nor `newPath` can be the root or escape it (`INVALID_ARGUMENT`), and `newPath` is required when it is masked. Returns both cleaned paths. A function that deploys from a repository has a read-only workspace and is refused with `FAILED_PRECONDITION`. Needs the editor role in the owning team. Recorded as a `files.edit` activity event. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:edit`
Create a function POST
Creates a function owned by `ownerTeam` (a team URN or slug) and assigns its hostname, `<name>.fns.xnr.app`. Names are never chosen. `displayName` is required (at most 64 characters, no control characters). `kind` is required (`KIND_NODE`, `KIND_GO` or `KIND_STATIC`) and cannot be changed later. Settings that do not apply to the kind are refused with `INVALID_ARGUMENT`: a port, entrypoint, packages or env on a static function, `staticDir` on a non-static one, `mainPackage` on a non-Go one. `source` says where the code lives, once and for good. Left out, or `SOURCE_MODE_PLATFORM`, the workspace is scaffolded with a working hello-world project for the kind and is edited in the console. `SOURCE_MODE_EXISTING_REPO` attaches `repo` through a team connection, and `SOURCE_MODE_NEW_REPO` creates the repository through the provider and writes the scaffold into it. A first deploy starts in the background, so the returned function usually has no `activeVersionId` yet; follow the deploy with `ListVersions` or `GetFunction`. A failure to apply `source` does not undo the function: it is created, and the reason comes back in `sourceError` with an OK status so the caller keeps the record. A `function.create` event is recorded in the team's activity feed. Needs the editor role in the owning team. A team API key may leave `ownerTeam` empty to create in its own team, and needs the editor role there; a signed-in user must name the team. Callable with a console session or a team API key (`Authorization: Bearer xk_…`). **Required scopes:** `functions:functions:edit`