---
title: Downloading reports via the Amazon Pay Reports API
url: amazon-pay-reports/downloading-reports.html
---

You can manually download settlement and transaction reports from Seller Central:

**Settlement reports**: click *Payments* from the *Reports* menu.  
**Transaction reports**: click *Payments Transactions Reports* from the *Reports* menu.

Note that manually requested reports will also be returned in the response of [Get Reports](../amazon-pay-reports/managing-reports.html#step-2-get-a-list-of-generated-reports) operation.

<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> Sandbox support only exists for the Sandbox Settlement Report. All other report types are not available in sandbox.</div>

<!-- prettier-ignore-start -->
* TOC
{:toc}
{::options toc_levels="3" /}

***
<!-- prettier-ignore-end -->

### Step1: Authentication

If you are using one of the Amazon Pay CV2 API SDKs, your SDK handle authentication for you, using the same keys and credentials as for your payment integration.

If you are new to CV2 APIs and SDKs, please follow the *[Download the Amazon Pay SDKs](https://developer.amazon.com/docs/amazon-pay-checkout/get-set-up-for-integration.html#4-download-the-amazon-pay-sdk)* and *[Get your Public Key ID](https://developer.amazon.com/docs/amazon-pay-checkout/get-set-up-for-integration.html#5-get-your-public-key-id)* sections of the official Amazon Pay integration guide.

In case you have to - or are preferring to - manually sign requests, please start by [Getting your Public Key ID](https://developer.amazon.com/docs/amazon-pay-checkout/get-set-up-for-integration.html#5-get-your-public-key-id). Requests need to be singed with your keys for authentication. Please follow the guide to [Signing Requests](https://developer.amazon.com/docs/amazon-pay-api-v2/signing-requests.html). The Amazon Pay Scratchpad ([US](https://pay-api.amazon.com/tools/scratchpad/index.html), [EU](https://pay-api.amazon.eu/tools/scratchpad/index.html), [JP](https://pay-api.amazon.jp/tools/scratchpad/index.html)) is also a great resource for this.

<div style="display:none" class="environmentSpecificKeys">
  <div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> *For partners*: Please reach out to your Amazon Pay Partner Manager or Solution Architect to understand which options are available for the merchants you support.</div>
</div>

***

### Step 2: Get a list of generated reports

The `Get Reports` API will return a list of reports including their metadata. The metadata includes the `reportDocumentId`. This identifier is required to retrieve the actual report document.

**Operation**: Get Reports

#### Request

<div style="display:none" class="environmentSpecificKeys">
<code style="color:black">
curl "https://pay-api.amazon.com/live/:version/reports"<br />
-X GET <br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"<br />
</code>

</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<code style="color:black">
curl "https://pay-api.amazon.com/live/:version/reports"<br />
-X GET <br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
-H "x-amz-pay-idempotency-key:AVLo5tI10BHgEk2jEXAMPLEKEY"<br />
</code>

</div>

#### Request parameters

<table border="1">
    <colgroup>
        <col width="30%" />
        <col width="20%" />
        <col width="50%" />
    </colgroup>
    <thead>
        <tr class="header">
            <th>Name</th>
            <th>Location</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td markdown="span">reportTypes<br />(optional)<br /><br />Type: string (comma-separated list of <a href="../amazon-pay-api-v2/reports.md#enum-reporttypes">ReportTypes</a>)</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">List of types of reports requested.</td>
        </tr>
        <tr>
            <td markdown="span">processingStatuses<br />(optional)<br /><br />Type: string (comma-separated list of <a href="../amazon-pay-api-v2/reports.md#enum-processingstatus">ProcessingStatus</a>)</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">A list of processing statuses used to filter reports.</td>
        </tr>
        <tr>
            <td markdown="span">createdSince<br />(optional)<br /><br />Type: string (date-time ISO 8601)</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">The earliest report creation date and time for reports to include in the response, in ISO 8601 date time format. Reports are retained for a maximum of 90 days.<br /><br />Default: *90 days*</td>
        </tr>
        <tr>
            <td markdown="span">createdUntil<br />(optional)<br /><br />Type: string (date-time ISO 8601)</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">The latest report creation date and time for reports to include in the response, in ISO 8601 date time format. Reports are retained for a maximum of 90 days.<br /><br />Default: *now*</td>
        </tr>
        <tr>
            <td markdown="span">pageSize<br />(optional)<br /><br />Type: number</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">The number of reports per page to return.<br />Minimum: *1*<br />Maximum: *100*<br /><br />Default: *10*</td>
        </tr>
        <tr>
            <td markdown="span">nextToken<br />(optional)<br /><br />Type: string</td>
            <td markdown="span">Query Parameter</td>
            <td markdown="span">A string token returned in the response to your previous request. `nextToken` is returned when the number of results exceeds the specified `pageSize` value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying `nextToken` with any other parameters will cause the request to fail.</td>
        </tr>
    </tbody>
</table>


#### Sample Code

<div style="display:none" class="environmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getReports" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getReports" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getReports" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getReports" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getReports">   
<div markdown="block">
```    
<?php
    include 'vendor/autoload.php';

    $amazonpay_config = array(
        'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
        'private_key'   => 'keys/private.pem',
        'region'        => 'YOUR_REGION_CODE',
        'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2'
    );

    try {
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getReports();

        if ($result['status'] === 200) {
            // success
            $response = $result['response'];
            echo $response;
        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
        }
    } catch (\Exception $e) {
            // handle the exception
            echo $e . "\n";
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getReports">
<div markdown="block">
```
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;

public class Sample
{
    public WebStoreClient InitiateClient()
    {
        // set up config
        var payConfiguration = new ApiConfiguration
        (
            region: Region.YOUR_REGION_CODE,
            publicKeyId: "YOUR_PUBLIC_KEY_ID",
            privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
            algorithm: AmazonSignatureAlgorithm.V2
        );

        // init API client
        var client = new WebStoreClient(payConfiguration);

        return client;
    }

    public void GetReportsAPI()
    {
        // init Headers
        var myHeaderKey = "x-amz-pay-idempotency-key";
        var myHeaderValue = Guid.NewGuid().ToString();
        var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };

        // init Request Payload
        GetReportsRequest reportRequest = new GetReportsRequest();

        // send the request
        GetReportsResponse report = client.GetReports(reportRequest, headers);

        // check if API call was successful
        if (!report.Success)
        {
            // handle the API error (use Status field to get the numeric error code)
        }

        // do something with the result, for instance:
        Console.WriteLine(report.RawResponse);
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getReports">
<div markdown="block">
```
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Region;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {
        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY")
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        AmazonPayResponse response = null;

        response = webstoreClient.getReports();
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getReports">
<div markdown="block">
```html
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');

const config = {
    publicKeyId: 'YOUR_PUBLIC_KEY_ID',
    privateKey: fs.readFileSync('tst/private.pem'),
    region: 'YOUR_REGION_CODE',
    algorithm: 'AMZN-PAY-RSASSA-PSS-V2' 
};    

const testPayClient = new Client.WebStoreClient(config);

const response = testPayClient.getReports();

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getReports-NESK" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getReports-NESK" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getReports-NESK" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getReports-NESK" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getReports-NESK">   
<div markdown="block">
```    
<?php
    include 'vendor/autoload.php';

    $amazonpay_config = array(
        'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
        'private_key'   => 'keys/private.pem',
        'region'        => 'YOUR_REGION_CODE',
        'sandbox'       => false,
        'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2'
    );

    try {
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getReports();

        if ($result['status'] === 200) {
            // success
            $response = $result['response'];
            echo $response;
        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
        }
    } catch (\Exception $e) {
            // handle the exception
            echo $e . "\n";
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getReports-NESK">
<div markdown="block">
```
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;

public class Sample
{
    public WebStoreClient InitiateClient()
    {
        // set up config
        var payConfiguration = new ApiConfiguration
        (
            region: Region.YOUR_REGION_CODE,
            environment: Environment.Live,
            publicKeyId: "YOUR_PUBLIC_KEY_ID",
            privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
            algorithm: AmazonSignatureAlgorithm.V2
        );

        // init API client
        var client = new WebStoreClient(payConfiguration);

        return client;
    }

    public void GetReportsAPI()
    {
        // init Headers
        var myHeaderKey = "x-amz-pay-idempotency-key";
        var myHeaderValue = Guid.NewGuid().ToString();
        var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };

        // init Request Payload
        GetReportsRequest reportRequest = new GetReportsRequest();

        // send the request
        GetReportsResponse report = client.GetReports(reportRequest, headers);

        // check if API call was successful
        if (!report.Success)
        {
            // handle the API error (use Status field to get the numeric error code)
        }

        // do something with the result, for instance:
        Console.WriteLine(report.RawResponse);
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getReports-NESK">
<div markdown="block">
```
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {
        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY")
            .setEnvironment(Environment.LIVE)
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        AmazonPayResponse response = null;

        response = webstoreClient.getReports();
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getReports-NESK">
<div markdown="block">
```html
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');

const config = {
    publicKeyId: 'YOUR_PUBLIC_KEY_ID',
    privateKey: fs.readFileSync('tst/private.pem'),
    region: 'YOUR_REGION_CODE',
    sandbox: false,
    algorithm: 'AMZN-PAY-RSASSA-PSS-V2' 
};    

const testPayClient = new Client.WebStoreClient(config);

const response = testPayClient.getReports();

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>

#### Response

Returns [HTTP 200 status response code](https://restfulapi.net/http-status-200-ok){:target="_blank"} if the operation was successful.

```
{
     "reports": [{
        "reportId": "A08439021T39K6DTX4JS8",
        "reportType": "_GET_FLAT_FILE_OFFAMAZONPAYMENTS_SETTLEMENT_DATA_",
        "startTime":"20221118T150630Z",
        "endTime":"20221202T150350Z",
        "createdTime":"20221207T170826Z",
        "processingStatus": "COMPLETED",
        "processingStartTime":"20221207T170826Z",
        "processingEndTime":"20221207T170826Z",
        "reportDocumentId": "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32"
     }]
}
```


#### Response parameters

<table width="100%" border="1">
    <colgroup>
        <col width="30%" />
        <col width="70%" />
    </colgroup>
    <thead>
        <tr class="header">
            <th>Parameters</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td markdown="span">reports
            <br>Type: list&lt;Report&gt;<br /></td>
            <td markdown="span">A list of report objects matching the search criteria.</td>
        </tr>
        <tr>
            <td markdown="span">nextToken  
            <br>Type: string<br /></td>
            <td markdown="span">Returned when the number of results exceeds pageSize. To get the next page of results, call getReports with this token as the only parameter.</td>
        </tr>
    </tbody>
</table>

All details for this API are available [here](../amazon-pay-api-v2/reports.html){:target="_blank"}. If you are using a SDK, please check the matching SDK documentation.

***

### Step 3: Get the Report document

Returns the pre-signed S3 URL for the report. The report can be downloaded using this URL.

**Operation**: Get Report Document

#### Request

<div style="display:none" class="environmentSpecificKeys">
<code style="color:black">
curl "https://pay-api.amazon.com/live/:version/report-documents/:reportDocumentId"<br />
-X GET <br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
</code>

</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<code style="color:black">
curl "https://pay-api.amazon.com/live/:version/report-documents/:reportDocumentId"<br />
-X GET <br />
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"<br />
-H "x-amz-pay-date:20201012T235046Z"<br />
</code>

</div>

#### Request parameters

<table border="1">
    <colgroup>
        <col width="30%" />
        <col width="20%" />
        <col width="50%" />
    </colgroup>
    <thead>
        <tr class="header">
            <th>Name</th>
            <th>Location</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td markdown="span">reportDocumentId<br />**(required)**<br /><br />Type: string</td>
            <td markdown="span">Path Parameter</td>
            <td markdown="span">Report Document identifier</td>
        </tr>
    </tbody>
</table>


#### Sample Code

<div style="display:none" class="environmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getReportDocument" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getReportDocument" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getReportDocument" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getReportDocument" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getReportDocument">   
<div markdown="block">
```    
<?php
    include 'vendor/autoload.php';

    $amazonpay_config = array(
        'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
        'private_key'   => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
        'region'        => 'YOUR_REGION_CODE',
        'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2'
    );

    try {
        $reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getReportDocument($reportDocumentId);

        if ($result['status'] === 200) {
            // success
            $response = $result['response'];
            echo $response;
        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
        }
    } catch (\Exception $e) {
            // handle the exception
            echo $e . "\n";
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getReportDocument">
<div markdown="block">
```
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;

public class Sample
{
    public WebStoreClient InitiateClient()
    {
        // set up config
        var payConfiguration = new ApiConfiguration
        (
            region: Region.YOUR_REGION_CODE,
            publicKeyId: "YOUR_PUBLIC_KEY_ID",
            privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
            algorithm: AmazonSignatureAlgorithm.V2
        );

        // init API client
        var client = new WebStoreClient(payConfiguration);

        return client;
    }

    public void GetReportDocument()
    {
        // init Headers
        var myHeaderKey = "x-amz-pay-idempotency-key";
        var myHeaderValue = Guid.NewGuid().ToString();
        var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };

        // init Request Payload
        string reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";

        // send the request
        GetReportDocumentResponse report = client.GetReportDocument(reportDocumentId, headers);

        // check if API call was successful
        if (!report.Success)
        {
            // handle the API error (use Status field to get the numeric error code)
        }

        // do something with the result, for instance:
        Console.WriteLine(report.RawResponse);
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getReportDocument">
<div markdown="block">
```
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Region;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {
        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY")
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        AmazonPayResponse response = null;
        String reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";

        response = webstoreClient.getReportDocument(reportDocumentId);
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getReportDocument">
<div markdown="block">
```html
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');

const config = {
    publicKeyId: 'YOUR_PUBLIC_KEY_ID',
    privateKey: fs.readFileSync('tst/private.pem'),
    region: 'YOUR_REGION_CODE',
    algorithm: 'AMZN-PAY-RSASSA-PSS-V2' 
};    

const reportDocumentId = 'amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32';
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getReportDocument(reportDocumentId);

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>
<div style="display:none" class="notEnvironmentSpecificKeys">
<ul id="profileTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#phptab-getReportDocument-NESK" data-toggle="tab">PHP</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#dotnettab-getReportDocument-NESK" data-toggle="tab">.NET</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#javatab-getReportDocument-NESK" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#nodejstab-getReportDocument-NESK" data-toggle="tab">Node.js</a></li>
</ul>
<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="phptab-getReportDocument-NESK">   
<div markdown="block">
```    
<?php
    include 'vendor/autoload.php';

    $amazonpay_config = array(
        'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
        'private_key'   => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
        'region'        => 'YOUR_REGION_CODE',
        'sandbox'       => false,
        'algorithm'     => 'AMZN-PAY-RSASSA-PSS-V2'
    );

    try {
        $reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";
        $client = new Amazon\Pay\API\Client($amazonpay_config);
        $result = $client->getReportDocument($reportDocumentId);

        if ($result['status'] === 200) {
            // success
            $response = $result['response'];
            echo $response;
        } else {
            // check the error
            echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n";
        }
    } catch (\Exception $e) {
            // handle the exception
            echo $e . "\n";
    }
?>
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="dotnettab-getReportDocument-NESK">
<div markdown="block">
```
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
using Amazon.Pay.API.WebStore.Reports;

public class Sample
{
    public WebStoreClient InitiateClient()
    {
        // set up config
        var payConfiguration = new ApiConfiguration
        (
            region: Region.YOUR_REGION_CODE,
            environment: Environment.Live,
            publicKeyId: "YOUR_PUBLIC_KEY_ID",
            privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
            algorithm: AmazonSignatureAlgorithm.V2
        );

        // init API client
        var client = new WebStoreClient(payConfiguration);

        return client;
    }

    public void GetReportDocument()
    {
        // init Headers
        var myHeaderKey = "x-amz-pay-idempotency-key";
        var myHeaderValue = Guid.NewGuid().ToString();
        var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };

        // init Request Payload
        string reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";

        // send the request
        GetReportDocumentResponse report = client.GetReportDocument(reportDocumentId, headers);

        // check if API call was successful
        if (!report.Success)
        {
            // handle the API error (use Status field to get the numeric error code)
        }

        // do something with the result, for instance:
        Console.WriteLine(report.RawResponse);
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="javatab-getReportDocument-NESK">
<div markdown="block">
```
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;

public void sample() {
    PayConfiguration payConfiguration = null;
    try {
        payConfiguration = new PayConfiguration()
            .setPublicKeyId("YOUR_PUBLIC_KEY_ID")
            .setRegion(Region.YOUR_REGION_CODE)
            .setPrivateKey("YOUR_PRIVATE_KEY")
            .setEnvironment(Environment.LIVE)
            .setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");

        WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
        AmazonPayResponse response = null;
        String reportDocumentId = "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32";

        response = webstoreClient.getReportDocument(reportDocumentId);
    } catch (AmazonPayClientException e) {
        e.printStackTrace();
    }
}
```

</div>
  </div>
  <div role="tabpanel" class="tab-pane" id="nodejstab-getReportDocument-NESK">
<div markdown="block">
```html
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');

const config = {
    publicKeyId: 'YOUR_PUBLIC_KEY_ID',
    privateKey: fs.readFileSync('tst/private.pem'),
    region: 'YOUR_REGION_CODE',
    sandbox: false,
    algorithm: 'AMZN-PAY-RSASSA-PSS-V2' 
};    

const reportDocumentId = 'amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32';
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getReportDocument(reportDocumentId);

response.then(function (result) {
    console.log(result.data);
}).catch(err => {
    console.log(err);
});
```

</div>
  </div>
</div>
</div>

#### Response

Returns [HTTP 200 status response code](https://restfulapi.net/http-status-200-ok){:target="_blank"} if the operation was successful.

```
{
      "reportDocumentId" : "amzn1.tortuga.3.45ee712dc-3512-6cbd-ad71-ab3cb4cffef7.T3FKJJI01Y1E32",
      "url" : ""https://tortuga-[...].amazonaws.com/<reportDocumentId>?X-Amz-Algorithm=...&X-Amz-Signature=...",
      "compressionAlgorithm" : "N/A"
}
```


The `Get Report Document` API will return an `url` with the link to the report in zip format.

All details for this API are available [here](../amazon-pay-api-v2/reports.html#get-report-document). If you are using a SDK, please check the matching SDK documentation.

***

### Step 4: Download the report document file

You must download the report using the information returned in Step 3. The `url` is valid for 30 seconds only. At this time, all files will be uncompressed. 
The following sample code demonstrates how to download a plain text report document. You can also use the principles demonstrated in the sample code to guide you in building applications in other programming languages.

Use the following as inputs for the sample code:

- The url and optional compressionAlgorithm values from the previous step are arguments for the url, and compressionAlgorithm parameters of the download method of the DownloadExample class.

<ul id="downloadTabs" class="nav nav-tabs">
  <li class="nav-item"><a class="active nav-link noExtIcon" href="#javatab" data-toggle="tab">Java</a></li>
  <li class="nav-item"><a class="nav-link noExtIcon" href="#wgettab" data-toggle="tab">WGET</a></li>
</ul>
<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="javatab">   
        <div markdown="block">

```java
package com.example.download;

import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;

public class DownloadExample {

    public static void main(String[] args){
        System.out.println("Downloading file");
        try (
            ReadableByteChannel readableByteChannel = Channels.newChannel(new URL("<url from GetReportDocument>").openStream());
            FileOutputStream fileOutputStream = new FileOutputStream("<target output file>")) 
        {
            fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
            fileOutputStream.close();
            System.out.println("Download complete");
        } catch(Exception e){
            System.err.println(String.format("error downloading: %s", e.getMessage()));
        }
    }

}
```

</div>
</div>
<div role="tabpanel" class="tab-pane" id="wgettab">
<div markdown="block">

```wget
wget -O <target output file> "<url from GetReportDocument>"
```

**Hint:** Place the url in quotes to avoid issues with wget.
</div>
  </div>
</div>

***
