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
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:
{
"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": ""
}| Field | Description |
|---|---|
asset_id | Attachment ID used for download |
filename / mime_type / size_bytes | File name, MIME type and size in bytes |
media_type | image, video, audio, document or other |
role | Optional semantic role. cover is the content’s one managed cover; inline, gallery, and media are also supported |
origin_url | Optional upstream source URL for provenance. Download the managed attachment for previews; do not depend on the external link remaining available |
status | ready in this list |
source_platform / external_content_id | Source 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
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.
| HTTP | code | Meaning and action |
|---|---|---|
| 401 | unauthorized | The API key is invalid |
| 403 | forbidden | Missing data scope or assets field grant for this content |
| 404 | not_found | The content does not exist or is not ingested yet |
| 404 | attachment_not_found | The attachment does not exist or does not belong to this content |
| 409 | attachment_incomplete | The upload has not completed; retry later |
| 429 | rate_limit_exceeded | Rate limited; back off per Retry-After |
| 503 | attachment_unavailable | Attachment 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.