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
| Parameter | Type | Description |
|---|---|---|
object | string | The 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"
}
]
}| Field | Type | Description |
|---|---|---|
records | object[] | 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": []
}| Field | Type | Description |
|---|---|---|
object_name | string | The object that was imported into |
created | integer | Number of records successfully created |
duplicates | integer | Number of records skipped as duplicates |
failed | integer | Number of records that failed validation |
errors | object[] | 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
| Parameter | Type | Description |
|---|---|---|
object | string | The object to export (e.g. contacts, companies) |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
format | string | json | Export format: json or csv |
fields | string | all fields | Comma-separated list of field names to include |
filter_field | string | Field name to filter on | |
filter_operator | string | Filter operator (e.g. eq, contains, gte) | |
filter_value | string | Filter value | |
filters | string | Advanced filters as a JSON-encoded FilterGroup object | |
sort_by | string | created_at | Field to sort by |
sort_dir | string | desc | Sort direction: asc or desc |
limit | integer | 1000 | Maximum 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.csvThe CSV response returns:
Content-Type: text/csvContent-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
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_OBJECT | The object name does not exist |
| 400 | VALIDATION_ERROR | Invalid format, filter, or field name |
| 403 | PERMISSION_DENIED | Token does not belong to an admin user |