Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates

On this page

HTTP API Reference
Overview

  • Content Lake API

    Actions
    Assets
    Copy
    Backups
    Doc
    Export
    History
    Jobs
    Listen
    Live
    Mutation
    Query
    Scheduling
    Webhooks

  • Compute and AI

    Agent Actions
    Embeddings Index

  • Apps

    Media Library

  • Management API

    Access
    Projects
    Roles

On this page

  • Authentication
Endpoints
  • Export documents in a dataset
HTTP API ReferenceLast updated January 9, 2026

Export API reference

  • Article
  • Changelog

Reference documentation for the export HTTP endpoint.

The Export API allows you to export all the non-deleted documents in a dataset, including drafts and asset documents.

Authentication

  • All requests must be authenticated.

Base API server URL

Sanity project base URL

https://{projectId}.api.sanity.io/{apiVersion}

Variables

  • projectIdstringdefault: "your-project-id"

    Sanity project ID

  • apiVersionstringdefault: "v2021-03-25"

    API version

Previous

Doc

Next

History

Endpoints

Export documents in a dataset

get/data/export/{dataset}

The Export API allows you to export all the non-deleted documents in a dataset, including drafts and asset documents.

By default, this endpoint returns all the documents a user can access as an NDJSON stream. The documents will be in the state they were when the request was made and will not be affected by any changes in the dataset that happened after the request was made. In most cases, you probably want to use the CLI tool's export functionality or the JavaScript npm package. Those have built-in features such as asset downloads and an option for including drafts.

Cursor mode for large datasets

For datasets with many documents (typically tens of thousands), you can experience that network or other instabilities cause the export stream to time out or be interrupted. In these cases, you can send a request a nextCursor query parameter set to an empty string. This will cause the export to run for 30 seconds and end with an object with a nextCursor key and value. The cursor is an encoded representation of a position in an ordered document list of the dataset.

You can initiate a new export request with this value as the nextQuery parameter value to continue the export manually. Note that any changes made between requests in "cursor mode" will be reflected in the export, which can lead to inconsistencies, for example, if references have been changed in the dataset.

Tip: An unauthenticated request will only return publicly available documents. If you include an authentication token, it will consist of documents that this token can access (for example, drafts and system documents).

Path parameters

  • datasetstringrequired

Query parameters

  • typesstring
  • nextCursorstring

Responses

200

Returns an NDJSON stream of documents.

  • string (binary)

    A stream of documents in NDJSON format.

    Example:{"_id":"doc-5","_type":"counter","count":10} {"_id":"doc-6","_type":"counter","count":11} {"nextCursor":"taZ9fp"}