🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Backups

Interact with your backups via the HTTP API

Enable or disable backups

PUT /v2024-02-21/projects/:id/datasets/:name/settings/backups

Query parameters

  • REQUIREDenabledboolean

    Enable or disable backups

Example

Request body

{"enabled": true}

Response - 204

{}

List backups

GET /v2024-02-21/projects/:id/datasets/:name/backups

Query parameters

  • limitinteger

    Max number of backups returned

    default: 30

    max: 100

  • afterdate

    YYYY-MM-DD

    Only return backups after this timestamp (inclusive)

  • beforedate

    YYYY-MM-DD

    Only return backups before this timestamp (exclusive)

Example

Request body

{"limit": 20, "before": "2023-12-12"}

Response - 200

{
  "backups": [
    {
      "id": "2024-02-02-19083f95-1741-4e29-997a-76b56c773e24",
      "createdAt": "2024-02-02T14:13:06Z"
    }
  ],
  "limit": 20
}

Get a backup

GET /v2024-02-21/projects/:id/datasets/:name/backups/:id

Gotcha

This endpoint is primarily designed for use through the Sanity CLI sanity backup download command, which handles paging, downloading all files, and constructing a tarball in the format expected by sanity dataset import.

Query parameters

  • nextCursorstring

    A cursor to fetch the next page of files for a download

Example

Request body

{}

Response - 200

{
    "createdAt": "2023-12-12T06:03:01",
    "totalFiles": "1021",
    "files": [
        {
            "name": "document1",
            "url": "https://storage.googleapis.com/example-bucket/cat.jpeg?X-Goog-Algorithm=
GOOG4-RSA-SHA256&X-Goog-Credential=example%40example-project.iam.gserviceaccount
.com%2F20181026%2Fus-central1%2Fstorage%2Fgoog4_request&X-Goog-Date=20181026T18
1309Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&X-Goog-Signature=247a2aa45f16
9edf4d187d54e7cc46e4731b1e6273242c4f4c39a1d2507a0e58706e25e3a85a7dbb891d62afa849
6def8e260c1db863d9ace85ff0a184b894b117fe46d1225c82f2aa19efd52cf21d3e2022b3b868dc
c1aca2741951ed5bf3bb25a34f5e9316a2841e8ff4c530b22ceaa1c5ce09c7cbb5732631510c2058
0e61723f5594de3aea497f195456a2ff2bdd0d13bad47289d8611b6f9cfeef0c46c91a455b94e90a
66924f722292d21e24d31dcfb38ce0c0f353ffa5a9756fc2a9f2b40bc2113206a81e324fc4fd6823
a29163fa845c8ae7eca1fcf6e5bb48b3200983c56c5ca81fffb151cca7402beddfc4a76b13344703
2ea7abedc098d2eb14a7",
           "type": "document"
        }
    ],
    "nextCursor": "CLAKLSNldl=="
}

Was this article helpful?