Data Access Path · 6/7

Recommended reading order, not completion status. Optional steps can be skipped.

View all steps

Before you start: Read content first; for uploaded images/files confirm assets permission, or skip if no downloads are needed.

Download Images & Attachments

Some documents have collector-uploaded images, media or files. Managed attachments do not imply that every external resource was archived. Original URLs in document assets are separate from files uploaded through the attachment service.

Before Calling

Configure WHALE_BASE_URL and WHALE_API_KEY using Get & Use an API Key. Obtain DOCUMENT_ID from search or browse results and confirm document-scope access and the assets field grant. Never forward the Consumer Key to storage.

List Attachments

Bash
curl -sS --fail-with-body "$WHALE_BASE_URL/v1/documents/$DOCUMENT_ID/attachments?limit=50" \
  -H "Authorization: Bearer $WHALE_API_KEY" | jq .

limit is 1–100, default 50. The response contains only completed uploads:

JSON
{
  "attachments": [
    {
      "asset_id": "asset_01K...",
      "dataset_id": "social_media_raw",
      "source_platform": "xiaohongshu",
      "external_content_id": "65f0c2...",
      "role": "cover",
      "origin_url": "https://source.example.com/cover.jpg",
      "filename": "cover.jpg",
      "media_type": "image",
      "mime_type": "image/jpeg",
      "size_bytes": 248133,
      "status": "ready",
      "created_at": "2026-10-14T08:00:00Z"
    }
  ],
  "next_cursor": ""
}
FieldDescription
asset_idAttachment ID used for download
filename / mime_type / size_bytesFile name, MIME type and size in bytes
media_typeimage, video, audio, document or other
roleOptional semantic role. cover is the content’s one managed cover; inline, gallery, and media are also supported
origin_urlOptional upstream source URL for provenance. Download the managed attachment for previews; do not depend on the external link remaining available
statusready in this list
source_platform / external_content_idSource identity of the owning content (dataset_id is internal; ignore it)

When next_cursor is nonempty, pass it as after for the next page; empty means no more. For a reliable cover, prefer the attachment whose role is cover and call its download endpoint instead of using an external document.cover.url or origin_url.

Download a File

Bash
ASSET_ID="asset_01K..."
download_url="$(curl -sS --fail-with-body \
  "$WHALE_BASE_URL/v1/documents/$DOCUMENT_ID/attachments/$ASSET_ID/download" \
  -H "Authorization: Bearer $WHALE_API_KEY" | jq -er '.url')"
curl -sS --fail-with-body -o cover.jpg "$download_url"

The endpoint returns {"url": "...", "expires_in": 300}. The URL is valid for 300 seconds; download it directly without the Consumer Key. Never persist signed URLs or write them into public logs; request a fresh one after expiry.

Permissions and Errors

Your application needs data scope for the content and the assets field grant. Attachments are associated with content, not with historical versions. An empty list may mean no files were uploaded or uploads are not yet complete.

HTTPcodeMeaning and action
401unauthorizedThe API key is invalid
403forbiddenMissing data scope or assets field grant for this content
404not_foundThe content does not exist or is not ingested yet
404attachment_not_foundThe attachment does not exist or does not belong to this content
409attachment_incompleteThe upload has not completed; retry later
429rate_limit_exceededRate limited; back off per Retry-After
503attachment_unavailableAttachment or storage service temporarily unavailable; retry later

Completion check: Retrieve and download available files without persisting short-lived URLs; next configure limits, retries and error handling.