---
title: "Update function"
method: PATCH
path: "/functions/{function_id}"
tags: ["Functions"]
---

# Update function

`PATCH /functions/{function_id}`

Update function metadata or code. Supports partial updates - only include fields you want to change.

Common updates:
- Update function code (requires redeployment to take effect)
- Change function name or description
- Update runtime configuration
- Modify function slug

Important: Code updates are saved immediately but do NOT automatically deploy. After updating code, you must call POST /functions/{id}/deploy for changes to take effect in production.

## Request body

- FunctionUpdateRequest — Request to update an existing function. Supports partial updates - only include fields you want to change. Important: Code updates are saved but not automatically deployed. You must call POST /functions/{id}/deploy to deploy changes to production.
  - `function` object, required
    - `name` string — Function display name
    - `slug` string — URL-safe function identifier (lowercase alphanumeric with hyphens)
    - `lock_version` integer — Optional. Include the current lock version to enable concurrent-modification detection — stale values return `409 Conflict`. If omitted, the update proceeds without conflict checking.
    - `description` string — Function description
    - `code` string — Updated JavaScript function code. After updating code, you must redeploy the function using POST /functions/{id}/deploy for changes to take effect in production.
    - `invoke_response_mode` 'wrapped' | 'passthrough' — Controls how successful invoke responses are returned for existing functions. - `passthrough`: Forward the function response body, status code, and `Content-Type` directly. - `wrapped`: Preserve the legacy Kapso API wrapper and return successful JSON results under `data`. New functions default to `passthrough`. `wrapped` is only available for legacy wrapped functions.
    - `runtime_config` object — Platform-specific runtime configuration
    - `public_endpoint` boolean — Allow invoke requests without an API key. Only supported for `cloudflare_worker` functions.

## Response `200`

Function updated successfully

- FunctionResponse — Single function response
  - `data` Function, required — Serverless function configuration. Functions are custom JavaScript code that runs on-demand in response to API invocations. Deploy functions to either Cloudflare Workers (global edge network) or Supabase Edge Functions (Deno runtime).
    - `id` string, uuid, required — Unique function identifier
    - `name` string, required — Function display name (user-friendly identifier)
    - `slug` string, required — URL-safe function identifier (lowercase alphanumeric with hyphens). Used in endpoint URLs. Must match pattern: /^[a-z0-9-]+$/
    - `lock_version` integer — Optimistic locking version. Increments on each update. Include this value on update to detect concurrent modifications — stale values return `409 Conflict`.
    - `description` string, nullable — Optional function description explaining purpose and usage
    - `code` string — JavaScript function code. Maximum size: 1 megabyte. This is the actual code that will execute when the function is invoked. Must be valid JavaScript that can run in the target environment (Cloudflare Workers or Supabase Edge Functions).
    - `version` integer, nullable — Function version number. Increments with each deployment. Use this to track which version is currently deployed in production.
    - `status` 'draft' | 'deployed' | 'error', required — Deployment status: - `draft`: Function code saved but not yet deployed to runtime - `deployed`: Successfully deployed and available for invocation - `error`: Deployment failed (check error logs for details)
    - `last_deployed_at` string, date-time, nullable — Timestamp of most recent successful deployment, null if never deployed
    - `function_type` 'cloudflare_worker' | 'supabase_function', required — Serverless runtime platform: - `cloudflare_worker`: Deploys to Cloudflare Workers (global edge network) - `supabase_function`: Deploys to Supabase Edge Functions (Deno runtime)
    - `invoke_response_mode` 'wrapped' | 'passthrough' — Controls how successful invoke responses are returned: - `wrapped`: Legacy behavior. Successful JSON responses are nested under `data`. - `passthrough`: Kapso forwards the function response body, status code, and `Content-Type` directly. Existing functions may still be `wrapped`. Newly created functions default to `passthrough`.
    - `public_endpoint` boolean — Whether the invoke endpoint can be called without an API key. Only supported for `cloudflare_worker` functions. When `true`, Kapso serves the function through the Platform API invoke route and anonymous requests are allowed.
    - `runtime_config` object, nullable — Platform-specific runtime configuration. Structure varies by function_type. Use this to configure environment variables, resource limits, or platform-specific features.
    - `endpoint_url` string, uri, nullable — Invocation URL for this function. Computed based on `function_type`. - `cloudflare_worker`: `https://api.kapso.ai/platform/v1/functions/{function_id}/invoke` - `supabase_function`: Direct Supabase Edge Function URL For private Cloudflare functions, include `X-API-Key`. For public Cloudflare functions (`public_endpoint=true`), the API key is optional.
    - `project_id` string, uuid — Project this function belongs to
    - `created_by_id` string, uuid, nullable — ID of user who created this function
    - `created_at` string, date-time, required — Function creation timestamp
    - `updated_at` string, date-time, required — Last modification timestamp

## Other responses

- `401` — Missing or invalid API key
- `404` — Resource not found
- `409` — Conflict — the supplied `lock_version` is stale. Refetch the function to get the current version and retry.
- `422` — Request validation failed

---

[API](https://skmtc.net/kapso/apis/kapso-platform-api.md) · [All operations](https://skmtc.net/kapso/apis/kapso-platform-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kapso/kapso-platform-api/versions/18ff5548a33f/schema)
