An error can mean the request was not accepted, a temporary request failed, or document processing finished without all of its content. Start with the error code and the job's current state before deciding to submit the file again.
Read an SDK error
The SDK exposes PageletError. It includes a code and message, plus the HTTP status, requestId, and details when available.
import { Pagelet, PageletError } from "@pagelet-ai/sdk"
const client = new Pagelet()
try {
const result = await client.documents.create({ file: "statement.pdf" })
console.log(result.document.id)
} catch (error) {
if (!(error instanceof PageletError)) throw error
console.error(error.code, error.message, error.requestId)
}Save the request ID when reporting an API problem. Do not include API keys or webhook secrets in logs or support messages.
Choose the next action
| Error code | What to do |
|---|---|
invalid_request | Correct the request. Validation details identify affected fields. |
unauthorized | Check the key and target environment. |
forbidden | Check key permissions and workspace feature access. |
not_found | Check the ID, workspace, and whether the content is still retained. |
capacity_exceeded | Wait before trying again. For Search, check your workspace's search limits. |
tenant_page_allowance_exceeded | Check the workspace's allowance and plan. |
upload_too_large | Use a file within the upload limit. |
upload_expired | Start a new upload; the old upload can no longer be confirmed. |
result_not_ready | Check the existing job later; do not upload another copy. |
search_unavailable | Search is temporarily unavailable. Try again after a short wait. |
webhook_not_configured | Set up webhook signing, or disable notification for that submission. |
idempotency_conflict | Use the original request with that key, or a new key for genuinely new work. |
idempotency_key_expired | Reconcile the original submission before choosing a new key. |
document_transfer_failed, request_failed, and request_timeout describe SDK request or transfer failures. Inspect the available status and the existing submission before choosing recovery.
Automatic retries
The SDK retries eligible temporary failures up to two times after the first attempt. API retries cover transport failures and HTTP 408, 500, 502, 503, and 504. File transfers also handle temporary conflicts according to the upload protocol.
The SDK does not automatically retry 429 responses or result_not_ready. Your application chooses when to retry a capacity or Search-limit response. A status read and a result read do not become polling loops.
Avoid duplicate submissions
For your application's retries of the same submission, keep the same idempotencyKey and request. If you omit the key, the SDK generates one for that call and keeps it through its own retries. Calling creation again without preserving the key is a new submission.
An application reference such as externalId is useful for correlation, but it is not a deduplication key.
Recover after waiting ends
A completion timeout or local cancellation does not cancel processing already admitted by the service. A completion_timeout error carries the job ID in details.job_id; use it to check progress and retrieve the result. If your application needs to persist the ID before processing finishes, start with jobs.create.
A processing job can finish with warnings or have an inspectable result despite failure. Check result_available, then inspect page warnings and nullable content. See Read and use results.