---
title: "[beta] Update a Function."
method: PATCH
path: "/functions/{name}"
tags: ["Beta APIs"]
---

# \[beta\] Update a Function.

`PATCH /functions/{name}`

## Request

- Base URL: `https://api.samsara.com`
- URL: `https://api.samsara.com/functions/{name}`
- Auth: HTTP bearer

Update an existing Function's description and configuration. The request must include `lastUpdateTimestampMs`, which is the timestamp value obtained from a previous create or get response. The response includes a URL (`uploadPutUrl`) for uploading new code. After uploading, call `POST /functions/{name}/deploy` for the changes to be applied.

 <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

To use this endpoint, select **Write Functions** under the Functions category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
 

 **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

## Path parameters

- `name` string, required

## Request body

- FunctionsPatchFunctionRequestBody: Request body for updating a Function.
  - `config` PatchFunctionRequestConfigRequestBody: Configuration fields to update on the Function. All fields are optional; only provided fields are updated.
    - `handler` string: The handler entrypoint for the function code (e.g. 'index.handler').
    - `isScheduleEnabled` boolean: Whether the run schedule is enabled.
    - `params` object: Default parameter values for the function. Replaces all existing parameters.
    - `schedule` FunctionScheduleRequestBody: Schedule configuration for a Function.
      - `entries` FunctionScheduleEntryRequestBody[], required: Schedule entries defining when the function runs.
        - `daysOfWeek` boolean[], required: Days of the week this entry applies to (7 elements, index 0 = Sunday).
        - `timeSinceMidnightMs` integer, required: Time since midnight in milliseconds when the function runs.
      - `timezone` string, required: IANA timezone name for the schedule.
    - `secrets` object: Secrets available to the function at runtime. Replaces all existing secrets.
  - `description` string: A description of the Function.
  - `lastUpdateTimestampMs` integer, required: Timestamp of the last known update to this Function, obtained from a create or get response. Required to prevent conflicting updates.

## Response `200`

OK response.

- FunctionsPatchFunctionResponseBody
  - `data` PatchFunctionDetailResponseBody, required: Details of an updated Function, including a URL for uploading a new code package. After uploading, call the deploy endpoint for the changes to be applied.
    - `lastUpdateTimestampMs` integer, required: Epoch milliseconds of the last update. Use this value in subsequent patch requests.
    - `name` string, required: Name of the Function.
    - `updatedAtTime` string, date-time, required: RFC 3339 timestamp when the Function was last updated.
    - `uploadPutUrl` string, required: A presigned PUT URL for uploading the function's code package. Valid for a limited time. After uploading, call `POST /functions/{name}/deploy` for the changes to be applied.

## Other responses

- `401`: Unauthorized response.
- `404`: Not Found response.
- `405`: Method Not Allowed response.
- `413`: Content Too Large response.
- `429`: Too Many Requests response.
- `500`: Internal Server Error response.
- `501`: Not Implemented response.
- `502`: Bad Gateway response.
- `503`: Service Unavailable response.
- `504`: Gateway Timeout response.
- `default`: Bad Request response.

---

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