Beta APIs

[beta] Update a Function.

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.

patch/functions/{name}

Request

  • Base URL
    https://api.samsara.com
  • Auth
    HTTP bearer

Path parameters

namestring required

The name of the Function to update.

Request body

descriptionstring

A description of the Function.

lastUpdateTimestampMsinteger required

Timestamp of the last known update to this Function, obtained from a create or get response. Required to prevent conflicting updates.

Example request

{
  "config": {
    "handler": "index.handler",
    "isScheduleEnabled": true,
    "params": {
      "region": "us-west",
      "threshold": "100"
    },
    "schedule": {
      "entries": [
        {
          "daysOfWeek": [
            false,
            true,
            true,
            true,
            true,
            true,
            false
          ],
          "timeSinceMidnightMs": 32400000
        }
      ],
      "timezone": "America/Los_Angeles"
    },
    "secrets": {
      "API_KEY": "my-secret-value"
    }
  },
  "description": "Processes incoming telemetry data.",
  "lastUpdateTimestampMs": 1609459200000
}

Response

OK response.

Example response

{
  "data": {
    "lastUpdateTimestampMs": 1609459200000,
    "name": "my-function",
    "updatedAtTime": "2021-01-01T00:00:00Z",
    "uploadPutUrl": "https://example.com/upload?token=..."
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.