Skip to main content
POST
/
v1
/
snippets
Create snippet
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>"
}

Authorizations

Authorization
string
header
required

Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at https://cnap.tech/account/tokens

Body

application/json
name
string
required
Required string length: 1 - 100
Example:

"Cluster Resource Audit"

code
string
required

Async JavaScript function body. Executed in a sandboxed V8 isolate with access to cnap.request().

Required string length: 1 - 50000
display_type
enum<string>
required

Controls how the snippet result is rendered in dashboard widgets

Available options:
table,
stat,
json,
logs
description
string

Optional human-readable description

Maximum string length: 500

Response

Snippet created

snippet_id
string
required