Skip to navigation

Extracting Content, Reading Metadata, and Transforming Files with Riviera

View as Markdown

Riviera is Dropbox’s content-processing platform. Its public routes read a file and give you back something derived from it. There are three of them:

  • /riviera/extract_async extracts content: Markdown, plain text, OCR text, a transcript, or video keyframes.
  • /riviera/get_metadata_async retrieves structured metadata: image EXIF, audio and video properties, PDF page data, or Office document properties.
  • /riviera/get_transform_async converts the file to a new one, such as a PDF, an HTML page, an image, a thumbnail, or a single video frame.

get_markdown_async, get_text_async, get_ocr_async, get_transcript_async, and get_keyframes_async are deprecated and will be turned off by December 31, 2026. Use extract_async instead. See Moving off the deprecated routes.

Picking the right route

Each route answers a different question about a file, and you can use them independently.

What you wantRouteWhat you get back
What the file says, as textextract_async, then extract_async/checkMarkdown, plain text, OCR text with word positions, a timestamped transcript, or keyframes, depending on extract_type
The file’s propertiesget_metadata_async, then get_metadata_async/checkOne metadata object, chosen by the file’s type
The file in another formatget_transform_async, then get_transform_async/check, then download_transform_outputThe bytes of a new file, such as a PDF, HTML, JPEG, or PNG

All three are read-only. They never change the source file, and they don’t write anything to the user’s Dropbox, including the output of a transform.

Each request handles one file. To process several files, send one request per file.

Moving off the deprecated routes

extract_async replaces five single-purpose routes. Each extract_type variant takes the same options as the route it replaces.

Deprecated routeUse instead
get_markdown_asyncextract_async with extract_type set to markdown
get_text_asyncextract_async with extract_type set to text
get_ocr_asyncextract_async with extract_type set to ocr
get_transcript_asyncextract_async with extract_type set to transcript
get_keyframes_asyncextract_async with extract_type set to keyframes

get_metadata_async isn’t deprecated, and neither are the transform routes.

Moving a call over takes three changes:

  1. Move the options into extract_type. The old routes took their options at the top level of the request. In extract_async they go inside the extract_type object, next to its .tag:

    Before, calling get_markdown_async:

    {"file_id_or_url": {".tag": "path", "path": "/docs/spec.pdf"}, "enable_ocr": true}

    After, calling extract_async:

    {"file_id_or_url": {".tag": "path", "path": "/docs/spec.pdf"}, "extract_type": {".tag": "markdown", "enable_ocr": true}}

    Always send extract_type as an object, even for a type with no options: {".tag": "text"}, not "text".

  2. Poll extract_async/check. The polling flow is the same as before.

  3. Read the result one level deeper. A complete result now holds a union tagged with the extraction type, and that union carries the same fields the old route returned:

    Before, from get_markdown_async/check:

    {".tag": "complete", "markdown": "# Quarterly Report\n..."}

    After, from extract_async/check:

    {".tag": "complete", "complete": {".tag": "markdown", "markdown": "# Quarterly Report\n..."}}

A failed job now returns one error union, ExtractApiV2Error, for every extraction type. Some failures also come back as a more specific variant than before. For example, a file over a size limit returns limit_exceeded_error where an old route returned user_error. If your code branches on errors, check it against Handling failures.

How the routes work: launch and poll

All three routes are asynchronous:

  1. Call the route. It starts a job and returns an async_job_id.
  2. Poll the corresponding /check route with that ID, such as extract_async/check. It returns one of:
    • in_progress: the job is still running. Poll again later.
    • complete: the job finished. The result is in the response.
    • failed: the job failed. The response carries a typed error you can branch on.

Transforms add one step: a complete transform result describes the output file but doesn’t contain it. Pass its output_handle to download_transform_output to get the bytes.

curl -X POST https://api.dropboxapi.com/2/riviera/extract_async \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"file_id_or_url": {".tag": "path", "path": "/recordings/standup.mp4"}, "extract_type": {".tag": "transcript"}}'
{".tag": "async_job_id", "async_job_id": "dbjid:AABh8k9X..."}
curl -X POST https://api.dropboxapi.com/2/riviera/extract_async/check \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"async_job_id": "dbjid:AABh8k9X..."}'
{".tag": "in_progress"}

Some guidance on polling:

  • These routes are rate limited. About 15 seconds between polls is a safe starting point. Back off further for long media, and respect retry_after on a 429 response.
  • A failed job still returns HTTP 200 from /check. Read .tag to tell complete and failed apart.
  • The async_job_id is all you need to poll, so you can launch a job in one process and poll it from another.

Pointing at a file

