API Failure handling · 8 min read

Errors

BladePDF errors can happen before the request is sent, while the API validates the render, or while the PDF is being generated. Handle them explicitly so your app can retry safely or show useful feedback.

Package exceptions

Exception Cause
MissingApiKeyException BLADEPDF_API_KEY is empty.
AssetNotFoundException A manually attached asset path does not exist.
InvalidRenderConfigurationException The fluent API was used in an unsupported combination, such as header HTML on a cloud template render or async() without storePdf().
RenderFailedException BladePDF returned a non-successful HTTP response.

Handling exceptions

Controller
php
 1use BladePDF\Laravel\Exceptions\BladePdfException;
 2use Illuminate\Support\Facades\Log;
 3
 4try {
 5    return BladePDF::fromTemplate('invoice.standard', $context)
 6        ->reference($invoice->uuid)
 7        ->render()
 8        ->download('invoice.pdf');
 9} catch (BladePdfException $e) {
10    Log::warning('BladePDF render failed', [
11        'invoice_id' => $invoice->id,
12        'message' => $e->getMessage(),
13    ]);
14
15    return back()->withErrors([
16        'pdf' => 'The PDF could not be generated. Please try again.',
17    ]);
18}

API status codes

Status Meaning Typical fix
400Invalid render request.Check source, context, metadata, options, and required files.
401Missing authentication.Set BLADEPDF_API_KEY.
403The API key is not allowed to render.Check API key, account, and plan status.
408Render timed out.Reduce complexity or increase plan/render timeout if available.
413Payload is too large.Reduce HTML/context/assets size.
429Concurrency or queue limit reached.Retry later with backoff or lower concurrency.
500Unexpected render failure.Check dashboard logs and retry if safe.
508Daily bandwidth limit reached.Wait for reset or adjust plan.
509Monthly bandwidth limit reached.Wait for reset or adjust plan.

Common validation errors

  • Missing main html input file. The request was source: html but no HTML file was sent.
  • Missing context input file. The request was source: template but no context JSON file was sent.
  • HTML file fields are not supported for template render source. Cloud template renders cannot include html, header_html, or footer_html.
  • metadata.template_name is only supported for html render source. Use reference() for cloud templates.
  • waitUntil option requires waitFunction Use waitFunction() when waitUntil('function') is set.
  • Asynchronous renders require store_pdf=true. Call storePdf() before async().
  • Asynchronous renders require available PDF storage... Free workspace storage before submitting another async render.

Render limit errors

BladePDF enforces limits for render time, PDF size, payload size, network access, and asset requests. Limit errors appear in dashboard logs and are delivered through pdf.failed webhooks.

Safe retries

Retrying is usually safe when your render operation has no side effects. Use your own idempotency key or reference() value to avoid duplicate downstream work.

Retry reference
php
 1BladePDF::fromTemplate('invoice.standard', $context)
 2    ->reference($invoice->uuid)
 3    ->render()
 4    ->pdf();

Debugging

Every render appears in the dashboard with request id, logs, timing metrics, asset counts, failure message, and template/reference metadata. Start there when a render fails in production.

Was this page helpful?
Let us know if something's missing or unclear.