Batch exports: schedule events, persons, sessions and groups to your warehouse

Create, run, backfill and monitor scheduled exports to S3, GCS, Azure, Postgres, Snowflake, BigQuery, Redshift and Databricks with the API, the CLI or the app, and the exact permissions each destination needs.

Embed
Preview of the card
<a href="https://lucidace.com/help/batch-exports"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/53b50d06-270e-4489-ad13-7bc0755abe89/social-card.svg?v=3e7ae33eec8b" alt="Batch exports: schedule events, persons, sessions and groups to your warehouse" width="600" height="315"></a>

A batch export is a schedule: every interval_secs Lucida writes the next window of one stream to your storage and, for a warehouse, loads it. Streams are events, persons, sessions and groups (plus query, source_rows and replays described in the API reference). Delivery is at-least-once: a window can be written twice after a retry, so de-duplicate by uuid (events), upsert by version (persons, groups) or use session_id (sessions). Persons and groups are exported again whenever they change.

Credentials are write-only. They are sealed when you save the schedule and are never returned, logged or shown again; to rotate one, delete and recreate the schedule.

The API

Everything is under /v1/projects/{project_id}/export-schedules. Reads need the connector:read scope, every other call connector:write.

Call

What it does

POST /export-schedules

Create. Body: name, stream, format (jsonl.gz or parquet), destination, optional warehouse, interval_secs, chunk_secs, options, credentials.

GET /export-schedules

List, ?limit=&cursor= returns {data, next_cursor}.

GET, PATCH, DELETE /export-schedules/{id}

Read, change name, interval_secs or enabled, delete.

POST /export-schedules/test

Check a destination and its credentials without saving (writes and removes a probe object). 200 with {ok: true, key} when it works; when the destination refuses the probe the answer is a 422 problem with the destination's error as detail.

POST /export-schedules/{id}/pause, /resume

Stop and restart the schedule.

POST /export-schedules/{id}/run

Run the next window now (202). The schedule must be enabled.

POST /export-schedules/{id}/backfills

Export [start_at, end_at) (end_at is capped at now; more than 366 days, or more than 366 intervals, is a 400). One run is queued per schedule interval (an 8-day range on a daily schedule queues 8 runs); the response is the first run with every run listed under runs. A window with no rows finishes at once. Backfills never move the schedule position.

GET /export-schedules/{id}/runs

Runs with status, rows, files, bytes, error; filter ?kind=scheduled|backfill|retry.

POST /export-schedules/{id}/runs/{run_id}/retry, /cancel

Retry a failed run, cancel a queued or running one.

Failure alerts

A schedule whose last attempt failed shows as export_failing in pipeline health (GET /pipeline-health, and the Pipeline health page), carrying the error text. Turn on pipeline alerts under Pipeline health settings to get it by email, Slack or webhook. A schedule that is silently behind shows as export_behind.

Definitions as code

lucida pull and lucida apply manage schedules as lucida/export-schedules/<name>.yaml:

name: events-to-snowflake
stream: events
format: parquet
interval_secs: 3600
destination: { kind: s3, endpoint: https://s3.us-east-1.amazonaws.com, bucket: my-exports, region: us-east-1, prefix: lucida }
warehouse:
  kind: snowflake
  params: { account: xy12345.us-east-1, user: LUCIDA, database: ANALYTICS, schema: RAW, table: EVENTS, stage: LUCIDA_EXPORTS }
credentials:                       # references only: a literal value is refused
  dest: { access_key: "env:EXPORT_S3_ACCESS_KEY", secret_key: "env:EXPORT_S3_SECRET_KEY" }
  warehouse: { private_key: "env:EXPORT_SNOWFLAKE_KEY" }
enabled: true

Every env:NAME is read from the environment of the machine running lucida apply when the schedule is created. After creation only name, interval_secs and enabled change in place; changing the stream, format, destination, warehouse or options means deleting the file's schedule (lucida prune --yes) and applying again. Pulled files never contain credentials.

Permissions per destination

Lucida only needs what is listed here.

S3 (and S3-compatible storage)

Credentials: access_key and secret_key (optionally session_token), or a role_arn in the destination that Lucida's AWS identity assumes (add external_id). The principal needs s3:PutObject on arn:aws:s3:::BUCKET/PREFIX/*. With sse: aws:kms it also needs kms:GenerateDataKey and kms:Decrypt on the key. Large files use multipart upload, so add s3:AbortMultipartUpload. No list or read access is needed.

Google Cloud Storage

Credential: a service_account_json (or a short-lived access_token). The service account needs storage.objects.create on the bucket (role Storage Object Creator).

Azure Blob Storage

Credential: a sas_token for the container with Create and Write permissions.

Postgres

Credential: dsn. The destination takes a [schema.]table, jsonl.gz and the events, persons or source_rows streams. The role needs CREATE on the schema for the first run (the table is created on first use), then INSERT and UPDATE on the table (persons upsert by version). tls_mode is require, verify-ca or verify-full. Groups and sessions are not written to Postgres directly: use a bucket and a warehouse.

Snowflake

Lucida writes files to a bucket and runs COPY INTO through the SQL API. You create the external stage and the table. Params: account, database, schema, table, stage (plus optional warehouse, role, stage_prefix).

  • Stage: an external stage over the export bucket, with a storage integration that can read it.

  • Credential: a key pair (private_key, optional private_key_passphrase, with params.user) or a programmatic access token (token_type: PROGRAMMATIC_ACCESS_TOKEN) or OAuth token. Passwords are not supported.

  • Grants for that user or role: USAGE on the database, schema, warehouse and stage (and READ on the stage), INSERT on the table.

BigQuery

Load jobs read files from a GCS bucket, so the destination is gcs. Params: project, dataset, table (optional partition_type).

  • Credential: service_account_json (or access_token); params.impersonate names a service account to act as.

  • Roles: BigQuery Job User on the project, BigQuery Data Editor on the dataset, and Storage Object Viewer on the bucket for the BigQuery service identity.

Redshift

Lucida issues COPY through the Redshift Data API. Params: region, database, schema_table, iam_role (the role Redshift assumes to read the bucket) and either cluster (plus db_user) or workgroup.

  • Credential: access_key and secret_key, or params.role_arn (and external_id) that Lucida's AWS identity assumes.

  • Caller permissions: redshift-data:ExecuteStatement, DescribeStatement, and redshift:GetClusterCredentials (provisioned) or redshift-serverless:GetCredentials (serverless).

  • iam_role needs s3:GetObject and s3:ListBucket on the bucket and must be attached to the cluster. The database user needs INSERT on the table.

Databricks

Lucida runs COPY INTO through the SQL Statement Execution API. Params: host, warehouse_id, table (catalog.schema.table, created by you), optional json_type (string or variant) and uri_scheme.

  • Credential: a personal access_token, or a service principal client_id and client_secret (OAuth M2M).

  • Grants: CAN USE on the SQL warehouse, USE CATALOG, USE SCHEMA and MODIFY on the table, and read access to the bucket through an external location or storage credential.

Updated