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

# Doc to Text

> Convert documents such as PDFs, PowerPoints, or Word files into plain text.

## Description

This endpoint converts PDF or DOCX documents into plain text. It supports input via URL or base64-encoded file content.

## Endpoint

```
POST https://app.dumplingai.com/api/v1/doc-to-text
```

## Headers

* **Content-Type:** `application/json`
* **Authorization:** Bearer `<API_KEY>` (required)

## Request Body

```json theme={null}
{
  "inputMethod": "string", // Required. Either "url" or "base64".
  "file": "string", // Required. URL or base64-encoded file content.
  "pages": "string" // Optional. Specify pages to process.
}
```

## Responses

### Success (200)

Returns the extracted text from the document.

```json theme={null}
{
  "text": "string" // Extracted text content
}
```

* **X-RateLimit-Limit:** The rate limit for the user.
* **X-RateLimit-Remaining:** The remaining number of requests for the user.

### Bad Request (400)

Returned if the request is invalid or the file format is unsupported.

```json theme={null}
{
  "error": "Error message describing the issue"
}
```

### Internal Server Error (500)

Returned if there's an error during the document processing.

```json theme={null}
{
  "error": "Error processing document"
}
```

## Example Request

```bash theme={null}
curl -X POST https://app.dumplingai.com/api/v1/doc-to-text \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "inputMethod": "url",
  "file": "https://example.com/sample.pdf"
}'
```

## Example Response

```json theme={null}
{
  "text": "This is the extracted text content from the document..."
}
```

## Notes

* Supported file formats: PDF and DOCX.
* Maximum file size may be limited (refer to your plan details).
* If using the URL method, ensure the file is publicly accessible.
* This endpoint uses 20 credits per request.
* The file type is automatically detected based on the file content.
* The "pages" field allows you to specify which pages to process:
  * Use comma-separated values or ranges (e.g., "1, 2-" or "1, 2, 3-7").
  * The first page index is 1.
  * Use "!" before a number for inverted page numbers (e.g., "!1" for the last page).
  * If not specified, all pages will be processed by default.
  * The input must be in string format.

## Rate Limiting

Rate limit headers (`X-RateLimit-Limit` and `X-RateLimit-Remaining`) are included in the response to indicate the user's current rate limit status.


## OpenAPI

````yaml POST /api/v1/doc-to-text
openapi: 3.0.3
info:
  title: DumplingAI API
  version: 1.0.0
  description: >
    REST API for DumplingAI's content intelligence and automation platform.

    All endpoints are grouped under `/api/v1`; most are secured via Bearer API
    keys unless an operation explicitly sets `security: []`.
servers:
  - url: https://app.dumplingai.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: YouTube
    description: Access metadata, search results, and transcripts from YouTube.
  - name: TikTok
    description: Retrieve TikTok profile, video, follower, and transcript data.
  - name: LinkedIn
    description: Programmatically fetch LinkedIn company and profile data.
  - name: Search
    description: Search-orientated endpoints spanning web, news, maps, and autocomplete.
  - name: Google
    description: Integrations with Google business listings and location data.
  - name: Scraping
    description: Webpage capture, crawling, and structured content extraction utilities.
  - name: Documents
    description: Document processing, conversion, and metadata utilities.
  - name: AI
    description: DumplingAI agent and knowledge base endpoints.
  - name: Developer Tools
    description: Utilities for executing sandboxed code via API.
paths:
  /api/v1/doc-to-text:
    post:
      tags:
        - Documents
      summary: Convert document to text
      description: >-
        Convert documents such as PDFs, PowerPoints, or Word files into plain
        text.
      operationId: docToText
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocToTextRequest'
            examples:
              default:
                value:
                  inputMethod: url
                  file: https://example.com/report.pdf
                  pages: 1-3,5
      responses:
        '200':
          description: Plain text representation returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocToTextResponse'
        '400':
          description: Invalid request payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    DocToTextRequest:
      type: object
      required:
        - inputMethod
        - file
      properties:
        inputMethod:
          $ref: '#/components/schemas/FileInputMethod'
        file:
          type: string
          description: Document URL or base64-encoded file content to convert to text.
        pages:
          type: string
          description: Optional page ranges to extract (e.g., '1-3,5').
        requestSource:
          $ref: '#/components/schemas/RequestSource'
      additionalProperties: false
    DocToTextResponse:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Plain text extracted from the source document.
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable description of what went wrong.
      required:
        - error
    FileInputMethod:
      type: string
      description: >-
        Indicates whether binary content is supplied via URL or base64-encoded
        string.
      enum:
        - url
        - base64
    RequestSource:
      type: string
      description: Optional identifier describing where the API request originated.
      enum:
        - API
        - WEB
        - MAKE_DOT_COM
        - ZAPIER
        - N8N
        - PLAYGROUND
        - DEFAULT_AUTOMATION
        - AGENT_PREVIEW
        - AGENT_LIVE
        - AUTOPILOT
        - STUDIO
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````