Skip to content
AISARAISAR
REST API

Snippets

Snippets (quick replies) are pre-written text blurbs, optionally with attached files, that the company prepares so an operator can insert them into a chat in one action instead of typing. This group manages the company's snippet library: list, create, update, delete, and download attached files.

Vs message templates

Unlike message templates, snippets are not moderated by the provider and can only be used inside an already-open 24-hour messaging window.

Request format and form fields

Create/update use multipart/form-data since they support file uploads. Form fields:

  • name (required, up to 255 characters).
  • message (required).
  • files[] (optional, up to 50 MB per file).

Updating attachments

On update, new files are appended via files[], and already-attached ones are removed by passing their ids in remove_file_ids[].

Endpoints

MethodPath
GET/v1/snippets

List the company's snippets.

POST/v1/snippets

Create a snippet (multipart/form-data, files optional, up to 50 MB each).

POST/v1/snippets/{snippet}

Update a snippet — text, add/remove files (multipart/form-data).

DELETE/v1/snippets/{snippet}

Delete a snippet.

GET/v1/snippets/{snippet}/files/{snippetFile}/download

Download a file attached to a snippet (via a signed URL).

Examples

Create a snippet

Request

bash
curl -X POST "https://api.aisar.app/v1/snippets" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "name=Приветствие" \
  -F "message=Здравствуйте! Чем можем помочь?" \
  -F "files[]=@/path/to/price-list.pdf"

Response

json
{
  "data": {
    "id": 9,
    "company_id": 1,
    "name": "Приветствие",
    "message": "Здравствуйте! Чем можем помочь?",
    "files": [
      {
        "id": 21,
        "name": "price-list.pdf",
        "size": 48213,
        "type": "application/pdf",
        "download_url": "https://api.aisar.app/v1/snippets/9/files/21/download?expires=...&signature=..."
      }
    ],
    "updated_at": "2026-02-09T18:00:00Z"
  }
}

List snippets

Request

bash
curl -X GET "https://api.aisar.app/v1/snippets" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "data": [
    {
      "id": 9,
      "company_id": 1,
      "name": "Приветствие",
      "message": "Здравствуйте! Чем можем помочь?",
      "files": [],
      "updated_at": "2026-02-09T18:00:00Z"
    }
  ]
}

Update: replacing an attachment via remove_file_ids

Request

bash
curl -X POST "https://api.aisar.app/v1/snippets/9" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "name=Приветствие (обновлённое)" \
  -F "message=Здравствуйте! Рады помочь." \
  -F "files[]=@/path/to/catalog.pdf" \
  -F "remove_file_ids[]=21"

Response

json
{
  "data": {
    "id": 9,
    "company_id": 1,
    "name": "Приветствие (обновлённое)",
    "message": "Здравствуйте! Рады помочь.",
    "files": [
      {
        "id": 22,
        "name": "catalog.pdf",
        "size": 102400,
        "type": "application/pdf",
        "download_url": "https://api.aisar.app/v1/snippets/9/files/22/download?expires=...&signature=..."
      }
    ],
    "updated_at": "2026-02-10T09:30:00Z"
  }
}