> ## 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.

# Run Extraction

> Create one extraction run for the current session document set.

## Authentication & Scope

Requires the `sessions-write` ability.

## Request

```http theme={null}
POST /extractions/sessions/770e8400-e29b-41d4-a716-446655440000/results HTTP/1.1
Host: api.raydocs.com
Authorization: Bearer <token>
```

### Path Parameters

| Parameter   | Type | Required | Description    |
| ----------- | ---- | -------- | -------------- |
| `sessionId` | uuid | Yes      | The session ID |

## Response

`201 Created` - Extraction run started.

```json theme={null}
{
  "id": "990e8400-e29b-41d4-a716-446655440000",
  "extraction_session_id": "770e8400-e29b-41d4-a716-446655440000",
  "status": "created",
  "config_hash": "9eeae65063f17f552f4f95fe8c23d0aa8b697f91df5e8dd4a7214be4d6a7aa62",
  "document_refs": [
    {
      "kind": "documentRef",
      "documentId": "880e8400-e29b-41d4-a716-446655440000",
      "workspaceId": "660e8400-e29b-41d4-a716-446655440000",
      "sha256": "6de7f6f5894c9f3fd1f6f8a4d1b3115d0d9b4b19d7a8a661f9fe90f9c2d80c3b",
      "filename": "invoice.pdf"
    }
  ],
  "title": null,
  "created_at": "2024-01-15T10:30:00Z",
  "completed_at": null
}
```

`201 Created` - Extraction run created in deferred mode while parsing completes.

```json theme={null}
{
  "id": "990e8400-e29b-41d4-a716-446655440001",
  "extraction_session_id": "770e8400-e29b-41d4-a716-446655440000",
  "status": "parsing_pending",
  "config_hash": "9eeae65063f17f552f4f95fe8c23d0aa8b697f91df5e8dd4a7214be4d6a7aa62",
  "audit_data": {
    "_pending_manual_run": {
      "pending_document_ids": [
        "880e8400-e29b-41d4-a716-446655440000"
      ]
    }
  },
  "created_at": "2024-01-15T10:30:00Z",
  "completed_at": null
}
```

<Note>
  Each `ExtractionSessionResult` represents one run snapshot for the documents attached to the session at trigger time. The output is aggregated across those documents. Poll the [Get Result](/api-reference/results/get-result) endpoint to check status and retrieve data when complete.
</Note>

`422 Unprocessable Entity` – No documents in session or documents not ready.


## OpenAPI

````yaml post /extractions/sessions/{sessionId}/results
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: Workflows
    description: Discover workflow runs and read their public outputs.
  - name: Results
    description: Access extraction results.
paths:
  /extractions/sessions/{sessionId}/results:
    post:
      tags:
        - Results
      summary: Run Extraction
      description: >-
        Create one extraction run for the current session document set. Requires
        `sessions-write`.
      operationId: runExtraction
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: Extraction run created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractionResult'
        '403':
          description: Forbidden
        '422':
          description: Session has no documents or documents are not processed
components:
  schemas:
    ExtractionResult:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        extraction_session_id:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - created
            - parsing_pending
            - processing
            - completed
            - failed
        config_hash:
          type: string
          nullable: true
        document_refs:
          type: array
          items:
            $ref: '#/components/schemas/DocumentRef'
        data:
          type: object
          description: Extracted data matching the template schema
        audit_data:
          type: object
          description: Verification/reasoning traces and run audit payload
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_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
  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.

````