curl --request POST \
--url https://api.cnap.tech/v1/snippets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Cluster Resource Audit",
"code": "<string>",
"display_type": "table",
"description": "<string>"
}
'{
"snippet_id": "<string>"
}Creates a reusable code snippet in the workspace. Snippets are async JavaScript functions executed in a sandboxed V8 isolate with access to cnap.request() for API calls.
curl --request POST \
--url https://api.cnap.tech/v1/snippets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Cluster Resource Audit",
"code": "<string>",
"display_type": "table",
"description": "<string>"
}
'{
"snippet_id": "<string>"
}Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at https://cnap.tech/account/tokens
1 - 100"Cluster Resource Audit"
Async JavaScript function body. Executed in a sandboxed V8 isolate with access to cnap.request().
1 - 50000Controls how the snippet result is rendered in dashboard widgets
table, stat, json, logs Optional human-readable description
500Snippet created