File upload guide
Use the File Upload API to securely send files to Stripe, such as dispute evidence, identification documents, and so on.
When you upload a file to Stripe using the API, it returns a file token and other information about the file. You can then use the token in other API calls. This guide describes this process.
Upload a file
To upload a file, send a multipart/form-data request to https://files.stripe.com/v1/files. The subdomain files.stripe.com is different than most Stripe API endpoints. Specify a purpose and a file in the request. The following example uploads a file located at /the relevant part of the product on your local file system with the purpose dispute_evidence:
Command Line
Select a language
curl
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
The following example uploads a file using our Android SDK with the purpose dispute_evidence:
CheckoutActivity.kt
Select a language
Kotlin
Java
No results
class CheckoutActivity : AppCompatActivity() {
private val stripe: Stripe by lazy {
Stripe(this, "pk_test_TYooMQauvdEDq54NiTphI7jx")
}
private fun uploadFile(file: File) {
stripe.createFile(
StripeFileParams(
file,
StripeFilePurpose.DisputeEvidence
),
callback = object : ApiResultCallback<StripeFile> {
override fun onSuccess(result: StripeFile) {
// File upload succeeded
}
override fun onError(e: Exception) {
// File upload failed
}
}
)
}
}
There are several valid purpose values, each with file format and size requirements.
| Purpose | Description | Supported mimetypes | Max size | Expiry | Downloadable |
|---|---|---|---|---|---|
account_requirement | Additional documentation requirements that can be requested for an account. | PDF the related setting PNG | 64MB | the related setting | No |
business_icon | A business icon. | the related setting PNG GIF | 512KB | the related setting | Yes |
business_logo | A business logo. | the related setting PNG GIF | 512KB | the related setting | Yes |
customer_signature | Customer signature image. | the related setting PNG SVG | 4MB | 7 days | Yes |
dispute_evidence | Evidence to submit with a dispute response. | PDF the related setting PNG | 5MB | 9 months | Yes |
platform_terms_of_service | A copy of the platform's Terms of Service. | PDF TXT the related setting | 64MB | the related setting | No |
issuing_regulatory_reporting | Additional regulatory reporting requirements for Issuing. | JSON | 256KB | 2 years | Yes |
pci_document | A self-assessment PCI questionnaire. | 16MB | the related setting | Yes | |
tax_document_user_upload | A user-uploaded tax document. | PDF CSV the related setting PNG the related setting the related setting | 16MB | the related setting | Yes |
additional_verification | Additional verification for custom accounts. | PDF the related setting PNG | 16MB | the related setting | No |
terminal_android_apk | Android POS apps to be deployed on Stripe smart readers. | APK | 200MB | 6 months | Yes |
terminal_reader_splashscreen | Splashscreen to be displayed on Terminal readers. | PNG the related setting GIF | 4.194304MB | 1 year | Yes |
terminal_wifi_certificate | Certificate used for Enterprise WiFi on Terminal readers. | PEM | 100KB | the related setting | No |
terminal_wifi_private_key | Private key used for Enterprise WiFi on Terminal readers. | PEM | 100KB | the related setting | No |
identity_document | A document to verify the identity of an account owner during account provisioning. | PDF the related setting PNG | 32MB | the related setting | When uploaded by Connect platform |
Caution
identity_document images also need to be smaller than 8,000px by 8,000px.
The the related setting type of the file you want to upload must correspond to its file format.
| File format | the related setting type |
|---|---|
| APK | application/vnd.android.package-archive |
| CSV | text/csv |
| the related setting | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| GIF | image/gif |
| HTML | text/html |
| ICO | image/vnd.microsoft.icon |
| the related setting | image/jpeg |
| JSON | application/json |
| the related setting | application/jsonl |
| the related setting | text/markdown |
| application/pdf | |
| PEM | application/x-pem-file |
| PNG | image/png |
| SVG | image/svg+xml |
| the related setting | image/tiff |
| TSV | text/tab-separated-values |
| TXT | text/plain |
| the related setting | image/webp |
| XLS | application/vnd.ms-excel |
| the related setting | application/vnd.ms-excel.sheet.macroEnabled.12 |
| the related setting | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| XML | application/xml |
| ZIP | application/zip |
Caution
Any Microsoft Office documents containing VBA macros will be rejected because of security concerns.
A successful request returns a File object.
Retrieving a File API resource
To retrieve the API resource for a file, make a GET request to the /v1/files endpoint of the files.stripe.com subdomain providing the file upload ID:
Command Line
Select a language
curl
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
When using restricted API keys, you must receive prior access to the Files resource.
Download the file contents
If the file purpose allows downloading the file contents, then the file includes a non-null url field indicating how to access the contents. This url requires authentication with your Stripe API keys.
Command Line
If you want unauthenticated access to a file whose purpose allows downloading, then you can produce anonymous download links by creating a file_link.
Command Line
Select a language
curl
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
The file_link resource has a url field that allows unauthenticated access to the contents of the file.
Using a file
After you upload a file, you can use the file upload ID in other API requests. For example, to attach an uploaded file to a particular dispute as evidence:
Command Line
Select a language
curl
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
You can only use an uploaded file in a single API request.
Handle Upload Errors
When you use the File API to upload a PDF document, we run it through a series of checks to validate that it’s correctly formatted and meets PDF specifications. We return an error for uploads that fail any of our checks.
Try the following to fix errors that we detect:
- Remove annotations or additional media you added to the document.
- If you can’t remove your annotations or media, or if you combined several PDFs into one, try using your computer’s “Print to PDF” function to create a fresh document.
- Print to PDF with macOS
- Print to PDF with Adobe Acrobat
