# Welcome to PDF.ai API

## PDF.ai API v2 Documentation

Welcome to PDF.ai API v2! Released on 11/28/2025, this version includes advanced endpoints: `parse`, `extract`, `split`, and `ask`. These features are designed to streamline and enhance your workflow. Below, you will find all the necessary documentation to get started with our API.

### Core APIs

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><strong>Parse</strong></td><td>Parses a PDF into Markdown or JSON with OCR, VLM support.</td><td><a href="/pages/G8SUfMvHexyp0A6YLxoZ">/pages/G8SUfMvHexyp0A6YLxoZ</a></td><td><a href="/files/UQkXitYH2YQGPDWuZSy7">/files/UQkXitYH2YQGPDWuZSy7</a></td></tr><tr><td><strong>Extract</strong></td><td>Exract structured data from PDF documents based on a JSON schema.</td><td><a href="/pages/hRrFswxEOwzaPLMnSI72">/pages/hRrFswxEOwzaPLMnSI72</a></td><td><a href="/files/tkgRx7RipISLQnxTdd2A">/files/tkgRx7RipISLQnxTdd2A</a></td></tr><tr><td><strong>Split</strong></td><td>Divide large PDF files into smaller, more focused documents.</td><td><a href="/pages/CZPm5wK000dBHHiKXmoK">/pages/CZPm5wK000dBHHiKXmoK</a></td><td><a href="/files/lDKmvdDtKuMp2Q0MQkQj">/files/lDKmvdDtKuMp2Q0MQkQj</a></td></tr><tr><td><strong>Ask</strong></td><td>Interact with your PDFs by querying information directly.</td><td><a href="/pages/gT5XY3nokzFuMGLRviPg">/pages/gT5XY3nokzFuMGLRviPg</a></td><td><a href="/files/ErLfb1zChlqVWz035Tmg">/files/ErLfb1zChlqVWz035Tmg</a></td></tr></tbody></table>

## Try in our playground

Explore our intuitive playground where you can upload your documents, apply schemas, and instantly view the results. It's the perfect way to see our API in action and get hands-on experience. Visit the Playground to start experimenting now!

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Parse playground</strong></td><td><a href="https://pdf.ai/parser">https://pdf.ai/parser</a></td></tr><tr><td><strong>Extract playground</strong></td><td><a href="http://pdf.ai/extract">http://pdf.ai/extract</a></td></tr><tr><td><strong>Split playground</strong></td><td><a href="http://pdf.ai/split">http://pdf.ai/split</a></td></tr></tbody></table>

## Start to integrate

To get started with our API, follow this brief guide to learn how to send your first request quickly and easily.

{% content-ref url="/pages/7oS4DXTgEXGL8AcEFthp" %}
[Quick start](/quick-start)
{% endcontent-ref %}


# Quick start

## Get your API keys

Your API requests are authenticated using the API key. Any request that doesn't include an API key will return an error.