Every route takes the source file in file_id_or_url. Set exactly one of:

  • path: an absolute Dropbox path, such as /docs/spec.pdf.
  • file_id: a Dropbox file ID, such as id:a4ayc_80_OEAAAAAAAAAYa. Prefer this for files you’ll process again, since it still works after the file is renamed or moved.
  • url: either a Dropbox shared link or an external HTTP or HTTPS URL.
    • Dropbox resolves a shared link as the calling user, and respects the link’s settings. A password-protected link, or one with downloads disabled, is rejected.
    • Dropbox’s servers fetch an external URL, so it must be reachable from the public internet and point at a supported file type.

Which inputs work depends on how you authenticate:

InputUser AuthApp Auth
pathYesNo
file_idYesNo
Dropbox shared linkYesNo
External URLYesYes

extract_async with extract_type set to ocr doesn’t accept external URLs; they fail with unsupported_format_error.

All of these routes need the files.content.read scope. See the File Access Guide for information on how paths, file IDs, and shared links work.

Extracting content

/riviera/extract_async covers every kind of content extraction. Set extract_type to the kind you want. Refer to the documentation for information on supported file types and size limits.

Options

Options go inside the extract_type object. Any you leave out take their defaults.

extract_typeOptionDefaultWhat it does
markdownenable_ocrfalseRuns OCR on PDFs, so that scanned pages contribute text. Slower.
markdownembed_imagesfalseEmbeds images in the Markdown as base64 data URIs. This can make the result much larger.
transcripttimestamp_levelsentencesentence gives one segment per sentence. word gives one per word, which is useful for captions but returns many more segments.
transcriptaudio_languageDetectedAn ISO 639-1 code for the spoken language, such as en. It helps most on short or ambiguous clips.
transcriptincluded_special_wordsNoneA comma-separated list of filler words to keep, such as uh, um. Filler words are removed by default.
keyframesscene_change_threshold0.3How sensitive scene detection is, from just above 0 up to 1. A lower value gives more keyframes.
keyframesinclude_imagesfalseIncludes each keyframe as a base64 JPEG.

text and ocr have no options.

Results

A complete result holds the variant that matches your extract_type:

{".tag": "complete", "complete": {".tag": "markdown", "markdown": "# Quarterly Report\n\nRevenue grew 12%...\n"}}
{
".tag": "complete",
"complete": {
".tag": "transcript",
"structured_transcript": {
"transcript_locale": "en",
"segments": [
{"text": "Good morning, everyone.", "start_time": 0.0, "end_time": 1.8}
]
}
}
}

The other variants have these fields:

  • text: text, the document’s plain text.
  • ocr: text, the recognized text, and hocr, the same text with the position of each word.
  • keyframes: frames, each with a timestamp, a scene_score, and an image_base64 when you set include_images.

See the reference for every field.

Extracting file metadata

/riviera/get_metadata_async takes only file_id_or_url. The file’s type decides which kind of metadata you get:

File typemetadata_typeFields include
Images, including camera RAW formatsmetadata_type_exifDimensions, camera and lens, exposure settings, orientation, capture time, GPS location
Audio and videometadata_type_mediaDuration and bitrate, plus each stream’s codec, resolution, frame rate, channels, and language
PDFmetadata_type_pdfPage count, and the first page’s width and height in points
Word, PowerPoint, and Excel (.docx, .pptx, .xlsx)metadata_type_officeAuthor, company, title, subject, keywords, editing time, and page, word, or slide counts

A file in any other format, or over the size limit for its kind, fails with user_error.

Read metadata_type to find out which variant metadata holds:

{
".tag": "complete",
"metadata_type": {".tag": "metadata_type_pdf"},
"metadata": {".tag": "pdf", "pages": 12, "width": 612, "height": 792}
}

All metadata is best-effort. When the file doesn’t record a field, the field is left out or set to its default. For example, a photo taken with location turned off has no GPS data. See the reference for the full list of fields, supported formats, and size limits.

Converting files

/riviera/get_transform_async produces a new file from the source file. Set transform_type to the output you want:

transform_typeWhat you getAcceptsOptions
pdfA PDFWord-processing, presentation, and spreadsheet documents, such as .docx, .pptx, .xlsx, .odt, .rtf, and .gdoc. Not images.None
htmlAn HTML page that keeps the sheet layoutSpreadsheets only: .gsheet, .ods, .xls, .xlsm, .xlsx. Not .csv.None
imageA JPEG or PNG, of one page for a multi-page sourceThe pdf documents, plus .pdf, .html, iWork and design files, AVIF, HEIC, SVG, camera RAW, fonts, and videoimage
image_pdfA JPEG or PNG of one page, rendered by way of a PDFThe pdf documentsimage
thumbnailA resized image at a fixed sizeEverything image accepts, plus .bmp, .gif, .ico, .jpeg, .png, .tif, .tiff, .webp, and JPEG 2000thumbnail
video_frameOne still frame from a videoVideo files, such as .mov, .mp4, .mkv, and .webmvideo_frame

Use image for formats a browser can’t show directly, such as HEIC, RAW, PSD, or SVG. It doesn’t accept formats a browser already shows, such as JPEG or PNG; use thumbnail to resize those. Prefer image to image_pdf unless you specifically want the PDF rendering.

