Skip to main content
Some Layer reports are too large or expensive to generate in a single synchronous request. For those, Layer uses an async export workflow:
  1. Submit a report generation request
  2. Poll the export status (or wait for a webhook)
  3. Download the completed file
Today, Create billing report export is the first report that uses this pattern. Additional report types will reuse the same Exports polling endpoints.

Prerequisites

  • An active Layer account and API credentials
  • A valid access token (see Initial Setup)
  • Optional: a webhook endpoint configured to receive export.completed and export.failed (see Webhooks)

Workflow

1

Submit the report request

Call the report-specific creation endpoint. For billing reports:
Layer responds with 202 Accepted and an Export resource:
Save the export id. You will use it to poll for completion.
2

Poll for status

Call Fetch export until status is completed or failed:
Status values:You can also list recent exports with List exports.
3

Download the file

When status is completed, download the artifact from download_url. The URL is a short-lived presigned link.
Use file_name from the export response when saving the file locally.

Prefer webhooks instead of polling

If you do not want to poll, subscribe to export lifecycle webhooks in the Layer developer portal:
  • export.completed — the export finished successfully
  • export.failed — the export failed
These events are client-scoped: the payload includes id, type, and data, and does not include top-level business_id / business_external_id fields used by business-scoped webhooks. Example export.completed payload:
After receiving export.completed, call Fetch export to retrieve the download_url. See Webhooks for endpoint setup and signature verification, and the Event Catalog for the full list of event types.