Return the download link for one part of a checkpoint, and start the preparation of the database part.
Use it when the user wants a copy of an environment's database, files,
or code as of a checkpoint.
A checkpoint is a row of ``list_snapshots``. ``part``
picks what to download:
- ``database``: the Postgres database as a ``.sqlc`` archive for
``pg_restore``. Any row serves. The platform prepares the archive
first, from the backup, and this call starts that preparation. The
preparation holds the account's one database download slot until it
ends, and a second call for the same checkpoint joins it. The result
is ``{part, status, export_id, detail, download_url, console_url,
expires_at}``. Poll ``get_export_status`` with ``export_id`` until
``status`` reads 'ready' or 'failed', then fetch ``download_url``.
Call this tool again only to retry after 'failed'; the ``error``
that ``get_export_status`` returns states when to retry.
- ``files``: the environment's object-storage files as they were at
the checkpoint, as a ``.tar.gz``. Pick a row whose
``aligned_blob`` flag is true. This part starts nothing.
- ``code``: the deployed code at the checkpoint's ``git_sha``, as
a ``.tar``. Any row serves. This part starts nothing.
For ``files`` and ``code`` this tool returns ``{part, download_url,
console_url}``. ``download_url`` is the API link, and ``console_url``
serves the same artifact to a browser signed in to the console.
**Run the request with your own token.** Send the header
``Authorization: Bearer <your token>``, with the token from
``$XHOSTD_TOKEN``. If that variable is unset, ask the user to mint a
token on the console /tokens page and export it as ``XHOSTD_TOKEN``.
Never ask the user to paste a token, and never write a token value
into a command. On a failure, the response body holds the error
envelope ``{"error": {"code", "message"}}``. Without a shell, give the
user ``console_url`` to open in a browser signed in to the console.
Any HTTP client works. For example:
``printf 'Authorization: Bearer %s\n' "$XHOSTD_TOKEN" | curl -sS --fail-with-body --header @- -o <file> <url>``.
The example sends the header on curl's stdin, so the token stays off
the argv of every process, which any local user can read.
Errors:
- Every part: 403 ``download_disabled`` means the operator turned
this part off, which is permanent. 404 ``snapshot_not_found``
means no such checkpoint on this environment. 403 ``scope_denied``
means a narrowed ``$XHOSTD_TOKEN`` lacks the part's scope.
- ``database``, from this call: ``snapshot_out_of_window`` (409) and
``snapshot_host_gone`` (404) are permanent, so pick a newer
checkpoint. ``snapshot_download_busy`` (409) means another database
download of the account is being prepared: wait for it to end.
``deleting`` (409) means the environment or its project is being
deleted. A fetch of ``download_url`` before the preparation is ready
answers 409 ``snapshot_download_not_prepared``.
- ``files``: ``no_aligned_blob_snapshot`` (409) means the
checkpoint has no files leg. Another 409 names a checkpoint
older than the retention window, or one above the download limit
on file count or bytes. For the second, read the files with an
S3 client and the key pair that
``get_credential_request(purpose="object_storage")`` describes.
``blob_unavailable`` (503) is transient.
- ``code``: ``snapshot_sha_unknown`` and ``snapshot_code_gone``
(404) are permanent.
Returns ``{part, status, export_id, detail, download_url, console_url,
expires_at}`` for ``database``, and ``{part, download_url,
console_url}`` for ``files`` and ``code``.
Reference: https://docs.xhostd.com/mcp-tools#get_snapshot_download_link