# Retrieve invoice as PDF

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Gets the invoice as PDF. The returned URL is secure and allows download. The URL will expire in 60 minutes.

#### Related Tutorial[](#related-tutorial)

-   [Check out customer portal tutorial on how to download invoice as PDF.](https://www.chargebee.com/tutorials/customer-portal-sample.html#downloading_invoices_as_pdf)

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/__demo_inv__18/pdf \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.Pdf("__demo_inv__18").Request();

Download download = result.Download;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.Pdf("__demo_inv__18", nil).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Download := res.Download
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.InvoicePdfRequest{}
  res, err := client.Invoice.Pdf("__demo_inv__18", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Download := res.Download
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Invoice.pdf("__demo_inv__18").request();

        Download download = result.download();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.download.Download;
import com.chargebee.v4.models.invoice.params.InvoicePdfParams;
import com.chargebee.v4.models.invoice.responses.InvoicePdfResponse;

public class InvoicePdf {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        InvoicePdfResponse response = client.invoices().pdf("__demo_inv__18");

        Download download = response.getDownload();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.invoice.pdf("__demo_inv__18");

    console.log(result);
    const download = result.download;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->invoice()->pdf("__demo_inv__18");
$download = $result->download;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.pdf("__demo_inv__18")
download = response.download
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Invoice.pdf("__demo_inv__18")

download = result.download
```

## Sample Response

```json
{
  "download": {
    "download_url": "https://cb-local-downloads.s3.amazonaws.com/yourapp/invoice/__test__8asyKSOcTMNf4r.pdf?response-content-disposition=attachment%3Bfilename%3Dyourapp%2Finvoice%2F__test__8asyKSOcTMNf4r.pdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210210T130447Z&X-Amz-SignedHeaders=host&X-Amz-Expires=599&X-Amz-Credential=AKIAJI4SN7ONHAOGLOGA%2F20210210%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=dcf3b55c68ba695edded4a3d6305cb3822415601c590ad6293cfb858514078e6",
    "object": "download",
    "valid_till": 1612962887
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/invoices/{invoice-id}/pdf

## Input Parameters

- `disposition_type` (optional, enumerated string, default=attachment)
  Determines the pdf should be rendered as inline or attachment in the browser.
  Possible enum values:
    - `attachment`
      PDF is rendered as attachment in the browser
    - `inline`
      PDF is rendered as inline in the browser

## Returns

- `download` (Download object)
  Resource object representing download