You can generate an API key from your [<mark style="color:purple;">Developer</mark>](https://pdf.ai/developer) page at any time.

<figure><img src="/files/Muoir1KJBCQauRlUZlzu" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Your API key is shown only **once** when it is generated. Make sure to note it down securely. If you lost it you can regenerate it again from the same page.
{% endhint %}

## Make your first request

#### Example Parse Request

To make your first API request, use the following command to parse a document:

```javascript
// Using URL
const formData = new FormData();
formData.append('url', 'https://example.com/document.pdf');
formData.append('quality', 'standard');
formData.append('lang_list', JSON.stringify(['en']));
formData.append('llm', 'false');

const response = await fetch('https://pdf.ai/api/v2/parse', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY'
  },
  body: formData
});

const data = await response.json();
```

#### Example Response

Upon a successful request, you will receive a JSON response similar to:

```json
{
  "success": true,
  "markdown": "string",
  "contents": [
    {
      "bbox": [number, number, number, number], // [x0, y0, x1, y1]
      "content": "string",
      "pageNumber": number,
      "type": "string (optional)",
      "imageIds": ["string"] (optional),
      "conf": number (optional),
      "description": "string (optional)"
    }
  ],
  "images": [
    {
      "id": "string",
      "data": "string",
      "pageNumber": number (optional),
      "bbox": [number, number, number, number] (optional),
      "description": "string (optional)"
    }
  ],
  "pageCount": number
}
```


# Parse

Parses a PDF into Markdown or JSON with support for OCR, table formatting, and image extraction. Ideal for content extraction, knowledge base creation, and retrieval-augmented generation (RAG) workflo

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v2/parse`

Returns JSON schema and citations given a `docId` , `url` , or `file`.

#### Caching

When using a `docId` the results of the parse will be cached for subsequent calls with the same settings. Cached responses will result in 0 credits being used. Using a `docId` and caching will also allow you to save credits using the `/extract` and `/split` endpoints too.

#### Sample Requests

{% tabs %}
{% tab title="cURL" %}

```shellscript
curl -X POST https://pdf.ai/api/v2/parse \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/document.pdf" \
  -F "quality=standard" \
  -F "lang_list=[\"en\"]"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://pdf.ai/api/v2/parse"
headers = {"X-API-Key": "YOUR_API_KEY"}

with open("/path/to/document.pdf", "rb") as f:
    files = {"file": f}
    data = {
        "quality": "standard",
        "lang_list": '["en"]'
    }
    response = requests.post(url, headers=headers, files=files, data=data)

print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const FormData = require('form-data');
const fs = require('fs');
const axios = require('axios');

const form = new FormData();
form.append('file', fs.createReadStream('/path/to/document.pdf'));
form.append('quality', 'standard');
form.append('lang_list', '["en"]');

axios.post('https://pdf.ai/api/v2/parse', form, {
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    ...form.getHeaders()
  }
}).then(response => {
  console.log(response.data);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://pdf.ai/api/v2/parse";
$apiKey = "YOUR_API_KEY";

$postFields = [
    'file' => new CURLFile('/path/to/document.pdf'),
    'quality' => 'standard',
    'lang_list' => '["en"]'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: $apiKey"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}
{% endtabs %}

Replace placeholder values like `<YOUR_API_Key>` with your actual values.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Format

Content-Typ&#x65;**:** `multipart/form-data`

#### **Request Parameters**

| Parameter  | Type    | Required | Description                                                    |
| ---------- | ------- | -------- | -------------------------------------------------------------- |
| docId      | string  | No       | Document ID for caching parsed results                         |
| url        | string  | No       | URL of the PDF to parse (alternative to file upload)           |
| file       | File    | No       | PDF file to upload (alternative to URL)                        |
| quality    | string  | No       | Quality to use: 'standard' or 'advanced' (default: 'standard') |
| lang\_list | array   | No       | List of languages to detect (default: \['en'])                 |
| llm        | boolean | No       | Enable LLM processing for images (default: false)              |

#### Quality Options

* **standard**: This is the default and supports language selection for OCR.
* **advanced**: Utilizes Vision Language Models (VLM), potentially offering better accuracy for complex documents, no need to pass the language selection.

#### Response format

{% tabs %}
{% tab title="200 Parsed content" %}
{% code overflow="wrap" %}

```json
{
  "success": true,
  "markdown": "string",
  "contents": [
    {
      "bbox": [number, number, number, number], // [x0, y0, x1, y1]
      "content": "string",
      "pageNumber": number,
      "type": "string (optional)",
      "imageIds": ["string"] (optional),
      "conf": number (optional),
      "description": "string (optional)"
    }
  ],
  "images": [
    {
      "id": "string",
      "data": "string",
      "pageNumber": number (optional),
      "bbox": [number, number, number, number] (optional),
      "description": "string (optional)"
    }
  ],
  "pageCount": number,
  "docId": "string"
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

#### Credit Usage

Credits are based on the parsing quality, page count, and optional LLM processing.

**Cached results use 0 credits.**

| Quality    | Base Cost per Page | LLM Cost(if enabled)                |
| ---------- | ------------------ | ----------------------------------- |
| `standard` | 1 credit           | +1 credit per 5 images (rounded up) |
| `advanced` | 2 credits          | +1 credit per 5 images (rounded up) |

#### Credit Usage Examples

* **10-page document, standard quality, no LLM:**
  * Credits: `1 × 10 = 10 credits`
* **10-page document, advanced quality, no LLM:**
  * Credits: `2 × 10 = 20 credits`
* **10-page document, standard quality, LLM enabled, 12 images:**
  * Base: `1 × 10 = 10 credits`
  * LLM: `1 × ceil(12 / 5) = 1 × 3 = 3 credits`
  * Total: `13 credits`
* **Cached result (any configuration):**
  * Credits: `0 credits`


# Extract

Exract structured data from PDF documents based on a JSON schema. It returns the extracted data and citations linking each field to its source segments in the document. Use this endpoint when you need structured information from PDFs with traceable source references.

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v2/extract`

Returns JSON schema and citations given a `docId` , `url` , or `file`.

#### Caching

{% hint style="info" %}
If a `docId` is passed, no parsing credits will be used. However, if a `file` or `url` is used, parsing credits will apply during the extract call. The `docId` will be returned after this call, allowing users to use it in future extract requests without incurring additional parsing credits.
{% endhint %}

#### Sample Code

Here are examples of how to use the extraction API in different programming languages.

{% tabs %}
{% tab title="Curl" %}

```shellscript
curl -X POST https://pdf.ai/api/v2/extract \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "docId=your-document-id" \
  -F 'schema={"type":"object","properties":{"title":{"type":"string"},"author":{"type":"string"}},"required":["title"]}' \
  -F "system_prompt=Extract document metadata accurately."
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://pdf.ai/api/v2/extract"
headers = {"X-API-Key": "YOUR_API_KEY"}

schema = {
    "type": "object",
    "properties": {
        "title": {"type": "string"},
        "author": {"type": "string"}
    },
    "required": ["title"]
}

data = {
    "docId": "your-document-id",
    "schema": json.dumps(schema),
    "system_prompt": "Extract document metadata accurately."
}

response = requests.post(url, headers=headers, data=data)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const FormData = require('form-data');
const axios = require('axios');

const schema = {
  type: "object",
  properties: {
    title: { type: "string" },
    author: { type: "string" }
  },
  required: ["title"]
};

const form = new FormData();
form.append('docId', 'your-document-id');
form.append('schema', JSON.stringify(schema));
form.append('system_prompt', 'Extract document metadata accurately.');

axios.post('https://pdf.ai/api/v2/extract', form, {
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    ...form.getHeaders()
  }
}).then(response => {
  console.log(response.data);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://pdf.ai/api/v2/extract";
$apiKey = "YOUR_API_KEY";

$schema = json_encode([
    "type" => "object",
    "properties" => [
        "title" => ["type" => "string"],
        "author" => ["type" => "string"]
    ],
    "required" => ["title"]
]);

$postFields = [
    'docId' => 'your-document-id',
    'schema' => $schema,
    'system_prompt' => 'Extract document metadata accurately.'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: $apiKey"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}
{% endtabs %}

Replace placeholder values like `<YOUR_API_Key>` with your actual values.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Format

Content type: multipart/form-data

#### **Request Parameters**

| Parameter      | Type          | Required | Description                                                               |
| -------------- | ------------- | -------- | ------------------------------------------------------------------------- |
| schema         | string (JSON) | Yes      | JSON schema defining the structure to extract                             |
| system\_prompt | string        | No       | Custom system prompt for extraction (default: "Be precise and thorough.") |
| docId          | string        | No       | Document ID for caching parsed results                                    |
| url            | string        | No       | URL of the PDF to parse (alternative to file upload)                      |
| file           | File          | No       | PDF file to upload (alternative to URL)                                   |
| quality        | string        | No       | Quality to use: 'standard' or 'advanced' (default: 'standard')            |
| lang\_list     | array         | No       | List of languages to detect (default: \['en'])                            |

#### Response format

{% tabs %}
{% tab title="200 Parsed content" %}
{% code overflow="wrap" %}

```json
{
  "success": true,
  "data": {
    "result": { /* extracted data matching your schema */ },
    "citations": [
      {
        "content": "string",
        "pageNumber": number,
        "schemaLink": "string" // e.g. result.people[2].name
      }
    ]
  },
  "docId": "string"
}

```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

#### Credit Usage

Before extracting data from a PDF, the document must be parsed, which will incur credit usage unless a cached parsed result is available. See parse credit usage [here](/v2/parse).

| Component          | Condition             | Credit Calculation     |
| ------------------ | --------------------- | ---------------------- |
| Extraction Credits | Schema has ≤ 5 fields | 2 credits × page count |
| Extraction Credits | Schema has > 5 fields | 4 credits × page count |

#### Total Credit Formula

`Total credits = Parse credits + Extraction credits`

**Examples**

* **10-page document**, not cached parse, advanced quality, schema with 3 fields
  * Parse Credits: 2 × 10 = 20 credits
  * Extraction Credits: 2 × 10 = 20 credits
  * Total: 40 credits
* **5-page document**, cached parse, schema with 8 fields
  * Parse Credits: 0 credits (cached)
  * Extraction Credits: 4 × 5 = 20 credits
  * Total: 20 credits


# Split

Identify sections in PDF documents based on provided descriptions. Split analyzes the document and returns which pages contain each section, along with confidence levels. Use this endpoint when you need to locate specific sections within a document.

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v2/split`

Returns JSON schema and citations given a `docId` , `url` , or `file`.

#### Caching

{% hint style="info" %}
If a `docId` is passed, no parsing credits will be used. However, if a `file` or `url` is used, parsing credits will apply during the split call. The `docId` will be returned after this call, allowing users to use it in future split requests without incurring additional parsing credits.
{% endhint %}

#### Sample Code

Below are examples of how to use the `split` endpoint with different programming languages.

{% tabs %}
{% tab title="cURL" %}

```shellscript
curl -X POST https://pdf.ai/api/v2/split \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "docId=your-document-id" \
  -F 'split_description=[{"name":"Introduction","description":"Opening section"},{"name":"Conclusion","description":"Summary section"}]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://pdf.ai/api/v2/split"
headers = {"X-API-Key": "YOUR_API_KEY"}

split_description = [
    {"name": "Introduction", "description": "Opening section"},
    {"name": "Conclusion", "description": "Summary section"}
]

data = {
    "docId": "your-document-id",
    "split_description": json.dumps(split_description)
}

response = requests.post(url, headers=headers, data=data)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const FormData = require('form-data');
const axios = require('axios');

const splitDescription = [
  { name: "Introduction", description: "Opening section" },
  { name: "Conclusion", description: "Summary section" }
];

const form = new FormData();
form.append('docId', 'your-document-id');
form.append('split_description', JSON.stringify(splitDescription));

axios.post('https://pdf.ai/api/v2/split', form, {
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    ...form.getHeaders()
  }
}).then(response => {
  console.log(response.data);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://pdf.ai/api/v2/split";
$apiKey = "YOUR_API_KEY";

$splitDescription = json_encode([
    ["name" => "Introduction", "description" => "Opening section"],
    ["name" => "Conclusion", "description" => "Summary section"]
]);

$postFields = [
    'docId' => 'your-document-id',
    'split_description' => $splitDescription
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: $apiKey"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}
{% endtabs %}

Please replace placeholders like `<YOUR_API_Key>` with actual values.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Format

Content type: multipart/form-data

#### Request Parameters

| Parameter          | Type          | Required | Description                                                                                            |
| ------------------ | ------------- | -------- | ------------------------------------------------------------------------------------------------------ |
| split\_description | string (JSON) | Yes      | JSON array of section descriptions to find. Each object must have a name and optionally a description. |
| docId              | string        | No       | Document ID for caching parsed results.                                                                |
| url                | string        | No       | URL of the PDF to parse (alternative to file upload).                                                  |
| file               | File          | No       | PDF file to upload (alternative to URL).                                                               |
| quality            | string        | No       | Quality to use: 'standard' or 'advanced' (default: 'standard').                                        |
| lang\_list         | array         | No       | List of languages to detect (default: \['en']).                                                        |

#### Split Description Format

The `split_description` parameter must be a JSON array of objects:

```json
[
  {
    "name": "Introduction",
    "description": "Opening section that introduces the topic"
  },
  {
    "name": "Conclusion"
  }
]
```

#### Response format

{% tabs %}
{% tab title="200 Parsed content" %}
{% code overflow="wrap" %}

```json
{
  "success": true,
  "result": {
    "splits": [
      {
        "name": "Introduction",
        "pages": [1, 2, 3],
        "conf": "high"
      },
      {
        "name": "Conclusion",
        "pages": [45, 46],
        "conf": "medium"
      }
    ]
  },
  "docId": "string"
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

#### Credit Usage

Before splitting data from a PDF, the document must be parsed, which will incur credit usage unless a cached parsed result is available. See parse credit usage [here](/v2/parse).

| Component     | Condition      | Credit Calculation     |
| ------------- | -------------- | ---------------------- |
| Split Credits | Always charged | 2 credits × page count |

#### Total Credit Formula

`Total credits = Parse credits + Split credits`

#### Examples

* **10-page document, cached**
  * Parse Credits: 0 credits (cached)
  * Split Credits: 2 × 10 = 20 credits
  * Total: 20 credits
* **5-page document, not cached, advanced quality**
  * Parse Credits: 2 × 5 = 10 credits
  * Split Credits: 2 × 5 = 10 credits
  * Total: 20 credits


# Ask

Ask questions about your parsed PDF documents and get answers. You can query multiple documents at once. Includes the full document context for precise answers.

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v2/ask`

`prompt` one or more of your parsed documents (`docIds`) and get an answer based on their content.

#### Previously Parsed Documents

To use this endpoint the provided document IDs must have been previously parsed. See the [Parse](/v2/parse) endpoint here.

#### Sample Requests

Here's how you can make requests to the endpoint using different programming languages.

{% tabs %}
{% tab title="cURL" %}

```shellscript
curl -X POST https://pdf.ai/api/v2/ask \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "What is the main topic of this document?",
    "docIds": ["your-document-id-1", "your-document-id-2"]
  }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://pdf.ai/api/v2/ask"
headers = {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "prompt": "What is the main topic of this document?",
    "docIds": ["your-document-id-1", "your-document-id-2"]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const axios = require('axios');

axios.post('https://pdf.ai/api/v2/ask', 
  {
    prompt: 'What is the main topic of this document?',
    docIds: ['your-document-id-1', 'your-document-id-2']
  },
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    }
  }
).then(response => {
  console.log(response.data);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://pdf.ai/api/v2/ask";
$apiKey = "YOUR_API_KEY";

$data = json_encode([
    "prompt" => "What is the main topic of this document?",
    "docIds" => ["your-document-id-1", "your-document-id-2"]
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-API-Key: $apiKey",
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}
{% endtabs %}

Please replace placeholders like `<YOUR_API_Key>` with actual values.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Format

Content-Type: application/json

#### Request Parameters

| Parameter | Type      | Required | Description                                                           |
| --------- | --------- | -------- | --------------------------------------------------------------------- |
| prompt    | string    | Yes      | The question or query you want to ask about the documents.            |
| docIds    | string\[] | Yes      | Array of document IDs to query. All documents must be already parsed. |

#### Response format

{% tabs %}
{% tab title="200 Parsed content" %}
{% code overflow="wrap" %}

```json
{
  "success": true,
  "answer": "The main topics discussed in these documents are..."
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

#### Credit Usage

Credits are calculated based on the total number of pages across all documents queried

| Component   | Condition      | Credit Calculation           |
| ----------- | -------------- | ---------------------------- |
| Ask credits | Always charged | 3 credits × total page count |

#### Total Credit Formula

`Total credits = Total page count * 3`

#### Example

* Document 1: 10 pages
* Document 2: 5 pages
* Total Credits Used: (10 + 5) × 3 = 45 credits


# Delete

Permanently deletes a document and all associated data that was created by the v2 parse, extract, or split endpoints. This includes the document record, the uploaded PDF file in storage, and the cached parse results.

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v2/delete`

{% hint style="warning" %}
This endpoint only works for documents created via v2 parse, extract, or split endpoints.

Deletion is permanent and cannot be undone.
{% endhint %}

#### Sample Code

Below are examples of how to use the `delete` endpoint with different programming languages.

{% tabs %}
{% tab title="Curl" %}

```shellscript
curl -X POST https://pdf.ai/api/v2/delete \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"docId": "your-document-id"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://pdf.ai/api/v2/delete"
headers = {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {"docId": "your-document-id"}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const axios = require('axios');

axios.post('https://pdf.ai/api/v2/delete', 
  { docId: 'your-document-id' },
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    }
  }
).then(response => {
  console.log(response.data);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://pdf.ai/api/v2/delete";
$apiKey = "YOUR_API_KEY";

$data = json_encode(["docId" => "your-document-id"]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-API-Key: $apiKey",
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

{% endtab %}
{% endtabs %}

Please replace placeholders like `<YOUR_API_Key>` with actual values.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Format

Content-Type: application/json

#### Request Parameters

| Parameter | Type   | Required | Description                                        |
| --------- | ------ | -------- | -------------------------------------------------- |
| docId     | string | Yes      | Document ID returned from Parse, Extract, or Split |

#### Response format

{% tabs %}
{% tab title="Success Response (200)" %}
{% code overflow="wrap" %}

```json
{
  "success": true,
  "message": "Document and all associated data deleted successfully"
}
```

{% endcode %}
{% endtab %}

{% tab title="400 Bad Request - Missing docId " %}

```json
{ "error": "docId is required" }
```

{% endtab %}

{% tab title="400 Bad Request - Not a v2 document" %}

```json
{ 
  "error": "This document was not created by v2 parse, extract, or split endpoints",
  "hint": "Use the v1 delete endpoint for other documents"
}
```

{% endtab %}

{% tab title="404 Not Found" %}
{ "error": "Invalid API key" }
{% endtab %}

{% tab title="401 Unauthorized" %}

{% endtab %}
{% endtabs %}

#### Credit Usage

Free - no API credits are charged for delete operations.


# Credit usage

### Credit Usage

Understanding how credits are utilized within our plans is crucial for efficient resource management. Below is a detailed explanation of credit consumption for various features:

#### 📄 Parse ([example](/v2/parse#credit-usage-examples)):

* **Standard (OCR): 1 credit/page**
* **Advanced (VLM): 2 credits/page**\
  *Additional credits may apply if images require LLM analysis.*

#### 🔍 Extract ([example](/v2/extract#total-credit-formula)):

* **Standard: 2 credits/page**
* **Advanced: 4 credits/page**\
  *Parsing credits are necessary if no cached result is available.*

#### ✂️ Split ([example](/v2/split#total-credit-formula)):

* **2 credits/page**\
  *Parsing credits are required if no cached result is available.*

#### 💬 Ask ([example](/v2/ask#total-credit-formula)):

* **3 credits/page**\
  *Note: Document must be parsed first to obtain docId.*

#### 🗑️ Delete:

* **No cost**

***

### API plan

For more details and to pick the plan that best suits your needs, visit our [developer](https://pdf.ai/developer) page, and click **Manage Plan** button.

<figure><img src="/files/SBXd2aF6F6gDuyTC9BsW" alt=""><figcaption></figcaption></figure>

#### Free plan:

* **$0/month** for 200 credits per month\
  🎁 *No credit card required to get started.*

#### Paid plan:

* **$49/month** for 3,000 credits per month ($0.016/credit)
* **$99/month** for 10,000 credits per month ($0.010/credit)
* **$249/month** for 30,000 credits per month ($0.008/credit)
* **$599/month** for 100,000 credits per month ($0.006/credit)
* [**Contact us**](mailto:support@pdf.ai) for more than 100,000 credits per month


# Upload PDF

This API supports PDF uploads through two different methods: [**URL Upload**](#upload-pdf-using-url) and [**File upload**](#upload-pdf-using-file). Below are the specifications and limitations for each method

## Upload PDF using URL

**Limitation**

* **Timeout Limit:** 300 seconds

{% hint style="info" %}
There is no specific file size limit for this method; however, the URL must be accessible, and the upload process needs to be completed within the 300-second timeout limit.
{% endhint %}

## Upload PDF using URL

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/upload/url`

To get the document ID `docId` for the PDF

#### Headers

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| X-API-Key | string | \<API-Key>  |

#### Request Body

| Name                                  | Type    | Description                                                                          |
| ------------------------------------- | ------- | ------------------------------------------------------------------------------------ |
| url<mark style="color:red;">\*</mark> | string  | URL of your PDF file                                                                 |
| isPrivate                             | boolean | If your PDF file is private(true or false)                                           |
| ocr                                   | boolean | Enable Optical Character Recognition. Make the text of a scanned document searchable |
| tags                                  | array   | <p>List of tags to associate with the document<br>e.g., \["Tag1", "Tag2"]</p>        |

{% tabs %}
{% tab title="200 PDF is successfully uploaded" %}

```json
{
    "docId": "abcdxxxxxxx"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or URL is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

## Upload PDF using file

**Limitation**

* **Timeout Limit:** 300 seconds
* **File Size Limit:** 4.5 MB

{% hint style="info" %}
If the PDF file size exceeds 4.5 MB, it is recommended to use the URL Upload Method instead, to avoid any upload failures or delays.
{% endhint %}

## Upload PDF using file

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/upload/file`

To get the document ID `docId` for the PDF

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Body

| Name                                   | Type     | Description                                                                          |
| -------------------------------------- | -------- | ------------------------------------------------------------------------------------ |
| file<mark style="color:red;">\*</mark> | FormData | PDF file form data                                                                   |
| isPrivate                              | boolean  | If your PDF file is private(true or false)                                           |
| ocr                                    | boolean  | Enable Optical Character Recognition. Make the text of a scanned document searchable |
| tags                                   | array    | <p>List of tags to assciate with the document<br>e.g., \["Tag1"]</p>                 |

{% tabs %}
{% tab title="200 PDF is successfully uploaded" %}

```json
{
    "docId": "abcdxxxxxxx"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or file is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you receive a 500 error code when OCR is enabled, it is likely because your document is too large, causing the upload process to exceed the 300-second timeout. To avoid this, please perform OCR on your document before using our upload API.
{% endhint %}


# OCR an uploaded PDF

You can pass `ocr=true` in our upload endpoint, but if you forgot to do so, you can use this endpoint to perform OCR (Optical Character Recognition) on a document after it is uploaded **without consuming additional API credits**. To use this you need `docId` of the document.

### **Limitations**

* **Timeout Limit:** 300 seconds
* **File Size Limit**: 50 MB

{% hint style="info" %}
If the document has a large number of pages, the OCR process may result in a timeout error
{% endhint %}

## OCR a document

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/ocr`

To get the OCR of the PDF using `docId`

#### Headers

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| X-API-Key | string | \<API-Key>  |

#### Request Body

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| docId<mark style="color:red;">\*</mark> | string | Document ID obtained after uploading PDF |
| ocrLang                                 | string | OCR language. Default: "eng"             |

{% tabs %}
{% tab title="200 PDF is successfully uploaded" %}

```json
{
    "message": "OCR applied successfully!"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId present or document is private" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}

{% tab title="500:  Failed to apply OCR due to timeout" %}

<pre class="language-json"><code class="lang-json">{ 
<strong>    "error": "Failed to apply OCR. Try again."
</strong>}
</code></pre>

{% endtab %}
{% endtabs %}


# Update tags for an uploaded PDF

You can pass tags in our upload endpoint, but if you forgot to do so, you can use this endpoint to add/update/remove tags for a document using its `docId`. This endpoint **will not** consume any API credits from your plan.

Whatever tags you want to have for the document, include all of them in the array which is going to replace the list of tags associated with the document

{% hint style="warning" %}
To remove the tags for the document, use the empty array(\[])
{% endhint %}

## Document tags

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/tags`

To update the tags of a document using its `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Body

| Name                                    | Type   | Description                                                                                                                     |
| --------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------- |
| docId<mark style="color:red;">\*</mark> | string | Document ID obtained after uploading PDF                                                                                        |
| tags<mark style="color:red;">\*</mark>  | array  | <p>Tags you want to have for the document<br>e.g., \["Tag1", "Tag2"]<br><br>To remove the tags use empty array<br>e.g., \[]</p> |

{% tabs %}
{% tab title="200 Summary of the PDF" %}

```json
{
    "message": "Successfully updated tags!"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId or tags is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# Get single document

Using `/documents/<docId>` endpoint you can get the details of the Document ID (`docId`) specified.&#x20;

#### The document will have the following fields:

* `id` - docId of the PDF
* `name` - name of the uploaded PDF
* `size` - size of the PDF in bytes
* `isPublic` - boolean(true or false)
* `uploadedAt` - PDF upload timestamp
* `url` - URL of the PDF
* `tags` - List of tags associated with the document
* `importUrl` - source URL of the imported PDF if any

## Document

## Get single document

<mark style="color:blue;">`GET`</mark> `https://pdf.ai/api/v1/documents/{docId}`

To get the uploaded document using its `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

{% tabs %}
{% tab title="200 Details of the document" %}

```json
{
  "id": "efghxxxxxxx",
  "name": "efgh.pdf",
  "size": 123456,
  "isPublic": true,
  "uploadedAt": "2023-08-09T06:16:58.750Z",
  "url": "https://cdn.openai.com/papers/gpt-4.pdf",
  "importUrl": "https://cdn.example.com/doc1.pdf",
  "tags": ["Tag1", "Tag2"],
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="404 Not found" %}

```json
{
    "error": "No document found!"
}
```

{% endtab %}
{% endtabs %}


# Get all documents

Using `/documents` endpoint you can get the details of all the PDF documents uploaded along with their `docIds`.

#### Each document will have the following fields:

* `id` - docId of the PDF
* `name` - name of the uploaded PDF
* `size` - size of the PDF in bytes
* `isPublic` - boolean(true or false)
* `uploadedAt` - PDF upload timestamp
* `url` - URL of the PDF
* `importUrl` - source URL of the imported PDF if any

## Documents

## Get all documents

<mark style="color:blue;">`GET`</mark> `https://pdf.ai/api/v1/documents`

To get the uploaded documents and their docIds.

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

{% tabs %}
{% tab title="200 List of the uploaded documents" %}

```json
{
  "data": [
    {
      "id": "abcdxxxxxxx",
      "name": "abcd.pdf",
      "size": 123456,
      "isPublic": true,
      "uploadedAt": "2023-08-09T06:20:02.854Z",
      "url": "https://cdn.openai.com/papers/gpt-4.pdf",
      "importUrl": "https://cdn.example.com/doc1.pdf"
    },
    {
      "id": "efghxxxxxxx",
      "name": "efgh.pdf",
      "size": 123456,
      "isPublic": false,
      "uploadedAt": "2023-08-09T06:16:58.750Z",
      "url: "",
      "importUrl": ""
    }
  ]
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}
{% endtabs %}


# Chat with PDF

To chat with a PDF you need `docId` of the PDF. To get `docId` [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) the PDF first.

{% hint style="info" %}
Using the <mark style="color:blue;">`save_chat`</mark> option you can save chat history and can find the same  in PDF.ai/documents/\<docId>
{% endhint %}

To delete the chat you need to delete the PDF document using [<mark style="color:blue;">delete</mark>](/v1/delete-pdf) API.

{% hint style="info" %}
You can make use of the powerful GPT-4 model to get better answers using <mark style="color:blue;">`use_gpt4`</mark> field in the request body. You can choose a specific model between **gpt-4-turbo** and **gpt-4o** using <mark style="color:blue;">model</mark> field
{% endhint %}

> Note: There use to be `chatId` field previously for saving chat but now it's\
> deprecated. You just need to use `save_chat` field in order to save your chat history now.

## Chat with PDF

## Chat with a PDF

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/chat`

Ask questions to get responses from the PDF using `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                      | Type    | Description                                                                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| docId<mark style="color:red;">\*</mark>   | string  | Document ID obtained after uploading PDF                                                                                                 |
| save\_chat                                | boolean | Option to save chat history                                                                                                              |
| message<mark style="color:red;">\*</mark> | string  | Message or question you want to get answer from PDF                                                                                      |
| use\_gpt4                                 | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p>                                                                 |
| model                                     | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.</p> |
| language                                  | string  | Response language e.g., "french"                                                                                                         |
| sys\_prompt                               | string  | Customized system prompt                                                                                                                 |

{% tabs %}
{% tab title="200 Response to your message or question" %}

```json
{
   "content": "This is the answer to your message or question",
   "references": [
      {
         "pageNumber": 71,
         "fromLine": 41,
         "toLine": 48
      }
   ]
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId or message is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# Chat with all PDFs

To chat with all PDFs you just need to have at least one PDF uploaded using the [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) API endpoint.

{% hint style="info" %}
Using the `save_chat` option you can save chat all history and can find the same  in PDF.ai/documents/chat/all
{% endhint %}

## Chat with all PDFs

## Chat with all PDFs

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/chat-all`

Ask questions to get responses from any PDF

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                      | Type    | Description                                                                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| save\_chat                                | boolean | Option to save chat history                                                                                                              |
| message<mark style="color:red;">\*</mark> | string  | Message or question you want to get answer from PDF                                                                                      |
| use\_gpt4                                 | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p>                                                                 |
| model                                     | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.</p> |
| language                                  | string  | Response language e.g., "french"                                                                                                         |
| tag                                       | string  | To filter results based on tag, e.g., "Books"                                                                                            |
| topMatches                                | number  | <p>Max number of relevant or best-matched documents to consider for answering the query<br>Default: 10</p>                               |
| sys\_prompt                               | string  | Customized system prompt                                                                                                                 |

{% tabs %}
{% tab title="200 Response to your message or question" %}

```json
{
   "content": "This is the answer to your message or question",
   "references": [
      {
         "pageNumber": 71,
         "fromLine": 41,
         "toLine": 48,
         "docId": "abcd1234",
         "url": "https://cdn.openai.com/papers/gpt-4.pdf",
      }
   ]
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or message is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# Chat history

To get the chat history of a PDF you need `docId` of that PDF.&#x20;

Using `/v1/history` API you can get the complete chat history in the desired number of pages and in the desired order.

{% hint style="info" %}
Ensure that when you call the [Chat with PDF](/v1/chat-with-pdf) API, you set `save_chat` to true to let the chat history to be saved.
{% endhint %}

## Chat history of a PDF

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/history`

To get the chat history of the PDF using its `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Body

| Name                                    | Type   | Description                                                                                   |
| --------------------------------------- | ------ | --------------------------------------------------------------------------------------------- |
| docId<mark style="color:red;">\*</mark> | string | Document ID obtained after uploading PDF                                                      |
| resultsPerPage                          | number | Number of results you want per page. Default: 10. Max: 100                                    |
| pageNumber                              | number | <p>Page number you want results from <br>Default: 1</p>                                       |
| sortOrder                               | string | <p>Order of the messages<br>"asc" for ascending, "desc" for descending<br>Default: "desc"</p> |

{% tabs %}
{% tab title="200 History of the PDF" %}
{% code overflow="wrap" %}

```json
{
    "messages": [
        {
            "role": "assistant",
            "content": "It is in Japan",
            "createdAt": "2024-10-16T06:58:03.044Z",
            "references": [
              {
                 "pageNumber": 1,
                 "fromLine": 41,
                 "toLine": 48
              }
             ]
        },
        {
            "role": "user",
            "content": "Where is Tokyo?",
            "createdAt": "2024-10-16T06:58:03.043Z",
            "references": []
        }
    ],
    "totalMessages": 8,
    "totalPages": 1,
    "currentPage": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# Summarize PDF

To get the summary of a PDF you just need `docId` of the PDF. To get `docId` [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) the PDF first.

You can get the summary in the language you want using the `language` field. The default language is English.

{% hint style="warning" %}
The summary result will not be saved as a Chat. To save your chat history use [<mark style="color:blue;">chat</mark>](/v1/chat-with-pdf) API
{% endhint %}

## Summary of the PDF

## Summarize a PDF

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/summary`

To get the summary of the PDF using its `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Body

| Name                                    | Type    | Description                                                              |
| --------------------------------------- | ------- | ------------------------------------------------------------------------ |
| docId<mark style="color:red;">\*</mark> | string  | Document ID obtained after uploading PDF                                 |
| language                                | string  | Summary language e.g., "french"                                          |
| use\_gpt4                               | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p> |
| model                                   | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default)</p>       |

{% tabs %}
{% tab title="200 Summary of the PDF" %}

```json
{
    "content": "This is the summary of the PDF"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# Delete PDF

You can delete your PDF and your chats using `docId`. To get `docId` [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) the PDF first.

{% hint style="danger" %}
When you delete the PDF, you also delete the chat history of it
{% endhint %}

## Delete PDF

## Delete a PDF

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/delete`

Delete uploaded PDF with chats using `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| docId<mark style="color:red;">\*</mark> | string | Document ID obtained after uploading PDF |

{% tabs %}
{% tab title="200 Success message if PDF is deleted successfully" %}

```json
{
    "message": "Successfully deleted!"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}

{% tab title="404: Not Found Give docId PDF is not present" %}

```json
{
    "error": "Document with given docId not found!"
}
```

{% endtab %}
{% endtabs %}


# Parse

Parses a PDF into Markdown with support for chunking, table formatting, and inline image embedding via data URLs. Ideal for content extraction, knowledge base creation, and retrieval-augmented generation (RAG) workflows.

## Parse a PDF

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/parse`

Returns markdown of a PDF using a `docId` *or* a `url` .

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-Key>  |

#### Request Body

| Name  | Type    | Description                                                                          |
| ----- | ------- | ------------------------------------------------------------------------------------ |
| docId | string  | Document ID obtained after uploading a PDF                                           |
| url   | string  | Instead of a `docId` supply a PDF URL.                                               |
| llm   | boolean | Improve accuracy by using a LLM. Defaults to `false`                                 |
| chunk | "page"  | If set to "page" chunks content according to document page. Defaults to entire text. |

{% tabs %}
{% tab title="200 Parsed content" %}
{% code overflow="wrap" %}

```json
{
    "success": true,
    "url": "https://example.com/document.pdf",
    "content": "The page content."
}
```

{% endcode %}
{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}

#### Credit Usage

Every document processing request uses credits based on the parsing mode:

* **Non-LLM Parsing**: 1 credit for up to every 5 pages (e.g., a 12-page document uses 3 credits).
* **LLM Parsing**: 2 credits for up to every 5 pages (e.g., a 12-page document uses 6 credits).


# AI Tools

API endpoints for the PDF tools

Here is the list of specific API endpoints that you can use to extract relevant info from certain PDF documents

1. [<mark style="color:blue;">Invoice JSON</mark>](/v1/ai-tools/invoice-json) (Extract invoice data in JSON format)
2. [<mark style="color:blue;">Resume scanner</mark>](/v1/ai-tools/resume-scanner) (Get the resume overview or query candidate details)


# Invoice JSON

To get the invoice data in JSON format, you need `docId` of the PDF. To get `docId` [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) the PDF first.

{% hint style="warning" %}
The invoice result will not be saved as a Chat. To save your chat history use [<mark style="color:blue;">chat</mark>](/v1/chat-with-pdf) API
{% endhint %}

## Invoice

## Invoice JSON

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/invoice`

Get desired JSON formatted responses from the invoice PDF using `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                      | Type    | Description                                                                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| docId<mark style="color:red;">\*</mark>   | string  | Document ID obtained after uploading PDF                                                                                                 |
| message<mark style="color:red;">\*</mark> | string  | Your query or JSON format details                                                                                                        |
| use\_gpt4                                 | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p>                                                                 |
| model                                     | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.</p> |

{% tabs %}
{% tab title="200 JSON formatted response as per your message" %}

```json
{
  "content": {
    "products": [
      {
        "name": "First product",
        "quantity": 30
      },
      {
        "name": "Second product",
        "quantity": 20
      }
    ]
  }
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId or message is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}

{% tab title="404: Not Found Valid JSON response is not found" %}

```json
{
    "error": "Failed to get JSON formatted answer, try again!"
}
```

{% endtab %}
{% endtabs %}


# Resume scanner

You can get the overview of a resume along with important questions to assess candidates using the `docId` of the PDF. To get `docId` [<mark style="color:blue;">upload</mark>](/v1/upload-pdf) the PDF first.

{% hint style="warning" %}
The resume result will not be saved as a Chat. To save your chat history use [<mark style="color:blue;">chat</mark>](/v1/chat-with-pdf) API
{% endhint %}

## Invoice

## Resume scanner

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/resume`

Assess candidate resume using their `docId`

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                    | Type    | Description                                                                                                                              |
| --------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| docId<mark style="color:red;">\*</mark> | string  | Document ID obtained after uploading PDF                                                                                                 |
| message                                 | string  | You can add a specific question or leave it empty                                                                                        |
| use\_gpt4                               | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p>                                                                 |
| model                                   | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.</p> |

{% tabs %}
{% tab title="200 Resume overview/response to the query" %}

```json
{
    "content": "This is the overview of the candidate's resume"
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or docId or message is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}


# API limits

Our API is accessible through a [dedicated API plan](#dedicated-api-plan).

{% hint style="info" %}
The Ultimate plan is designed for personal and non-commercial use, with a lower limit. We recommend considering our dedicated API plan if you need to utilize our API for commercial purposes and require a higher limit.
{% endhint %}

### Ultimate plan \[Old plan no longer supported]

#### Non-commercial use limit&#x20;

* No limit on the number of pages of PDF
* 100 PDF upload requests/month
* 1,000 chat requests/month
* Max. 50MB/PDF upload via [URL upload](/v1/upload-pdf#upload-pdf-using-url), 4.5MB/PDF upload via [file upload](/v1/upload-pdf#upload-pdf-using-file)
* Timeout of 60 seconds when uploading PDFs having a large number of pages e.g, 1000, 2000 pages, etc

### Dedicated API plan

{% hint style="info" %}
You can buy the plan that suits your actual API usage based on the following credits:\
2 credits/file upload, 1 credit/gpt-3.5-turbo or gpt-4o-mini message, 2 credits/gpt-4o message, 4 credits/gpt-4-turbo message.

* $50/mo for 1,000 credits (14-day free trial, risk-free to try it out)
* $112/mo for 2,500 credits
* $200/mo for 5,000 credits
* $350/mo for 10,000 credits
* Contact us for 10,000+ credits
  {% endhint %}

#### Usage limits:

* No limit on the number of pages of PDF
* Custom number of API credits/month (see above)
* 500 requests/minute
* Max. 100MB/PDF upload via [URL upload](/v1/upload-pdf#upload-pdf-using-url), 4.5MB/PDF upload via [file upload](/v1/upload-pdf#upload-pdf-using-file)
* Timeout of 60 seconds when uploading PDFs having a large number of pages, e.g, 1000, 2000 pages, etc


