Skip to main content
Data exports allow you to download your messaging data in bulk for analysis, compliance audits, or backup purposes. Export links are valid for 24 hours after generation.

Exportable Data Types

Data TypeDescription
messagesAll sent and received messages with delivery status
conversationsConversation threads grouped by contact
webhookDeliveriesWebhook delivery attempts and responses
agentExecutionsAI agent execution logs and responses
activitiesAccount activity and audit logs

Creating an Export

import Zavudev from '@zavudev/sdk';

const zavu = new Zavudev();

const exportJob = await zavu.exports.create({
  dataTypes: ["messages", "conversations"],
  dateFrom: "2024-01-01T00:00:00Z",
  dateTo: "2024-12-31T23:59:59Z",
});

console.log(`Export ID: ${exportJob.id}`);
console.log(`Status: ${exportJob.status}`); // "pending"

Response

{
  "export": {
    "id": "exp_abc123",
    "status": "pending",
    "dataTypes": ["messages", "conversations"],
    "dateFrom": "2024-01-01T00:00:00.000Z",
    "dateTo": "2024-12-31T23:59:59.000Z",
    "expiresAt": "2024-01-16T10:30:00.000Z",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
}

Export Status

StatusDescription
pendingExport job created, waiting to be processed
processingExport is being generated
completedExport ready for download
failedExport failed (check errorMessage)

Checking Export Status

Exports are processed asynchronously. Poll the status until it’s completed:
async function waitForExport(exportId: string) {
  let exportJob;

  do {
    await new Promise(r => setTimeout(r, 5000)); // Wait 5 seconds
    exportJob = await zavu.exports.get(exportId);
    console.log(`Status: ${exportJob.status}`);
  } while (exportJob.status === "pending" || exportJob.status === "processing");

  if (exportJob.status === "completed") {
    console.log(`Download URL: ${exportJob.downloadUrl}`);
    console.log(`File size: ${exportJob.fileSize} bytes`);
  } else {
    console.error(`Export failed: ${exportJob.errorMessage}`);
  }

  return exportJob;
}

Completed Export Response

{
  "export": {
    "id": "exp_abc123",
    "status": "completed",
    "dataTypes": ["messages", "conversations"],
    "dateFrom": "2024-01-01T00:00:00.000Z",
    "dateTo": "2024-12-31T23:59:59.000Z",
    "downloadUrl": "https://storage.zavu.dev/exports/exp_abc123.zip?token=...",
    "fileSize": 1048576,
    "expiresAt": "2024-01-16T10:30:00.000Z",
    "completedAt": "2024-01-15T10:32:00.000Z",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
}

Downloading the Export

Once the export is complete, download the file using the downloadUrl:
import { writeFile } from 'fs/promises';

const exportJob = await zavu.exports.get(exportId);

if (exportJob.downloadUrl) {
  const response = await fetch(exportJob.downloadUrl);
  const buffer = await response.arrayBuffer();
  await writeFile('export.zip', Buffer.from(buffer));
  console.log('Export downloaded successfully!');
}
Download URLs expire 24 hours after the export is created. After expiration, you’ll need to create a new export.

Listing Exports

const { items, nextCursor } = await zavu.exports.list({
  status: "completed",
  limit: 50,
});

for (const exportJob of items) {
  console.log(`${exportJob.id}: ${exportJob.status}`);
}

Export File Format

Exports are delivered as a ZIP file containing JSON files for each data type:
export_exp_abc123.zip
├── messages.json
├── conversations.json
└── metadata.json
Each JSON file contains an array of records:
// messages.json
[
  {
    "id": "msg_abc123",
    "to": "+14155551234",
    "from": "+13125551212",
    "channel": "sms",
    "status": "delivered",
    "text": "Your order has shipped!",
    "createdAt": "2024-01-15T10:30:00.000Z"
  }
]

Date Range Filtering

Use dateFrom and dateTo to export data from a specific time period:
// Export last 30 days
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

const exportJob = await zavu.exports.create({
  dataTypes: ["messages"],
  dateFrom: thirtyDaysAgo.toISOString(),
  dateTo: new Date().toISOString(),
});
If you omit date filters, the export includes all available data. For large datasets, consider filtering by date to reduce export time.

Use Cases

Compliance Audits

Export message logs for regulatory compliance (GDPR, HIPAA, etc.)

Analytics

Analyze messaging patterns and delivery rates in your BI tools

Backup

Create regular backups of your messaging history

Migration

Export data when switching platforms or archiving projects

Rate Limits

LimitValue
Concurrent exports3 per project
Export requests10 per hour
Data retentionBased on your plan (see Data Retention)

Complete Example

import Zavudev from '@zavudev/sdk';
import { writeFile } from 'fs/promises';

const zavu = new Zavudev();

async function exportMessagingData() {
  // 1. Create the export
  const exportJob = await zavu.exports.create({
    dataTypes: ["messages", "conversations", "webhookDeliveries"],
    dateFrom: "2024-01-01T00:00:00Z",
    dateTo: "2024-12-31T23:59:59Z",
  });

  console.log(`Export created: ${exportJob.id}`);

  // 2. Wait for completion
  let status = exportJob.status;
  while (status === "pending" || status === "processing") {
    await new Promise(r => setTimeout(r, 5000));
    const updated = await zavu.exports.get(exportJob.id);
    status = updated.status;
    console.log(`Status: ${status}`);
  }

  // 3. Download if successful
  const completed = await zavu.exports.get(exportJob.id);

  if (completed.status === "completed" && completed.downloadUrl) {
    const response = await fetch(completed.downloadUrl);
    const buffer = await response.arrayBuffer();
    await writeFile(`export_${exportJob.id}.zip`, Buffer.from(buffer));
    console.log(`Downloaded: export_${exportJob.id}.zip (${completed.fileSize} bytes)`);
  } else {
    console.error(`Export failed: ${completed.errorMessage}`);
  }
}

exportMessagingData();