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

# Upload from URL

> Create a document packet by importing 1–10 HTTPS URLs server-side, all-or-nothing

*Rate limit tier: **submission** (60 req/min) — see [Rate limits](/api-reference-v3/introduction#rate-limits).*

Creates a [document packet](/concepts/document-packets) by having anyformat fetch the bytes server-side — no need to stream documents through your own backend when they already live in object storage you can presign (S3, GCS, R2, …) or at a public HTTPS URL.

Provide 1–10 **HTTPS** URLs. All of them import into a **single packet, atomically**: the packet is registered only after every fetch succeeded, so any failure imports nothing — no partial packet, no orphan files. Filenames are derived from each URL's path.

Each fetch is bounded by a 10-second timeout and a 20 MB per-file cap. A failed, non-2xx, or timed-out fetch surfaces as `422` with the distinct failure reasons in `detail`. URLs resolving to non-globally-routable addresses (loopback, private ranges, link-local, cloud-metadata) are refused before any connection opens.

The response is final — the packet is fully imported when you receive `201`. If the server-side import takes longer than the gateway's 6-minute polling ceiling, the request fails with a `504` (`retryable: true`); it is safe to retry with the same request body. Trigger extraction with [`POST /v3/document-packets/{document_packet_id}/run/`](/api-reference-v3/document-packets/run).

<RequestExample>
  ```bash curl theme={null}
  curl -X POST 'https://api.anyformat.ai/v3/workflows/0686bb97-8c30-70f0-8000-97669e000eb8/upload/from-url/' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "urls": [
        "https://example.com/invoices/april.pdf",
        "https://example.com/invoices/april-annex.pdf"
      ]
    }'
  ```

  ```python Python (requests) theme={null}
  import requests

  workflow_id = "0686bb97-8c30-70f0-8000-97669e000eb8"
  url = f"https://api.anyformat.ai/v3/workflows/{workflow_id}/upload/from-url/"
  headers = {"Authorization": "Bearer YOUR_API_KEY"}

  body = {
      "urls": [
          "https://example.com/invoices/april.pdf",
          "https://example.com/invoices/april-annex.pdf",
      ]
  }

  packet = requests.post(url, headers=headers, json=body).json()
  print(packet["document_packet_id"])
  ```
</RequestExample>

<ResponseExample>
  ```json Response (201 Created) theme={null}
  {
    "document_packet_id": "069dcc2c-e14c-7606-8000-2ee4fb17b4e1",
    "workflow_id": "0686bb97-8c30-70f0-8000-97669e000eb8",
    "files": [
      { "id": "069dcc2c-e14c-7606-8000-2ee4fb17b4e2", "name": "april.pdf" },
      { "id": "069dcc2c-e14c-7606-8000-2ee4fb17b4e3", "name": "april-annex.pdf" }
    ]
  }
  ```

  ```json Response (422 — a fetch failed, nothing imported) theme={null}
  {
    "error": "Remote fetch failed",
    "detail": "Remote server returned 404",
    "error_code": "VALIDATION_ERROR",
    "retryable": false,
    "request_id": "a1b2c3d4e5f67890abcdef1234567890"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v3/workflows/{workflow_id}/upload/from-url/
openapi: 3.1.0
info:
  title: anyformat API
  description: >
    Document extraction and workflow automation API.


    AnyFormat lets you define extraction workflows that pull structured data
    from any document — PDFs, images, scanned files, or plain text. Upload a
    file, run it through a workflow, and get back structured fields with
    confidence scores and source evidence.


    ## Quick start


    See the [Quick start
    guide](https://docs.anyformat.ai/api-reference/introduction) for a
    walkthrough.


    ## Authentication


    All endpoints (except `/health/`) require a Bearer token in the
    `Authorization` header:


    ```

    Authorization: Bearer <your-api-key>

    ```


    Get your API key from
    [app.anyformat.ai/api-key](https://app.anyformat.ai/api-key).


    ## Versioning


    Endpoints are versioned by path prefix (`/v2/`, `/v3/`). Every response
    under

    a versioned prefix includes `X-API-Version`.
  version: 2.0.0
servers:
  - url: https://api.anyformat.ai
    description: API server
security: []
tags:
  - name: workflows
    description: >-
      Workflows define extraction templates — what fields to extract from
      documents. Create workflows, upload files, run extractions, and fetch
      results.
  - name: files
    description: >-
      File collections group uploaded documents and track their extraction
      progress. Upload files, check status, and retrieve extraction results.
  - name: suggestions
    description: >-
      AI-powered schema and workflow suggestion endpoints for the AnyFormat
      webapp. Authenticated with a Cognito JWT rather than an API key.
  - name: document-packets
    description: >-
      Document packets group uploaded documents for a workflow (v3). Address a
      packet directly to (re-)run its workflow.
  - name: runs
    description: >-
      Extraction runs — the v3 first-class result entity. Each run is a single
      execution of a workflow against a document packet; fetch its status and
      results flat by run id.
  - name: health
    description: Health check endpoints to verify API availability.
paths:
  /v3/workflows/{workflow_id}/upload/from-url/:
    post:
      tags:
        - workflows
      summary: Create document packet from URLs
      description: |-
        Import every URL into a single document packet, atomically.

        The backend fetches each HTTPS URL server-side (10s timeout, 20 MB cap
        per file) and registers the packet in one transaction only after every
        fetch succeeded — any failure imports nothing (no partial packet, no
        orphan files). Filenames are derived from each URL's path.
      operationId: v3_upload_from_url
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: string
            title: Workflow Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentPacketFromUrlsRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentPacketCreatedV3'
          headers:
            X-RateLimit-Limit:
              description: Requests allowed per window (60s).
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
        '401':
          description: Authentication failed — missing, invalid, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                AUTH_FAILED:
                  value:
                    error: Authentication failed.
                    detail: Authentication failed.
                    error_code: AUTH_FAILED
                    retryable: false
                    request_id: req_abc123
        '404':
          description: >-
            Resource not found — the workflow, document packet, or run ID does
            not exist or is not visible to this API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                NOT_FOUND:
                  value:
                    error: Resource not found.
                    detail: Resource not found.
                    error_code: NOT_FOUND
                    retryable: false
                    request_id: req_abc123
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Rate limited — retry after the `Retry-After` header. Default
            windows: 60 requests/minute for extraction submission, 600
            requests/minute for general endpoints.
          headers:
            Retry-After:
              description: Seconds until the next request is allowed.
              schema:
                type: integer
            X-RateLimit-Limit:
              description: Requests allowed per window (60s).
              schema:
                type: integer
            X-RateLimit-Remaining:
              description: Requests remaining in the current window.
              schema:
                type: integer
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                RATE_LIMITED:
                  value:
                    error: Rate limit exceeded — retry after backoff.
                    detail: Rate limit exceeded — retry after backoff.
                    error_code: RATE_LIMITED
                    retryable: true
                    request_id: req_abc123
      security:
        - ApiKeyAuth: []
components:
  schemas:
    DocumentPacketFromUrlsRequest:
      properties:
        urls:
          items:
            type: string
          type: array
          maxItems: 10
          minItems: 1
          title: Urls
          description: >-
            HTTPS URLs the backend fetches server-side (1..10). The filename is
            derived from each URL's path.
          examples:
            - - https://example.com/invoices/april.pdf
      type: object
      required:
        - urls
      title: DocumentPacketFromUrlsRequest
      description: |-
        Body for ``POST /v3/workflows/{workflow_id}/upload/from-url/``.

        Every URL imports into a single packet atomically — any fetch or
        validation failure means nothing is persisted.
      examples:
        - urls:
            - https://example.com/invoices/april.pdf
            - https://example.com/invoices/april-annex.pdf
    DocumentPacketCreatedV3:
      properties:
        document_packet_id:
          type: string
          title: Document Packet Id
          description: >-
            Unique identifier of the newly created document packet (hyphenated
            UUID).
          examples:
            - 069dcc2c-e14c-7606-8000-2ee4fb17b4e1
        workflow_id:
          type: string
          title: Workflow Id
          description: The workflow the packet was created under (hyphenated UUID).
          examples:
            - 0686bb97-8c30-70f0-8000-97669e000eb8
        files:
          items:
            $ref: '#/components/schemas/DocumentPacketFileV3'
          type: array
          title: Files
          description: Files in the packet, in the order they were provided.
      type: object
      required:
        - document_packet_id
        - workflow_id
        - files
      title: DocumentPacketCreatedV3
      description: Response for the packet-creating uploads (multipart and from-url).
    ErrorEnvelope:
      type: object
      title: ErrorEnvelope
      description: >-
        Uniform error response. `retryable=true` means the same request may
        succeed on retry (with backoff); `retryable=false` means the caller must
        change the request before retrying.
      required:
        - error
        - detail
        - error_code
        - retryable
        - request_id
      properties:
        error:
          type: string
          description: Short human-readable summary.
        detail:
          description: >-
            Machine-readable detail. String for most errors; list of field
            errors for validation failures.
          oneOf:
            - type: string
            - type: array
              items:
                type: object
        error_code:
          type: string
          description: Stable identifier for programmatic handling.
          examples:
            - VALIDATION_ERROR
            - AUTH_FAILED
            - NOT_FOUND
            - PRECONDITION_FAILED
            - RATE_LIMITED
            - INTERNAL_ERROR
            - GATEWAY_TIMEOUT
        retryable:
          type: boolean
          description: True when the caller should retry (with backoff for 429/412/5xx).
        request_id:
          type: string
          description: Correlates this response with server logs.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DocumentPacketFileV3:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the file (hyphenated UUID).
          examples:
            - 069dcc2c-e14c-7606-8000-2ee4fb17b4e2
        name:
          type: string
          title: Name
          description: Filename recorded at upload.
          examples:
            - invoice.pdf
      type: object
      required:
        - id
        - name
      title: DocumentPacketFileV3
      description: Slim per-file projection inside a packet.
    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
  securitySchemes:
    ApiKeyAuth:
      type: http
      description: >-
        API key issued from app.anyformat.ai/api-key. Send as `Authorization:
        Bearer <key>`.
      scheme: bearer

````