Mint Asset URLs

POSThttps://api.captain.dev/v3/collections/:collection_name/documents/:document_id/asset-urls

Mint short-lived presigned URLs for a document's images.

Three kinds of id are accepted in asset_ids:

  • a figure id (regions[].figure_id): a crop of a figure in the document;
  • original: the document's own file, when the document is a raster image that Captain holds (an uploaded image, one staged from Google Drive, SharePoint or OneDrive, or a Confluence image attachment) or one a Sync connector indexed in your own S3 bucket. Not available for a document indexed with PII masking, or for a file a one-off index job read from your own bucket. The URL lasts 15 minutes at most;
  • a Confluence attachment identity (confluence://{site}/{page_id}/attachments/{id}), on the page that carries it: the attached image a page's text links to.

Each item degrades on its own: one that cannot be signed comes back unavailable with a reason and does not fail the whole request.

Path parameters

collection_namestringRequired
document_idstringRequired

Request

This endpoint expects an object.

asset_idslist of stringsRequired

What to mint URLs for. Up to 100; duplicates each return their own item. Three kinds of id are accepted. A figure id from regions[].figure_id: a crop of a figure in the document. original: the document’s own file, when the document is an image (PNG, JPEG, GIF, WebP, BMP or TIFF) that Captain holds, or one a Sync connector indexed in your own S3 bucket. Not available for a document indexed with PII masking, or for a file a one-off index job read from your own bucket. A Confluence attachment identity (confluence://{site}/{page_id}/attachments/{id}), on the page that carries it: the attached image, as linked from the page’s text. Ids are stable and safe to store, unlike the URLs they mint.

ttl_secondsinteger or nullOptional60-604800

How long each URL stays valid, in seconds. Default 900 (15 min); min 60, max 604800 (7 days). An original or attachment URL lasts 15 minutes at most: a longer request is shortened, and expires_at states the real expiry.

Response

Successful Response

collection_namestring
document_idstring
asset_urlslist of objectsOptional
expires_atstring or nullOptional

Earliest expiry across all signed items, so a client can schedule a single refresh instead of one timer per image. Null when nothing was signed.

expires_in_secondsinteger or nullOptional

Same deadline as a duration. Provided because browser clocks are routinely wrong, which makes an absolute-only expiry unreliable.

signed_countintegerOptionalDefaults to 0
unavailable_countintegerOptionalDefaults to 0
warningslist of stringsOptional

Errors

POST/v3/collections/:collection_name/documents/:document_id/asset-urls
import json
import requests

BASE_URL = "https://api.captain.dev"
API_KEY = "your_api_key"
COLLECTION_NAME = "research_library"
DOCUMENT_ID = "doc_climate_agriculture_2024"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/v3/collections/{COLLECTION_NAME}/documents/{DOCUMENT_ID}/asset-urls",
    headers=headers,
    json={
        "asset_ids": [
            "fig_1_a2b3c4d5e6f7g2h3i4j5k6l7m2",
            "fig_1_z7y6x5w4v3u2t7s6r5q4p3o2n7",
        ],
        "ttl_seconds": 1800,
    },
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
200
{
  "collection_name": "research_library",
  "document_id": "doc_climate_agriculture_2024",
  "asset_urls": [
    {
      "asset_id": "fig_1_a2b3c4d5e6f7g2h3i4j5k6l7m2",
      "status": "signed",
      "bbox": {
        "top": 0.12,
        "left": 0.2,
        "width": 0.5,
        "height": 0.31
      },
      "content_type": "image/png",
      "expires_at": "2024-05-21T08:30:00Z",
      "image_url": "https://assets.captainusercontent.com/crops/org_1/doc_climate_agriculture_2024/p4-2.png?X-Amz-Expires=1800&X-Amz-Signature=REDACTED",
      "kind": "figure",
      "page": 4
    },
    {
      "asset_id": "fig_1_z7y6x5w4v3u2t7s6r5q4p3o2n7",
      "status": "unavailable",
      "bbox": {
        "top": 0.4,
        "left": 0.15,
        "width": 0.6,
        "height": 0.22
      },
      "kind": "figure",
      "message": "No crop image was made for this figure when the document was indexed. Re-index the document to generate one.",
      "page": 7,
      "reason": "no_crop_available"
    }
  ],
  "expires_at": "2024-05-21T08:30:00Z",
  "expires_in_seconds": 1800,
  "signed_count": 1,
  "unavailable_count": 1,
  "warnings": []
}
Was this page helpful?