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

# Import Workspace Document from URL

> Import a document by URL with workspace-level content deduplication.

Import a remote document URL directly into your workspace document library.

## Authentication & Scope

Requires `documents-write`.

## Request

```http theme={null}
POST /workspaces/12/documents:importUrl HTTP/1.1
Host: api.raydocs.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "url": "https://example.com/invoice.pdf",
  "filename": "invoice.pdf"
}
```

## Response

`201 Created` when new, `200 OK` when reused by `sha256`.

<Note>
  URL is provenance metadata only. Deduplication is content-based within the workspace.
</Note>


## OpenAPI

````yaml post /workspaces/{workspaceId}/documents:importUrl
openapi: 3.0.1
info:
  title: Raydocs API
  description: REST API for document extraction with AI-powered data parsing
  version: 1.0.0
servers:
  - url: https://api.raydocs.com
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: Create and manage workspaces.
  - name: Workspace Users
    description: Manage users within a workspace.
  - name: Extraction Templates
    description: Define extraction schemas and settings.
  - name: Extraction Sessions
    description: Manage extraction jobs and documents.
  - name: Batch Operations
    description: Bulk operations on sessions.
  - name: Documents
    description: Upload and manage source documents.
  - name: Results
    description: Access extraction results.
paths:
  /workspaces/{workspaceId}/documents:importUrl:
    post:
      tags:
        - Documents
      summary: Import Workspace Document from URL
      description: >-
        Fetch a file from URL, deduplicate by content hash, and create or reuse
        a workspace document. Requires `documents-write`.
      operationId: importWorkspaceDocumentUrl
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                filename:
                  type: string
      responses:
        '200':
          description: Reused existing document by content hash
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceDocumentCreateResponse'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceDocumentCreateResponse'
        '403':
          description: Forbidden
        '422':
          description: Validation error
components:
  schemas:
    WorkspaceDocumentCreateResponse:
      type: object
      properties:
        document:
          $ref: '#/components/schemas/Document'
        dedup:
          type: object
          properties:
            reused:
              type: boolean
            matched_by:
              type: string
              nullable: true
        document_ref:
          $ref: '#/components/schemas/DocumentRef'
    Document:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        workspace_id:
          type: integer
        filename:
          type: string
        mime:
          type: string
        size:
          type: integer
          description: File size in bytes
        sha256:
          type: string
          minLength: 64
          maxLength: 64
        status:
          type: string
          enum:
            - uploaded
            - queued
            - parsing
            - parsed
            - processed
            - failed
        source_type:
          type: string
          enum:
            - upload
            - url
            - connector
        source_url:
          type: string
          nullable: true
        parsings:
          type: array
          items:
            $ref: '#/components/schemas/DocumentParsingSummary'
        created_at:
          type: string
          format: date-time
          readOnly: true
    DocumentRef:
      type: object
      required:
        - kind
        - documentId
        - workspaceId
      properties:
        kind:
          type: string
          example: documentRef
        documentId:
          type: string
          format: uuid
        workspaceId:
          type: integer
        filename:
          type: string
        mime:
          type: string
        size:
          type: integer
        sha256:
          type: string
        source:
          type: object
          properties:
            type:
              type: string
              enum:
                - upload
                - url
                - connector
            url:
              type: string
              nullable: true
        createdAt:
          type: string
          format: date-time
    DocumentParsingSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        config_hash:
          type: string
        status:
          type: string
          enum:
            - queued
            - processing
            - ready
            - failed
        parser_version:
          type: string
        updated_at:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Personal Access Token created from the Raydocs dashboard.

        Include in the Authorization header: `Bearer <your_token>`

        See [API Keys](/api-reference/api-keys) for token creation and
        management.

````