PUT
/
v1
/
snippets
/
{id}
Update a snippet
curl --request PUT \
  --url https://api.checklyhq.com/v1/snippets/{id} \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Snippet",
  "script": "request.url = request.url + '\''/extra'\''"
}'
{
  "id": 1,
  "name": "Snippet",
  "script": "request.url = request.url + '/extra'",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z"
}

Overview

The Update Snippet endpoint allows you to modify existing code snippets, including their source code, descriptions, and metadata. Changes to snippets affect all checks that reference them. Common Use Cases:
  • Code Maintenance
  • Function Updates
  • Bug Fixes
  • Feature Enhancements
Updating snippets affects all checks that reference them. Ensure proper testing before making changes to snippets used in production monitoring.
Changes to snippets propagate immediately to all referencing checks. Consider the impact on active monitoring when updating shared code.

Authorizations

Authorization
string
header
required

The Checkly Public API uses API keys to authenticate requests. You can get the API Key here.

Your API key is like a password: keep it secure!

Authentication to the API is performed using the Bearer auth method in the Authorization header and using the account ID.

For example, set Authorization header while using cURL:

curl -H "Authorization: Bearer [apiKey]" "X-Checkly-Account: [accountId]"

Headers

x-checkly-account
string

Your Checkly account ID, you can find it at https://app.checklyhq.com/settings/account/general

Path Parameters

id
integer
required

Body

application/json
name
string
required

The snippet name.

Example:

"Snippet"

script
string
required

Your Node.js code that interacts with the API check lifecycle, or functions as a partial for browser checks.

Example:

"request.url = request.url + '/extra'"

Response

Successful

id
number
Example:

1

name
string

The snippet name.

Example:

"Snippet"

script
string

Your Node.js code that interacts with the API check lifecycle, or functions as a partial for browser checks.

Example:

"request.url = request.url + '/extra'"

created_at
string<date-time>
updated_at
string<date-time>