Image Upload API

This is an optional upload service provided by Social Print Studio to make integration easier. It gives you a simple way to upload images and receive publicly accessible URLs — which is exactly what the Order Handoff API requires when submitting orders.

The returned publicUrl can be passed directly into the projectData.photos array when calling the Order Handoff API.

Endpoint

text
POST https://printkit.dev/api/upload
Authorization: Bearer <your-api-key>  (optional)

Upload files to S3 via presigned URLs. Supports images and other file types (PDFs, documents, etc.). Max file size is 50 MB per file. Optionally include an API key for attribution. If an invalid key is provided, the API returns 401.

Usage

The upload process is two steps: get a presigned upload URL, then send the file directly to S3 using that URL.

Step 1: Get Upload URL

curl -X POST https://printkit.dev/api/upload \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "filename": "photo.jpg",
    "source": "my-app-name",
    "email": "[email protected]",
    "fileSize": 1234567,
    "contentType": "image/jpeg",
    "folder": "my-app-name"
  }'

# Response:
# { "uploadUrl": "https://s3.amazonaws.com/...", "publicUrl": "https://..." }

Step 2: Upload File to S3

curl -X PUT "UPLOAD_URL_FROM_STEP_1" \
  -H "Content-Type: image/jpeg" \
  --data-binary @photo.jpg

# File is now live at the publicUrl from Step 1

Complete Helper Function

A drop-in helper that handles both steps and returns the final public URL:

# Step 1: Get a presigned upload URL
UPLOAD_RESPONSE=$(curl -s -X POST https://printkit.dev/api/upload \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "filename": "photo.jpg",
    "source": "my-app",
    "email": "[email protected]",
    "fileSize": 1234567,
    "contentType": "image/jpeg"
  }')

# Extract URLs from response (requires jq)
UPLOAD_URL=$(echo $UPLOAD_RESPONSE | jq -r '.uploadUrl')
PUBLIC_URL=$(echo $UPLOAD_RESPONSE | jq -r '.publicUrl')

# Step 2: Upload the file directly to S3
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: image/jpeg" \
  --data-binary @photo.jpg

# Step 3: Use the public URL in your order submission
curl -X POST https://printkit.dev/api/add-to-cart \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d "{
    \"sku\": \"metal-print-4x4\",
    \"source\": \"my-app\",
    \"email\": \"[email protected]\",
    \"projectData\": {
      \"photos\": [\"$PUBLIC_URL\"]
    }
  }"

Request Parameters

Required

ParameterTypeDescription
filenamestringThe original filename. Used for the S3 key and content type detection.
sourcestringAn identifier for your application (e.g. "my-app"). Used for tracking and debugging.

Optional

ParameterTypeDescription
emailstringA contact email address. Highly recommended — allows us to reach out to you if there are any issues with your uploads.
fileSizenumberFile size in bytes. Recommended — enables 50 MB validation before upload.
contentTypestringMIME type (e.g. image/jpeg, application/pdf). Auto-detected from filename if not provided.
folderstringS3 subfolder path. Defaults to lambda-uploads.

Recommended File Formats

Use JPG or PNG for photos. Some book products accept PDF files — check the specific product’s JSON file in the product catalog to confirm.

FormatUse case
JPGPhotos and images (preferred for most products)
PNGImages with transparency, graphics, or lossless quality requirements
PDFSelect book and print products — check per-product JSON

Notes