File
For LLMs: see /docs/amazon-pay/llms.txt | Markdown: /amazon-pay-api-v2/file.md
Overview
Upload and manage files for dispute evidence and other documentation needs. The API supports common file formats and provides secure upload URLs.
Note: If your publicKeyId
does not have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow
these instructions instead.
Note: If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow
these instructions instead.
Supported operations:
Upload File - POST https://pay-api.amazon.com/:version/files
Upload File - POST https://pay-api.amazon.eu/:version/files
Upload File - POST https://pay-api.amazon.jp/:version/files
Upload File - POST https://pay-api.amazon.com/:environment/:version/files
Upload File - POST https://pay-api.amazon.eu/:environment/:version/files
Upload File - POST https://pay-api.amazon.jp/:environment/:version/files
File Object
Property
Description
id Type: string
Unique identifier for referencing the file
type Type: filetype [Enum]
File format (jpg, pdf, etc.)
purpose Type: filePurpose [Enum]
Intended use (e.g., disputeEvidence)
size Type: int
File size in bytes
uploadTimestamp Type: dateTime
Upload time in ISO 8601 format
url Type: String
Download URL for the file
urlExpirationTimestamp Type: dateTime
URL expiration time
Enum
filePurpose
Value
Description
disputeEvidence
The file provided will be used as a dispute evidence
Upload files
The API provides a two-step process to upload files securely.
Step 1: Get Upload URL
First, request a secure upload URL:
Request
curl "https://pay-api.amazon.com/v2/files" \
-X POST \
-H "authorization: Bearer YOUR_TOKEN" \
-H "x-amz-pay-date: 20201012T235046Z" \
-H "x-amz-pay-idempotency-key: YOUR_IDEMPOTENCY_KEY" \
-d @request_body
curl "https://pay-api.amazon.com/:environment/v2/files" \
-X POST \
-H "authorization: Bearer YOUR_TOKEN" \
-H "x-amz-pay-date: 20201012T235046Z" \
-H "x-amz-pay-idempotency-key: YOUR_IDEMPOTENCY_KEY" \
-d @request_body
Request body
{
"type" : "jpg",
"purpose" : "disputeEvidence"
}
Request parameters
Name
Location
Description
x-amz-pay-idempotency-key(required) Type: String
Header
Unique key to prevent duplicate uploads. For detailed guidance on creating and using idempotency keys, see Idempotency.
type Type: String
Body
File format (jpg, png, pdf)
purpose Type: String
Body
Upload reason (disputeEvidence)
Supported file types
fileType
Description
Content-Type
csv
CSV files
text/csv
pdf
PDF documents
application/pdf
xls/xlsx
Excel spreadsheets
application/vnd.ms-excel (xls) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
doc/docx
Word documents
application/msword (doc) application/vnd.openxmlformats-officedocument.wordprocessingml.document (docx)
ods
OpenDocument spreadsheets
application/vnd.oasis.opendocument.spreadsheet
jpg/png
Image files
image/jpeg (jpg) image/png (png)
Sample Code
<?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'
);
$payload = array(
'type' => 'jpg',
'purpose' => 'disputeEvidence'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->uploadFile($payload, $headers);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$fileId = $response['id'];
$uploadUrl = $response['url'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.File;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
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 UploadFile()
{
// prepare the request
var request = new UploadFileRequest(type: "jpg", purpose: "disputeEvidence");
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// send the request
FileResponse result = client.UploadFile(request, headers);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
string fileId = result.Id;
string uploadUrl = result.URL;
DateTime urlExpiryTimestamp = result.UrlExpirationTimestamp;
}
}
}
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.DisputeFilePurpose;
import com.amazon.pay.api.types.EvidenceDocumentFileType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
JSONObject payload = new JSONObject();
payload.put("type", EvidenceDocumentFileType.JPG.getEvidenceDocumentFileType());
payload.put("purpose", DisputeFilePurpose.DISPUTE_EVIDENCE.getDisputeFilePurpose());
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.uploadFile(payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const uuidv4 = require('uuid/v4');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const payload = {
type: "jpg",
purpose: "disputeEvidence"
};
const headers = {
'x-amz-pay-idempotency-key': uuidv4().toString().replace(/-/g, '')
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.uploadFile(payload, headers);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
require 'securerandom'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem')
}
client = AmazonPayClient.new(config)
payload = {
"type": "jpg",
"purpose": "disputeEvidence"
}
headers = {
"x-amz-pay-Idempotency-Key": SecureRandom.uuid
}
response = client.upload_file(payload, headers: headers)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
<?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' => true,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'type' => 'jpg',
'purpose' => 'disputeEvidence'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->uploadFile($payload, $headers);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$fileId = $response['id'];
$uploadUrl = $response['url'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.File;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
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 UploadFile()
{
// prepare the request
var request = new UploadFileRequest(type: "jpg", purpose: "disputeEvidence");
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// send the request
FileResponse result = client.UploadFile(request, headers);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
string fileId = result.Id;
string uploadUrl = result.URL;
DateTime urlExpiryTimestamp = result.UrlExpirationTimestamp;
}
}
}
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.DisputeFilePurpose;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.EvidenceDocumentFileType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
JSONObject payload = new JSONObject();
payload.put("type", EvidenceDocumentFileType.JPG.getEvidenceDocumentFileType());
payload.put("purpose", DisputeFilePurpose.DISPUTE_EVIDENCE.getDisputeFilePurpose());
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.uploadFile(payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const uuidv4 = require('uuid/v4');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: true,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const payload = {
type: "jpg",
purpose: "disputeEvidence"
};
const headers = {
'x-amz-pay-idempotency-key': uuidv4().toString().replace(/-/g, '')
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.uploadFile(payload, headers);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
require 'securerandom'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem'),
sandbox: true
}
client = AmazonPayClient.new(config)
payload = {
"type": "jpg",
"purpose": "disputeEvidence"
}
headers = {
"x-amz-pay-Idempotency-Key": SecureRandom.uuid
}
response = client.upload_file(payload, headers: headers)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
Response
The API returns:
{
"id": "file_sdcjscbjckndjhckj",
"type" : "jpg",
"purpose": "disputeEvidence",
"uploadTimestamp": "20190714T155300Z",
"url": "https://pay-api.amazon.com/v1/files/file_sdcjscbjckndjhckj/contents",
"urlExpirationTimeStamp": "20190714T155300Z"
}
Step 2: Upload your file
Send your file to the returned URL:
curl "YOUR_PRESIGNED_URL" \
-X PUT \
-H "Content-Type: application/pdf" \
-T "/path/to/file"
File Requirements:
Maximum size: 2MB
Files must be relevant dispute evidence
After uploading, use the returned fileId when submitting dispute evidence.