跳过主要内容
unraster

DEVELOPERS / API v1

Images in. Editable files out.

Submit a conversion, follow its progress, and download SVG and PowerPoint files.

1. Create an API key

Sign in with Google and open API keys. Keep your key on your server and send it as a Bearer token. Reading tasks requires conversions:read; creating and deleting requires conversions:write. Keys share your account’s conversion credits.

2. Check credits

curl https://unraster.ai/v1/conversions/quote \
  -H "Authorization: Bearer $UNRASTER_API_KEY"

The response lists exact prices in prices: SVG costs 1 credit, PPTX costs 2 credits, and requesting both costs 3 credits. It also includes your integer available_credits, the upload limit, and supported outputs.

{"billing_version":"fixed-v1","prices":{"svg":1,"pptx":2},"available_credits":10,"reserved_credits":0,"max_upload_bytes":26214400,"outputs":["svg","pptx"]}

The exact price is reserved when you submit. Only requested outputs that are ready to download are charged; credits for unavailable outputs are released. Progress checks and downloads are free.

3. Submit one image

Upload a static PNG, JPEG, or WebP, up to 25 MiB and 25 million pixels. Send outputs=svg, outputs=pptx, or outputs=svg,pptx. Generate a unique REQUEST_ID and retain it with your request.

curl https://unraster.ai/v1/conversions \
  -H "Authorization: Bearer $UNRASTER_API_KEY" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -F "file=@slide.png" \
  -F "outputs=svg,pptx"

A new task returns HTTP 202. Save its ID.

{
  "id": "cnv_example", "status": "queued", "stage": null,
  "version_id": null, "error": null,
  "outputs": [
    { "format": "svg", "status": "pending" },
    { "format": "pptx", "status": "pending" }
  ]
}

If the connection fails, retry the same image and output selection with the same idempotency key. A changed request using that key returns HTTP 409. Do not generate another key just because a response was lost.

4. Check progress and download

curl https://unraster.ai/v1/conversions/$TASK_ID \
  -H "Authorization: Bearer $UNRASTER_API_KEY"
StatusWhat to do
queuedWaiting to start; check again shortly.
processingStill working; poll every few seconds.
completedDownload outputs whose status is ready.
needs_reviewDownload ready outputs; unavailable outputs are not charged.
failedReview your source. No unavailable output is charged.
deletedThis task is no longer available.

outputs is an array. Ready outputs contain a url and expires_at. Paid, settled results use a public link under https://files.unraster.ai that works without an API key for seven days after completion. Anyone holding that link can download the file, so keep it private. A relative URL is a short-lived account-authenticated download; resolve it against the API origin and send your Bearer key only to that origin. Fetch the task again to refresh a relative link. A seven-day public link cannot be extended by fetching the task again.

Deleting with DELETE /v1/conversions/{id} revokes its download links. Deleting a completed task does not refund a successful conversion.

5. Receive webhooks

Add a public HTTPS endpoint in Webhook settings. Save the signing secret when it appears; it is shown only once. Notifications include conversion.completed, conversion.failed, and conversion.needs_review.

Preserve the exact request body bytes. The webhook-id header identifies the event. The webhook-signature header has the form t=TIMESTAMP,v1=HEX_SIGNATURE.

HMAC-SHA256(
  hexDecode(signing_secret),
  timestamp + "." + webhook_id + "." + raw_body
)

Use a timing-safe signature comparison, reject timestamps outside a five-minute window, and verify the event ID matches the body. Deduplicate by event ID before applying your business action. Events can arrive repeatedly or out of order; query the current task for its latest status and download links. Return 2xx after durably accepting an event. Failed deliveries retry for a limited period, so retain polling as a recovery option.

Handle errors

Errors use {"error": {"code": "…", "message": "…"}}. Branch on error.code.

  • 400 / 413 / 415: correct the request, file size, or format.
  • 401 / 403: check your key and permissions.
  • 402: insufficient available credits.
  • 404: the task or file is unavailable to this account.
  • 409: check for an idempotency conflict.
  • 429: respect Retry-After before retrying.
  • 503: retry later, preserving the original idempotency key.