# 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>](https://api.pdf.ai/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>](https://api.pdf.ai/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 %}
