---
title: "Invoke a function"
method: POST
path: "/functions/{functionId}/invoke"
tags: ["Functions"]
---

# Invoke a function

`POST /functions/{functionId}/invoke`

## Request

- Base URL: `https://api.volcano.dev`
- URL: `https://api.volcano.dev/functions/{functionId}/invoke`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Invoke a function. The function's `visibility` decides which credentials
may call it, and the function does not run for any other. A `private`
function answers every credential but a service key exactly as a
missing one, with 404, so its name and id cannot be discovered; an anon
key on an `authenticated` function gets 403. An SDK calling by name
resolves it first through `GET /functions/resolve`, which answers that
anon key with 404 instead.

**With Service Key** (admin/background operations, every visibility):
- Use for background jobs, webhooks, cron, admin operations
- Function receives payload only (no user context)
- Database queries bypass RLS (admin access)

**With Auth User Token** (user-facing, `authenticated` or `public` functions):
- Use for user-initiated actions
- Includes users from anonymous sign-ins
- Function receives payload + `__volcano_auth` context:
  ```javascript
  {
    user_id: "uuid",
    email: "user@example.com",
    project_id: "uuid",
    role: "authenticated" or "anonymous"
  }
  ```
- Database queries enforce RLS (user-scoped data)

**With Anon Key** (`public` functions only):
- Requires anon key permission: `functions.invoke`
- Function must have `visibility: public`
- Function receives payload only (no `__volcano_auth`)

**Reserved payload keys:** the top-level `__volcano_auth` and
`__volcano_http` keys are reserved. Volcano removes caller-supplied
values for both before the function runs; only an auth user token adds
a server-built `__volcano_auth`, and only HTTP-mode ingress sets
`__volcano_http: true`.

**Transport and CORS:**
- This operation is the authenticated direct RPC endpoint and always uses the
  POST `{payload: ...}` contract, including for functions whose DNS ingress is
  configured in HTTP mode.
- The geo-routed DNS ingress is the function's `invoke_url`. It is on a
  different domain from this API, so it cannot be derived from the API host.
- RPC-mode DNS ingress accepts POST at `/`. HTTP-mode DNS ingress accepts GET,
  HEAD, POST, PUT, PATCH, and DELETE at `/` and nested paths.
- Direct and RPC-mode CORS preflight advertises `POST, OPTIONS`. HTTP-mode DNS
  preflight advertises `GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS`.
- `http_auth_mode: none` applies only to public HTTP-mode DNS ingress; this
  direct operation always requires a Volcano credential.

**Durable functions are not invocable here.** A durable function's id
answers 404, whatever its visibility, because a synchronous call would
run it with no execution record, no idempotency and no concurrency
accounting. Start one with
`POST /durable-functions/{functionId}/executions`.

## Path parameters

- `functionId` string, uuid, required

## Request body

- FunctionInvocationRequest
  - `payload` object: Payload to send to the function. If invoked with auth user token, Volcano automatically injects `__volcano_auth` context: ```javascript { ...yourPayload, __volcano_auth: { user_id: "uuid", email: "user@example.com", project_id: "uuid", role: "authenticated" | "anonymous" } } ``` The top-level `__volcano_auth` and `__volcano_http` keys are reserved; Volcano removes caller-supplied values for both.

## Response `200`

Function response (passthrough from function runtime)

- FunctionInvocationResponse: Raw function response body returned by the invoked function.

## Other responses

- `400`: Bad request - invalid payload or function in failed state
- `401`: Unauthorized - invalid or missing token
- `403`: Forbidden - CORS blocked, missing `functions.invoke`, or an anon key on an `authenticated` function
- `404`: Function not found. Also returned for a `private` function to any credential but a service key.
- `429`: Rate limit exceeded (per-function or project-wide limit), or the owning platform user's billing-cycle bandwidth allowance (aggregate ingress + egress) was exceeded.
- `503`: Function still provisioning or rate limiting service unavailable. A freshly deployed (or updated) function may briefly report `provisioning` and reject invocations until the background status reconciler observes its deployment workflow completing and transitions it to `active`. This is expected for a few seconds after deploy; clients should retry.
- `default`: Function response (passthrough; status code/body/headers come from the function)

## Changes

- **2026-09-19** `3a6f365f3f35`: 10 breaking, 13 info
  - added the new path request parameter `functionId`
  - the request's body type changed from no type to `object`
  - the response's body type changed from no type to `object` for status `200`
  - the response's body type changed from no type to `object` for status `400`
  - …19 more
- **2026-08-27** `bb44e98aba2e`: 15 breaking, 8 warning
  - the request's body type changed from `object` to no type
  - the response's body type changed from `object` to no type for status `200`
  - the response's body type changed from `object` to no type for status `400`
  - the response's body type changed from `object` to no type for status `401`
  - …19 more
- **2026-07-27** `bb52784e098a`: 6 info
  - added the optional property `code` to the response with the `400` status
  - added the optional property `code` to the response with the `401` status
  - added the optional property `code` to the response with the `403` status
  - added the optional property `code` to the response with the `404` status
  - …2 more

[Operation history](https://skmtc.dev/kong/apis/volcano-api/changes/functions/:functionId/invoke/post.md)

---

[API](https://skmtc.dev/kong/apis/volcano-api.md) - [All operations](https://skmtc.dev/kong/apis/volcano-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/volcano-api/revisions/84c4488f91e9?raw)
