Snippets

Snippets are reusable text blocks scoped to the organization, typically used for message composition.

All endpoints require authentication via the X-API-Key header. See Authentication.


Create a snippet

POST /snippets

Request body

FieldTypeRequiredNotes
namestringYesNon-empty.
valuestringYesNon-empty.

Example request

curl -X POST https://<host>/api/snippets \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Greeting",
    "value": "Hey {{firstName}}, hope you are doing well!"
  }'

Response

{
  "success": true,
  "data": {
    "_id": "675a...",
    "name": "Greeting",
    "value": "Hey {{firstName}}, hope you are doing well!",
    "createdAt": 1716000000000
  }
}

Errors

StatusMessageCause
400Validation errorMissing or empty name or value.

List snippets

GET /snippets

Returns snippets sorted by name ascending.

Query parameters

ParameterTypeDefaultNotes
pagenumber00-indexed.
perPagenumber50Items per page.

Example request

curl "https://<host>/api/snippets?page=0&perPage=25" \
  -H "X-API-Key: your-api-key"

Response

{
  "success": true,
  "data": [
    {
      "_id": "675a...",
      "name": "Greeting",
      "value": "Hey {{firstName}}, hope you are doing well!",
      "createdAt": 1716000000000
    }
  ],
  "pagination": {
    "page": 0,
    "perPage": 25,
    "totalItems": 8,
    "totalPages": 1
  }
}

Update a snippet

PUT /snippets/:id

Path parameters

ParameterTypeDescription
idstringSnippet ID.

Request body

FieldTypeRequiredNotes
namestringNoNon-empty if provided.
valuestringNoNon-empty if provided.

Example request

curl -X PUT https://<host>/api/snippets/675a... \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{ "value": "Hi {{firstName}}, great to connect!" }'

Response

{
  "success": true,
  "data": {
    "value": "Hi {{firstName}}, great to connect!"
  }
}

Errors

StatusMessageCause
404Not foundSnippet does not exist.

Delete a snippet

DELETE /snippets/:id

Path parameters

ParameterTypeDescription
idstringSnippet ID.

Example request

curl -X DELETE https://<host>/api/snippets/675a... \
  -H "X-API-Key: your-api-key"

Response

{
  "success": true,
  "message": "Success"
}

Errors

StatusMessageCause
404Not foundSnippet does not exist.

Response envelope

All endpoints use the standard envelope:

{
  "error": false,
  "success": true,
  "message": "...",
  "code": 200,
  "data": "...",
  "pagination": {}
}

Error responses:

{
  "error": true,
  "success": false,
  "message": "...",
  "code": 400,
  "data": null
}

data is null for a general failure, such as a database error or an upstream timeout. When the request is rejected because of a specific field, data carries the field(s) at fault instead:

{
  "error": true,
  "success": false,
  "message": "phone: Phone parse failed: The string supplied did not seem to be a phone number (input: <masked>)",
  "code": 400,
  "data": {
    "issues": [
      {
        "path": "phone",
        "message": "Phone parse failed: The string supplied did not seem to be a phone number (input: <masked>)"
      }
    ]
  }
}

Each issue carries a path (the dotted path into the request body) and a message. A label is added when the path is not self-describing, which today means custom fields only, for example "path": "fields.68b0a1f39c2e4d0012ab77e5", "label": "Class Year". issues is an array, but treat it as holding at most one entry: validation stops at the first failure.

On this page