Skip to main content
Use this endpoint to trigger an asynchronous export of clinical data in NDJSON (newline-delimited JSON) format. You specify one or more FHIR resource types and an optional since timestamp to export only records created or updated after a given point. The response returns a jobId immediately; use the job status endpoint to poll for completion and retrieve the pre-signed download URL.

Request

POST https://api.clinikapi.com/v1/bulk/export

Headers

x-api-key
string
required
Your ClinikAPI secret key (clk_live_* or clk_test_*).
Content-Type
string
required
Must be application/json.

Body

resourceTypes
string[]
required
Array of FHIR resource type names to export (e.g. ["Patient", "Encounter", "Observation"]). All tenant data for each type is included unless since is specified.
since
string
ISO 8601 timestamp. When provided, only records created or updated on or after this time are included (e.g. "2025-01-01T00:00:00Z").

Response

Returns 202 Accepted immediately. The export job runs asynchronously.
data.jobId
string
Unique job identifier (e.g. job_abc123). Use this to poll for status and retrieve the download URL.
data.status
string
Initial job status. Always pending at the time of creation.
data.message
string
Human-readable confirmation message (e.g. "Export job started").
meta
object
Standard response metadata including requestId, timestamp, status, and rate-limit fields.

Examples

curl

curl -X POST https://api.clinikapi.com/v1/bulk/export \
  -H "x-api-key: clk_live_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceTypes": ["Patient", "Encounter", "Observation"],
    "since": "2025-01-01T00:00:00Z"
  }'
{
  "data": {
    "jobId": "job_abc123",
    "status": "pending",
    "message": "Export job started"
  }
}

TypeScript SDK

import { Clinik } from '@clinikapi/sdk';

const clinik = new Clinik(process.env.CLINIKAPI_SECRET_KEY!);

const { data } = await clinik.bulk.export({
  resourceTypes: ['Patient', 'Encounter', 'Observation'],
  since: '2025-01-01T00:00:00Z',
});

console.log(data.jobId); // "job_abc123"

// Poll until complete
let job;
do {
  await new Promise(r => setTimeout(r, 2000));
  ({ data: job } = await clinik.bulk.getJob(data.jobId));
} while (job.status === 'pending' || job.status === 'processing');

console.log(job.downloadUrl); // pre-signed S3 URL valid for 1 hour