Documentation Index
Fetch the complete documentation index at: https://mintlify.com/polarsource/polar/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Files can be used as product media (images) or downloadable benefits. Polar provides presigned URLs for secure direct upload to S3.
The File Object
MIME type (e.g., image/png)
When upload was completed
Storage service: product_media or downloadable
List Files
curl -X GET "https://api.polar.sh/v1/files" \
-H "Authorization: Bearer polar_pat_..."
Query Parameters
Create File Upload
curl -X POST "https://api.polar.sh/v1/files" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "product-image.png",
"mime_type": "image/png",
"size": 524288,
"service": "product_media",
"organization_id": "org_123"
}'
Initiates a file upload and returns a presigned URL.
Request Body
File type: product_media or downloadable
Organization ID (required unless using org token)
Response
Presigned S3 URL for upload
Required headers for upload
Complete File Upload
curl -X POST "https://api.polar.sh/v1/files/{id}/uploaded" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{}'
Marks the file upload as complete after uploading to S3.
Path Parameters
Update File
curl -X PATCH "https://api.polar.sh/v1/files/{id}" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "updated-name.png"
}'
Path Parameters
Request Body
Delete File
curl -X DELETE "https://api.polar.sh/v1/files/{id}" \
-H "Authorization: Bearer polar_pat_..."
Path Parameters
Upload Flow
The complete upload process:
- Create file upload - Get presigned URL
- Upload to S3 - Use presigned URL
- Mark complete - Notify Polar upload finished
Example
# 1. Create file upload
RESPONSE=$(curl -X POST "https://api.polar.sh/v1/files" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{
"name": "hero.png",
"mime_type": "image/png",
"size": 524288,
"service": "product_media",
"organization_id": "org_123"
}')
FILE_ID=$(echo $RESPONSE | jq -r '.id')
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
# 2. Upload file to S3
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: image/png" \
--data-binary "@hero.png"
# 3. Mark upload complete
curl -X POST "https://api.polar.sh/v1/files/$FILE_ID/uploaded" \
-H "Authorization: Bearer polar_pat_..." \
-H "Content-Type: application/json" \
-d '{}'
Python Example
import requests
client = requests.Session()
client.headers['Authorization'] = 'Bearer polar_pat_...'
# 1. Create upload
response = client.post('https://api.polar.sh/v1/files', json={
'name': 'hero.png',
'mime_type': 'image/png',
'size': 524288,
'service': 'product_media',
'organization_id': 'org_123'
})
data = response.json()
# 2. Upload to S3
with open('hero.png', 'rb') as f:
requests.put(
data['upload_url'],
data=f,
headers={'Content-Type': 'image/png'}
)
# 3. Mark complete
client.post(f"https://api.polar.sh/v1/files/{data['id']}/uploaded")