API reference
Quickstart
Submit a run, poll the task, download the file. This example resizes a fabric swatch to a 120 × 40 cm print — the same three steps apply to every tool.
1. Submit the run
Every tool endpoint accepts the same shape: an image (URL or upload) plus the tool’s parameters. The response returns the task id and the exact credit cost of the run, debited from the key owner’s balance.
curl -X POST https://printresize.com/api/refit \
-H "Authorization: Bearer pr_your_key" \
-F "imageUrl=https://example.com/swatch.png" \
-F "widthCm=120" -F "heightCm=40" \
-F "shape=rect" -F "quality=standard"import requests
res = requests.post(
"https://printresize.com/api/refit",
headers={"Authorization": "Bearer pr_your_key"},
data={
"imageUrl": "https://example.com/swatch.png",
"widthCm": "120",
"heightCm": "40",
"shape": "rect",
"quality": "standard",
},
)
print(res.json())const form = new FormData();
form.set("imageUrl", "https://example.com/swatch.png");
form.set("widthCm", "120");
form.set("heightCm", "40");
form.set("shape", "rect");
form.set("quality", "standard");
const res = await fetch("https://printresize.com/api/refit", {
method: "POST",
headers: { Authorization: "Bearer pr_your_key" },
body: form,
});
console.log(await res.json());The response is immediate:
{
"success": true,
"taskId": "f4a2e6c1-9f0f-4c2e-8f19-6b5f0a3e91d2",
"credits": 6
}Costs are known up front
credits field is the authoritative charge for the run. If the balance is too low you get a 402 instead — nothing is debited.2. Poll the task
Task status moves pending → running → completed | failed. A 5-second interval is a good default; runs usually finish in 1–3 minutes, extra-large resizes up to 5.
curl -H "Authorization: Bearer pr_your_key" \
https://printresize.com/api/ai-tasks/f4a2e6c1-9f0f-4c2e-8f19-6b5f0a3e91d2import time, requests
task_id = "f4a2e6c1-9f0f-4c2e-8f19-6b5f0a3e91d2"
while True:
task = requests.get(
f"https://printresize.com/api/ai-tasks/{task_id}",
headers={"Authorization": "Bearer pr_your_key"},
).json()
if task["status"] in ("completed", "failed"):
break
time.sleep(5)const { taskId } = await res.json(); // submit response from step 1
let task;
do {
await new Promise((r) => setTimeout(r, 5000));
task = await fetch(
`https://printresize.com/api/ai-tasks/${taskId}`,
{ headers: { Authorization: "Bearer pr_your_key" } },
).then((r) => r.json());
} while (task.status !== "completed" && task.status !== "failed");A completed task carries the result metadata:
{
"status": "completed",
"stage": "done",
"widthPx": 8192,
"heightPx": 2731,
"dpi": 173,
"thumbnailUrl": "https://cdn.printresize.com/.../thumb.webp",
"credits": 6,
"refunded": false,
"errorCode": null
}3. Download the file
The download streams the finished PNG with attachment headers — hand it straight to production. The DPI and physical size are written into the file.
curl -H "Authorization: Bearer pr_your_key" \
-o result.png \
https://printresize.com/api/ai-creations/f4a2e6c1-9f0f-4c2e-8f19-6b5f0a3e91d2/downloadwith open("result.png", "wb") as f:
f.write(requests.get(
f"https://printresize.com/api/ai-creations/{task_id}/download",
headers={"Authorization": "Bearer pr_your_key"},
).content)import { writeFile } from "node:fs/promises";
const download = await fetch(
`https://printresize.com/api/ai-creations/${taskId}/download`,
{ headers: { Authorization: "Bearer pr_your_key" } },
);
await writeFile("result.png", Buffer.from(await download.arrayBuffer()));What’s next
| Parameter | Values | Notes |
|---|---|---|
| Print Resize | every shape, size, and quality option | /docs/api/print-resize |
| Home textiles | mockups, scene swap, pattern extraction | /docs/api/home-textiles |
| Errors | error codes and how to handle them | /docs/errors |
