KasarKasar Docs
API Reference

Import / Export

Import records in batch and export data as CSV or JSON. Admin-only endpoints for data management.

The import and export endpoints allow administrators to move data in and out of Kasar in bulk. Both endpoints require admin privileges.

Import Records

POST /api/v1/import/{object}

Batch import records into an object. Pipeline defaults are automatically applied for objects with a pipeline. Duplicate detection runs on each record and duplicates are counted separately from created records.

This endpoint is restricted to admin users. Non-admin tokens receive a 403 error.

Path Parameters

ParameterTypeDescription
objectstringThe object to import into (e.g. contacts, companies)

Request Body

{
  "records": [
    {
      "first_name": "Alice",
      "last_name": "Martin",
      "email": "alice@example.com",
      "company_name": "Acme Corp"
    },
    {
      "first_name": "Bob",
      "last_name": "Dupont",
      "email": "bob@startup.io"
    }
  ]
}
FieldTypeDescription
recordsobject[]Array of records to import. Each record is a key-value map matching the object's field names.

Limits

  • Batch size: 50 records per request
  • Max duration: 300 seconds (5 minutes)

Example Request

curl -X POST "https://kasar.app/api/v1/import/contacts" \
  -H "Authorization: Bearer ksr_a1b2c3d4e5f6..." \
  -H "Content-Type: application/json" \
  -d '{
    "records": [
      {
        "first_name": "Alice",
        "last_name": "Martin",
        "email": "alice@example.com"
      },
      {
        "first_name": "Bob",
        "last_name": "Dupont",
        "email": "bob@startup.io"
      }
    ]
  }'

Response

{
  "object_name": "contacts",
  "created": 1,
  "duplicates": 1,
  "failed": 0,
  "errors": []
}
FieldTypeDescription
object_namestringThe object that was imported into
createdintegerNumber of records successfully created
duplicatesintegerNumber of records skipped as duplicates
failedintegerNumber of records that failed validation
errorsobject[]Details for each failed record (index, code, message)

Duplicate Detection

During import, each record is checked against existing data using email, phone, and name matching. Duplicates are not created; they are counted in the duplicates field.

Error Example

When some records fail validation:

{
  "object_name": "contacts",
  "created": 1,
  "duplicates": 0,
  "failed": 1,
  "errors": [
    {
      "index": 1,
      "code": "VALIDATION_ERROR",
      "message": "Field 'email' must be a valid email address"
    }
  ]
}

Export Records

GET /api/v1/export/{object}

Export records from an object as JSON or CSV. Supports filtering, sorting, and field selection.

This endpoint is restricted to admin users. Non-admin tokens receive a 403 error.

Path Parameters

ParameterTypeDescription
objectstringThe object to export (e.g. contacts, companies)

Query Parameters

ParameterTypeDefaultDescription
formatstringjsonExport format: json or csv
fieldsstringall fieldsComma-separated list of field names to include
filter_fieldstringField name to filter on
filter_operatorstringFilter operator (e.g. eq, contains, gte)
filter_valuestringFilter value
filtersstringAdvanced filters as a JSON-encoded FilterGroup object
sort_bystringcreated_atField to sort by
sort_dirstringdescSort direction: asc or desc
limitinteger1000Maximum records to export (max 10000). The MCP crm_export tool uses a default of 500; this REST endpoint defaults to 1000.

Example: Export as JSON

curl -X GET "https://kasar.app/api/v1/export/contacts?format=json&fields=first_name,last_name,email&limit=500" \
  -H "Authorization: Bearer ksr_a1b2c3d4e5f6..."

Response:

{
  "format": "json",
  "records": [
    {
      "first_name": "Alice",
      "last_name": "Martin",
      "email": "alice@example.com"
    },
    {
      "first_name": "Bob",
      "last_name": "Dupont",
      "email": "bob@startup.io"
    }
  ],
  "total": 2
}

Example: Export as CSV

curl -X GET "https://kasar.app/api/v1/export/contacts?format=csv&fields=first_name,last_name,email" \
  -H "Authorization: Bearer ksr_a1b2c3d4e5f6..." \
  -o contacts.csv

The CSV response returns:

  • Content-Type: text/csv
  • Content-Disposition: attachment; filename="contacts_export.csv"

Example: Export with Filters

curl -X GET "https://kasar.app/api/v1/export/contacts?format=json&filter_field=status&filter_operator=eq&filter_value=qualified&sort_by=last_name&sort_dir=asc" \
  -H "Authorization: Bearer ksr_a1b2c3d4e5f6..."

For complex filters, use the filters parameter with a JSON-encoded FilterGroup:

curl -G "https://kasar.app/api/v1/export/contacts" \
  -H "Authorization: Bearer ksr_a1b2c3d4e5f6..." \
  --data-urlencode 'format=json' \
  --data-urlencode 'filters={"operator":"and","conditions":[{"field":"status","operator":"eq","value":"qualified"},{"field":"created_at","operator":"gte","value":"2025-01-01"}]}'

Error Responses

StatusCodeDescription
400INVALID_OBJECTThe object name does not exist
400VALIDATION_ERRORInvalid format, filter, or field name
403PERMISSION_DENIEDToken does not belong to an admin user

On this page