---
title: "Update Custom Function"
method: PATCH
path: "/v1/custom_functions/{function_id}"
tags: ["API v1", "Custom Functions", "Custom Functions CRUD"]
---

# Update Custom Function

`PATCH /v1/custom_functions/{function_id}`

## Request

- Base URL: `https://api.xpander.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.xpander.ai/v1/custom_functions/{function_id}`
- Auth: API key in header `x-api-key`

Update an existing custom function. You can update name, description, source_code, and limits. If source_code changes, the function is re-analyzed automatically.

## Path parameters

- `function_id` string, required

## Request body

- UpdateCustomFunctionRequest: Request model for updating an existing custom function. All fields are optional. If source_code changes, the function will be re-analyzed automatically (status transitions to 'analysing' then 'ready').
  - `name` string, nullable: Updated function name.
  - `description` string, nullable: Updated function description.
  - `source_code` string, nullable: Updated Python source code. If changed, triggers re-analysis.
  - `limits` CustomFunctionLimitsModel: Resource limits for custom function execution.
    - `max_run_time` integer, nullable: Maximum execution time in seconds. The function will be terminated if it exceeds this limit. Default: 15 seconds.

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/xpander/apis/xpander-ai-api-service.md) - [All operations](https://skmtc.dev/xpander/apis/xpander-ai-api-service/llms.txt) - [OpenAPI document](https://skmtc.dev/xpander/apis/xpander-ai-api-service/revisions/725c0066d5df?raw)
