> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beta.adapter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Document By Urn

> Download a document as a file by its `urn`.

A document ingested from a binary (a PDF, image, spreadsheet, attachment, video) streams back
as the file was ingested, with `Range` support for resumable downloads. An email downloads as
an RFC 822 `.eml` with its stored attachments and a calendar event as an iCalendar `.ics`.
Other documents without a binary payload return 404; read those with the document route.

<Snippet file="api/documents/download-document-by-urn.mdx" />


## OpenAPI

````yaml GET /v1/documents/{urn}/raw
openapi: 3.1.0
info:
  title: Adapter API
  description: Connect and sync data from any SaaS tool.
  version: 0.1.0
servers:
  - url: http://localhost:8080
security: []
tags:
  - name: connections
    description: Manage OAuth connections to data sources.
paths:
  /v1/documents/{urn}/raw:
    get:
      tags:
        - documents
      summary: Download Document By Urn
      description: >-
        Download a document as a file by its `urn`.


        A document ingested from a binary (a PDF, image, spreadsheet,
        attachment, video) streams back

        as the file was ingested, with `Range` support for resumable downloads.
        An email downloads as

        an RFC 822 `.eml` with its stored attachments and a calendar event as an
        iCalendar `.ics`.

        Other documents without a binary payload return 404; read those with the
        document route.
      operationId: download_document_by_urn
      parameters:
        - name: urn
          in: path
          required: true
          schema:
            type: string
            title: Urn
      responses:
        '200':
          description: >-
            The document as a file: the original bytes of a binary payload, an
            RFC 822 message for an email, or an iCalendar file for a calendar
            event.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
            message/rfc822:
              schema:
                type: string
                format: binary
            text/calendar:
              schema:
                type: string
                format: binary
        '206':
          description: The requested byte range of a binary payload.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationErrorModel'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PermissionDeniedErrorModel'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorModel'
          description: Not Found
        '416':
          description: The requested byte range lies outside the binary payload.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Rate limit exceeded for the caller's tier. RFC 9457 problem+json
            body; IETF RateLimit-* headers and Retry-After are set.
          headers:
            Retry-After:
              description: Seconds to wait before retrying (RFC 9110).
              schema:
                type: integer
            RateLimit-Limit:
              description: Requests allowed per window.
              schema:
                type: integer
            RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            RateLimit-Reset:
              description: Delta-seconds until the window resets.
              schema:
                type: integer
            RateLimit-Policy:
              description: Active policy, e.g. '5;w=60'.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/RateLimitProblemDetail'
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitProblemDetail'
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorModel'
          description: Internal Server Error
components:
  schemas:
    AuthenticationErrorModel:
      properties:
        error_code:
          type: string
          const: authentication_error
          title: Error Code
          default: authentication_error
        message:
          type: string
          title: Message
          default: Invalid or missing credentials.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: AuthenticationErrorModel
    PermissionDeniedErrorModel:
      properties:
        error_code:
          type: string
          const: permission_denied
          title: Error Code
          default: permission_denied
        message:
          type: string
          title: Message
          default: You do not have permission to perform this action.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: PermissionDeniedErrorModel
    NotFoundErrorModel:
      properties:
        error_code:
          type: string
          const: not_found
          title: Error Code
          default: not_found
        message:
          type: string
          title: Message
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      required:
        - message
      title: NotFoundErrorModel
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RateLimitProblemDetail:
      properties:
        type:
          type: string
          title: Type
          description: >-
            Stable problem-type URI, e.g.
            '{api_base_url}/errors/rate_limit_exceeded'.
        title:
          type: string
          const: Too Many Requests
          title: Title
          default: Too Many Requests
        status:
          type: integer
          const: 429
          title: Status
          default: 429
        detail:
          type: string
          title: Detail
          description: Human-readable explanation, including the retry hint.
        error_code:
          type: string
          const: rate_limit_exceeded
          title: Error Code
          default: rate_limit_exceeded
        endpoint:
          type: string
          title: Endpoint
          description: Logical endpoint the limit applies to (e.g. 'ask', 'search').
        tier:
          type: string
          title: Tier
          description: The caller's billing tier (e.g. 'flex').
        limit:
          type: integer
          title: Limit
          description: Requests allowed per window for this tier + endpoint.
        remaining:
          type: integer
          title: Remaining
          description: Requests remaining in the current window (0 when blocked).
        window_seconds:
          type: integer
          title: Window Seconds
          description: Length of the fixed rate-limit window, in seconds.
        retry_after:
          type: integer
          title: Retry After
          description: Seconds to wait before retrying (mirrors the Retry-After header).
        instance:
          anyOf:
            - type: string
            - type: 'null'
          title: Instance
          description: The request path that was limited.
      type: object
      required:
        - type
        - detail
        - endpoint
        - tier
        - limit
        - remaining
        - window_seconds
        - retry_after
      title: RateLimitProblemDetail
      description: >-
        The 429 response body, exactly as ``RateLimitError.problem_detail``
        renders it —

        RFC 9457 Problem Details, served as ``application/problem+json``
        alongside the IETF

        ``RateLimit-*`` headers and ``Retry-After``. (Distinct from the legacy

        ``RateLimitErrorModel`` shape, which does not match what the handler
        emits.)
    InternalServerErrorModel:
      properties:
        error_code:
          type: string
          const: internal_server_error
          title: Error Code
          default: internal_server_error
        message:
          type: string
          title: Message
          default: An unexpected error occurred.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
      type: object
      title: InternalServerErrorModel
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.