# Use HTTP (/docs/http)

Use the HTTP API when you are integrating without the Node.js SDK. Submit a document by creating an upload, sending the file to its signed destination, and confirming it. Then read job status and retrieve the result.

The [SDK](/docs/sdk-quickstart) handles this sequence for you. This guide shows the HTTP steps explicitly.

## Before you start [#before-you-start]

You'll need a file, an API key with Create uploads, Read job status, and Read results permissions, and your deployment's API origin. The examples use Bash, `curl`, and `jq`.

Set `API_URL` to that origin without a trailing slash, and `PAGELET_API_KEY` to your key. Save the [sample statement](/docs/samples/statement.pdf) as `statement.pdf`, or substitute your own file and filename.

The public specification is available at `${API_URL}/openapi.json`. Its schemas describe the implemented HTTP requests and responses. SDK result aggregation is a client feature; HTTP result reads remain paginated.

## 1. Create an upload [#1-create-an-upload]

```sh
curl --fail-with-body "$API_URL/v1/uploads" \
  --header "Authorization: Bearer $PAGELET_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: statement-submission-001" \
  --data '{"filename":"statement.pdf"}' \
  --output upload.json

UPLOAD_ID=$(jq -r '.upload_id' upload.json)
JOB_ID=$(jq -r '.job_id' upload.json)
```

Omitting `classification`, as above, uses saved [workspace defaults](/docs/workspace-and-team#classification-defaults). Include `"classification": null` to skip it for one upload, or a category/criteria array to override the defaults.

The response contains the upload and job IDs, signed transfer instructions, expiry, and maximum file size. Use a new idempotency key for each new submission. Reuse the same key and request when retrying that submission within its upload window.

## 2. Transfer the file [#2-transfer-the-file]

Use the returned URL, method, and headers. The current upload contract returns `content-type` and `if-none-match` headers:

```sh
curl --fail-with-body \
  --request "$(jq -r '.upload.method' upload.json)" \
  --header "Content-Type: $(jq -r '.upload.headers["content-type"]' upload.json)" \
  --header "If-None-Match: $(jq -r '.upload.headers["if-none-match"]' upload.json)" \
  --upload-file statement.pdf \
  "$(jq -r '.upload.url' upload.json)"
```

Do not send your API key to the signed file destination. Treat the signed URL as temporary access and keep it out of public logs.

## 3. Confirm the upload [#3-confirm-the-upload]

After the file transfer succeeds:

```sh
curl --fail-with-body --request POST \
  "$API_URL/v1/uploads/$UPLOAD_ID/confirm" \
  --header "Authorization: Bearer $PAGELET_API_KEY" \
  --output status.json
```

Confirmation starts the document's admission and processing flow. Sending file bytes alone does not start processing. Confirm before the expiry returned by upload creation.

## 4. Check progress [#4-check-progress]

```sh
curl --fail-with-body "$API_URL/v1/jobs/$JOB_ID" \
  --header "Authorization: Bearer $PAGELET_API_KEY" \
  --output status.json

jq '{status, progress, result_available, detail}' status.json
```

Repeat this request with a delay while processing remains active, or use [webhooks](/docs/background-processing). Stop on a final status. When `result_available` is true, retrieve the result even if the final status reports a processing failure.

## 5. Retrieve all result pages [#5-retrieve-all-result-pages]

After the result is available, fetch each page window. This loop saves every response and follows `pagination.next_start` until it is `null`:

```sh
PAGE_START=1
while [ "$PAGE_START" != "null" ]; do
  RESULT_FILE="result-$PAGE_START.json"
  curl --fail-with-body \
    "$API_URL/v1/jobs/$JOB_ID/result?page_start=$PAGE_START&page_limit=50" \
    --header "Authorization: Bearer $PAGELET_API_KEY" \
    --output "$RESULT_FILE" || break
  jq '.pages' "$RESULT_FILE"
  PAGE_START=$(jq -r '.pagination.next_start' "$RESULT_FILE")
done
```

The responses include document and job details, page content, and warnings. A failed page has `markdown: null`; a successfully processed page without text has `markdown: ""`. Keep that distinction when using the content. [Read and use results](/docs/results) explains the fields.

## Recover an interrupted submission [#recover-an-interrupted-submission]

Keep the upload and job IDs so you can inspect the existing submission. If confirmation's response is lost, repeat confirmation for the same upload rather than creating another one.

A repeated signed transfer may return `412` because the write-once destination already contains the file. For a retry of the same file and upload, proceed to confirmation rather than trying to overwrite it. Other transfer errors need their own diagnosis. Expired uploads require a new submission.

See [Errors and retries](/docs/errors-and-retries) for API error codes and the difference between retrying an existing request and creating a new document.
