Beta APIs

[beta] Create a Function.

Create a new Function with the given name, description, and configuration. The response includes a URL (uploadPutUrl) for uploading the function's code package. After uploading, call POST /functions/{name}/deploy to make the function runnable.

<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.

post/functions

Request

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

Request body

descriptionstring

A description of the Function.

namestring required

Unique name for the Function.

Example request

{
  "config": {
    "handler": "index.handler",
    "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.",
  "name": "my-function"
}

Response

OK response.

Example response

{
  "data": {
    "codePackage": {
      "downloadGetUrl": "https://example.com/download?token=...",
      "status": "deployed"
    },
    "config": {
      "handler": "index.handler",
      "isScheduleEnabled": true,
      "params": {
        "Nihil vitae modi accusamus est.": "Eos dolor magni mollitia.",
        "Qui ex quos perferendis eveniet repudiandae.": "Qui quia quam quam vel voluptas."
      },
      "schedule": {
        "entries": [
          {
            "daysOfWeek": [
              false,
              true,
              true,
              true,
              true,
              true,
              false
            ],
            "timeSinceMidnightMs": 32400000
          }
        ],
        "timezone": "America/Los_Angeles"
      },
      "secrets": {
        "Qui sint earum cum nam voluptatum nihil.": "Voluptatem est nemo nisi.",
        "Sequi eos sunt.": "Fuga quisquam distinctio nostrum rerum debitis ut."
      }
    },
    "createdAtTime": "2021-01-01T00:00:00Z",
    "description": "Processes incoming telemetry data.",
    "effects": {
      "nextScheduledAtTime": "2021-01-01T00:00:00Z"
    },
    "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.