Skip to content
AISARAISAR
REST API

Exports

Asynchronous export of company data — contacts, messages, or segments — to CSV, XLSX, or JSON. Creating queues a background job and immediately returns the export object in the pending status, and the finished file is downloaded from a separate endpoint. The whole group is available on the Business plan only.

Access and permissions

The whole group is available on the Business plan only (the feature:exports middleware): without the feature every request returns 403 { "error": "feature_not_available", "feature": "exports", "required_plan": "business" }. Reading (GET /exports, GET /exports/{id}) requires the export.view permission and creating (POST /exports) requires export.create. Listing supports pagination (page ≥ 1, perPage 5–100, default 20).

Export lifecycle

Creating queues a background job and immediately returns the export object in pending status (lifecycle pending → processing → completed/failed); readiness is polled via GET /exports/{id}, and the file is downloaded from GET /exports/{id}/download — while status != completed this endpoint returns 404. The download_url link only appears once the status is completed and points to that same download endpoint.

Create body and filters

In the create body type and format are required; the optional filters object narrows the selection with account_type, segment_id, segment_ids[], date_from, date_to, channel_id, direction (inbound/outbound), conversation_id, and group_chat_id.

Daily limits

Per-company daily limits apply: at most 20 exports of any type per day and at most 5 exports of the messages type; exceeding either returns 422 with the error on the type field.

Endpoints

MethodPath
GET/v1/exports

List exports

POST/v1/exports

Create an export

GET/v1/exports/{export}

Get an export (status, size, row count)

GET/v1/exports/{export}/download

Download the finished export file

DELETE/v1/exports/{export}

Delete an export

Examples

Create a contacts export

Request

bash
curl -X POST https://api.aisar.app/v1/exports \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "contacts",
    "format": "csv",
    "filters": { "segment_id": 12 }
  }'

Response

json
{
  "data": {
    "message": "Export started.",
    "export": {
      "id": 301,
      "uuid": "9f1c2e40-6b3a-4e9e-9d2a-1f7a8c0b5d21",
      "type": "contacts",
      "name": "Contacts export",
      "format": "csv",
      "status": "pending",
      "filters": { "segment_id": 12 },
      "row_count": null,
      "file_size": null,
      "error_message": null,
      "download_url": null,
      "expires_at": "2026-03-22T10:00:00.000000Z",
      "created_at": "2026-03-15T10:00:00.000000Z",
      "updated_at": "2026-03-15T10:00:00.000000Z"
    }
  }
}

Export messages with filters

Request

bash
curl -X POST https://api.aisar.app/v1/exports \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "messages",
    "format": "xlsx",
    "filters": {
      "channel_id": 7,
      "direction": "inbound",
      "date_from": "2026-03-01",
      "date_to": "2026-03-15"
    }
  }'

Response

json
{
  "data": {
    "message": "Export started.",
    "export": {
      "id": 302,
      "uuid": "3b8f1a20-7c4d-4a1e-8f6b-2e9c0d3a5b74",
      "type": "messages",
      "name": "Messages export",
      "format": "xlsx",
      "status": "pending",
      "filters": {
        "channel_id": 7,
        "direction": "inbound",
        "date_from": "2026-03-01",
        "date_to": "2026-03-15"
      },
      "row_count": null,
      "file_size": null,
      "error_message": null,
      "download_url": null,
      "expires_at": "2026-03-22T10:05:00.000000Z",
      "created_at": "2026-03-15T10:05:00.000000Z",
      "updated_at": "2026-03-15T10:05:00.000000Z"
    }
  }
}

Poll export status

Request

bash
curl https://api.aisar.app/v1/exports/301 \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

json
{
  "data": {
    "export": {
      "id": 301,
      "uuid": "9f1c2e40-6b3a-4e9e-9d2a-1f7a8c0b5d21",
      "type": "contacts",
      "name": "Contacts export",
      "format": "csv",
      "status": "completed",
      "filters": { "segment_id": 12 },
      "row_count": 340,
      "file_size": 48213,
      "error_message": null,
      "download_url": "https://api.aisar.app/v1/exports/301/download",
      "expires_at": "2026-03-22T10:00:00.000000Z",
      "created_at": "2026-03-15T10:00:00.000000Z",
      "updated_at": "2026-03-15T10:02:31.000000Z"
    }
  }
}

Exports not available on the current plan (403)

Request

bash
curl -X POST https://api.aisar.app/v1/exports \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "type": "contacts", "format": "csv" }'

Response

json
{
  "data": {
    "message": "Feature not available on your plan.",
    "error": "feature_not_available",
    "feature": "exports",
    "required_plan": "business"
  }
}