The reference lists every format each transform accepts.

Options

A transform’s options go in a separate top-level field named after the options set, not inside transform_type. Send only the options set that belongs to your transform_type. Any other options set fails with invalid_options_error.

Options fieldUsed byOptionDefaultWhat it does
imageimage, image_pdfpage_number1The page to render, counting from 1. To render every page, send one request per page.
imageimage, image_pdfscale_percent100Scales the image to this percentage of its natural size, from 1 to 100. Riviera doesn’t upscale.
thumbnailthumbnailsizew64h64One of the size buckets files/get_thumbnail uses, from w32h32 to w2048h1536.
thumbnailthumbnailmodestrictHow to fit the source into size: strict, bestfit, fitone_bestfit, or original.
thumbnailthumbnailformatjpegjpeg, png, or webp.
video_framevideo_frameoffset_in_seconds0How far into the video to take the frame.
video_framevideo_framescale_percent100Scales the frame to this percentage of its natural size, from 1 to 100.

To pick out a single frame, use video_frame. To find every scene change in a video, use extract_async with keyframes.

curl -X POST https://api.dropboxapi.com/2/riviera/get_transform_async \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"file_id_or_url": {".tag": "path", "path": "/decks/q3-review.pptx"}, "transform_type": {".tag": "image"}, "image": {"page_number": 3, "scale_percent": 50}}'

Downloading the output

When you poll get_transform_async/check, a complete result describes the output file:

{
".tag": "complete",
"output_handle": "AAEx3...",
"size": 48213,
"format": "jpeg",
"mime_type": "image/jpeg",
"expires_ts": 1763164800
}

The format is what Riviera actually produced, which for some sources isn’t what you asked for. Check format or mime_type before you hand the file to something else.

Pass output_handle to /riviera/download_transform_output to get the bytes. Like files/download, this route is on content.dropboxapi.com. It takes its argument in the Dropbox-API-Arg header, returns the file as the response body, and describes the file in the Dropbox-API-Result header:

curl -X POST https://content.dropboxapi.com/2/riviera/download_transform_output \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header 'Dropbox-API-Arg: {"output_handle": "AAEx3..."}' \
--output q3-review-page-3.jpg

Keep these in mind when downloading:

  • Only the user who requested the transform can redeem its handle. A handle from another user, or one that was never valid, fails with user_error.
  • A handle stops working at expires_ts, which is in Unix seconds. After that, the download fails with expired_handle_error, and you need to request the transform again.
  • The download usually returns straight away. If Riviera has dropped the cached output, it makes the file again before responding, which can take as long as the original transform.

Handling failures

A failed job returns failed with a typed error. All three routes use the same set of error variants, apart from a few that only one route returns. Group them like this:

SituationError variantsWhat to do
The file can’t be used for this requestunsupported_format_error, conversion_failure_error, no_audio_error (transcripts only)Check that the route supports the file’s format, and that the file has what you asked for, such as an audio track. A corrupt file gives conversion_failure_error. Retrying the same file won’t help, so skip it or fix it.
The file can’t be reachednot_found_error, is_a_folder_errorCheck that the identifier points to a file, not a folder, and that the caller can access it. Then retry with the corrected identifier.
The shared link blocks accessshared_link_password_protected, link_download_disabled_errorThe link’s own settings prevent access. Use a link with no password and downloads allowed, or use a path or file ID.
A limit was exceededlimit_exceeded_errorCompare the file with the documented limits. For keyframes, raise scene_change_threshold or turn off include_images. For markdown, turn off embed_images. Otherwise, skip the file or split it.
The request is wronguser_error, invalid_options_error (transforms only)Fix the request. user_error includes a message saying what’s wrong, such as an option out of range. Retrying the same request won’t help.
The output handle has expiredexpired_handle_error (download_transform_output only)Request the transform again to get a new handle.
Something went wrong on the serverserver_errorRetry with exponential back-off. If it keeps failing, report it.

get_metadata_async is the exception: it reports an unsupported format or a file over its size limit as user_error, with a message saying which. Treat those as “skip the file”, not as a bad request.

A request that can’t be parsed at all, such as one with no extract_type, fails straight away with HTTP 400 instead of starting a job.

See each route’s reference for the exact variants it returns.

A typical end-to-end flow

  1. Find the file. Get a path or file ID, or a shared link. Prefer a file ID for anything you’ll process again.
  2. Start the job. Call extract_async, get_metadata_async, or get_transform_async, and save the async_job_id.
  3. Poll with back-off. Call the corresponding /check route until it returns complete or failed.
  4. Use the result. Store the extracted content or metadata. For a transform, download the output with download_transform_output before expires_ts.
  5. Handle failures by type. Retry server_error with back-off, fix the request for input errors, and skip files that can’t be processed.

To process many files, run this flow for each file in parallel. Retry the launch call as well as polls, and expect some files to fail while others succeed.