Docs / Errors

Reference

Errors

When a request fails, DevilPDF returns a non-2xx status and a JSON body with one error object.

{
  "error": {
    "type": "template_error",
    "message": "undefined filter: currancy",
    "line": 14,
    "col": 22
  }
}
FieldDescription
typeA stable, machine-readable name. Branch on this.
messageA sentence written for a person. It says what went wrong and, where possible, how to fix it. The wording can change, so do not match on it.
other fieldsSome types add detail, such as line and col above. They are listed below.

#Error types

TypeStatusMeaning
invalid_request400The request is malformed: invalid JSON, a missing field, a wrong type or an unsupported value.
unauthorized401The API key is missing or not valid.
forbidden403The request is not allowed: changing a starter template, or calling a dashboard-only endpoint with an API key.
plan_limit403Your plan does not include this feature, or you are over a plan limit such as saved templates or batch size.
not_found404The template, document, batch, webhook or endpoint does not exist on your account.
payload_too_large413The request body, a field, or an input file is over the size limit.
template_error422The template or its data has a problem: a syntax error, an unknown filter, a broken Word template.
render_error422The page could not be loaded or rendered.
ai_refused422The AI generator could not turn the prompt into a document template.
quota_exceeded429You have used this month's documents or AI generations.
rate_limited429Too many requests in a short time.
internal_error500Something broke on our side.
ai_unavailable503The AI generator is busy or returned something unusable.
not_configured503The feature is switched off on our side for now.
render_timeout504The render ran out of time.

#What to do

#invalid_request

Read the message. It names the field and says what it expected. These are bugs in the calling code, so fix the request rather than retrying it.

In a batch, the message starts with the position of the offending item, for example items[3]: ....

#unauthorized

Send the key as Authorization: Bearer dp_live_.... If the key was revoked, create a new one in the dashboard under API keys. See authentication.

#forbidden

You tried to edit or delete a starter template (copy it first, then change the copy), or you called a dashboard-only endpoint with an API key.

#plan_limit

The message says which limit. Common causes: a batch larger than your plan allows, S3 delivery or EU storage on Free, embed tokens below Growth. Upgrade, or stay inside the limit. See limits.

#not_found

Check the id, and check that you are using a key from the account that owns it. Ids from one account never resolve on another. A deleted template also returns not_found when rendered.

#payload_too_large

Something is over a size limit: the html field for your plan, the request body, an input PDF, or an uploaded template file. See limits. For big HTML, host heavy images and fonts at a URL instead of inlining them as base64.

#template_error

Extra fieldDescription
lineLine in the template where the problem is, when known.
colColumn on that line, when known.

Fix the template. The dashboard editor reports the same error in its live preview, and POST /v1/templates/validate checks a template without rendering it. See the template language.

#render_error

The browser could not produce the document. Typical causes: a url that does not load or is not public, a selector that matches nothing, an S3 upload that your bucket rejected.

Extra fieldDescription
retryabletrue when the failure was on our side (the renderer was at capacity or crashed) and the same request is likely to work on a second try.

Retry when retryable is true. Otherwise fix the cause named in the message.

#render_timeout

Templates and HTML get 30 seconds; URLs get 45. Look for slow images or fonts, a wait_for selector that never appears, or a page that never finishes loading. A timeout can also be a one-off, so one retry is reasonable.

#quota_exceeded

Extra fieldDescription
limitYour plan's monthly allowance for the thing you ran out of.
resets_atWhen the allowance resets: the first day of next month, 00:00 UTC.

Upgrade in the dashboard for an immediate higher allowance, or wait for the reset. Check where you stand at any time with GET /v1/usage.

#rate_limited

You are over 600 requests per minute. Wait a few seconds and retry with backoff. If you are generating many documents at once, use a batch: one request for up to 1,000 documents, depending on your plan.

#ai_refused and ai_unavailable

ai_refused means the prompt did not describe a document. Rewrite it. ai_unavailable is temporary: try again shortly. Neither uses an AI generation. See AI templates.

#internal_error and not_configured

Not your fault. Retry internal_error after a short pause. If it keeps happening, email support@devilpdf.com with the document id or the time of the request.

#Failed renders are free

A render that fails, for any reason, does not count against your monthly documents. The same goes for failed AI generations.

#Errors on async documents

An async render or batch item is accepted with 202 before it is rendered, so a later failure cannot come back as an HTTP error. Instead the document ends with "status": "failed" and carries the error:

{
  "object": "document",
  "id": "doc_nWWGc4ehhC44vpOsHFGn",
  "status": "failed",
  "url": null,
  "error": {
    "type": "render_timeout",
    "message": "Rendering took too long and was stopped. Check for slow images or fonts, or a wait_for selector that never appears."
  }
}

You see it when you fetch the document, and in the document.failed webhook. Problems that can be caught up front (bad fields, a missing template, no quota left) are still returned immediately as normal errors.

#Handling errors in code

async function render(body) {
  for (let attempt = 1; ; attempt++) {
    const res = await fetch("https://devilpdf.com/v1/render", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.DEVILPDF_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
    });
    if (res.ok) return res.json();

    const { error } = await res.json();
    const retry =
      error.type === "rate_limited" ||
      error.type === "render_timeout" ||
      error.type === "internal_error" ||
      error.retryable === true;
    if (!retry || attempt === 3) {
      throw Object.assign(new Error(error.message), { type: error.type, status: res.status });
    }
    await new Promise((r) => setTimeout(r, attempt * 2000));
  }
}

Retry only the types shown. Everything else will fail the same way until the request changes.