# Quickstart

This walks the full roundtrip with `curl`. You need an [API key](https://docs.accessful.de/authentication/)
and a PDF. Export the key first:

```bash
export ACCESSFUL_API_KEY="ak_your_key_here"
export BASE="https://api.accessful.de/api/v1/upload-service"
```

1. **Upload the PDF.** Send it as multipart form field `files`:

   ```bash
   curl -X POST "$BASE/pdf/upload" \
     -H "X-API-Key: $ACCESSFUL_API_KEY" \
     -F "files=@document.pdf"
   ```

   The response lists one `caseId` per accepted file:

   ```json
   {
     "successfulUploads": ["7c2f1e4a-9b0d-4a1e-8f3c-2d6b5a9e1c40"],
     "duplicateFiles": [],
     "message": "Upload completed successfully. Uploaded 1 files. 0 duplicates found.",
     "callbackUrl": null
   }
   ```

2. **Poll the job status** with that `caseId` until it is `completed`:

   ```bash
   curl "$BASE/job-status/7c2f1e4a-9b0d-4a1e-8f3c-2d6b5a9e1c40" \
     -H "X-API-Key: $ACCESSFUL_API_KEY"
   ```

   ```json
   { "jobStatus": "completed", "stage": "finished", "score": 87 }
   ```

   `score` is the accessibility quality of the result (0–100). See all
   [`jobStatus` values](https://docs.accessful.de/reference/job-status/).

3. **Download** the converted PDF/UA:

   ```bash
   curl -L "$BASE/download/7c2f1e4a-9b0d-4a1e-8f3c-2d6b5a9e1c40" \
     -H "X-API-Key: $ACCESSFUL_API_KEY" \
     -o document-pdfua.pdf
   ```

4. **Delete the case** when you no longer need it (optional, but recommended —
   this is a permanent purge):

   ```bash
   curl -X DELETE "$BASE/delete/7c2f1e4a-9b0d-4a1e-8f3c-2d6b5a9e1c40" \
     -H "X-API-Key: $ACCESSFUL_API_KEY"
   ```
**Skip the polling:** Instead of step&nbsp;2, register a [webhook](https://docs.accessful.de/webhooks/) at upload time and we'll
POST a signed event to your URL the moment the job finishes.

## Full example

```js
const BASE = 'https://api.accessful.de/api/v1/upload-service';
const headers = { 'X-API-Key': process.env.ACCESSFUL_API_KEY };

// 1. Upload
const form = new FormData();
form.append('files', new Blob([await readFile('document.pdf')], { type: 'application/pdf' }), 'document.pdf');
const up = await fetch(`${BASE}/pdf/upload`, { method: 'POST', headers, body: form });
const { successfulUploads: [caseId] } = await up.json();

// 2. Poll until terminal
const terminal = new Set(['completed', 'failed', 'analyzer_failed', 'canceled', 'quota_exceeded']);
let status;
do {
  await new Promise((r) => setTimeout(r, 2000));
  status = await (await fetch(`${BASE}/job-status/${caseId}`, { headers })).json();
} while (!terminal.has(status.jobStatus));

if (status.jobStatus !== 'completed') throw new Error(`Job ${status.jobStatus}`);

// 3. Download
const pdf = await (await fetch(`${BASE}/download/${caseId}`, { headers })).arrayBuffer();
await writeFile('document-pdfua.pdf', Buffer.from(pdf));
console.log(`Done — score ${status.score}`);
```
Prefer to click instead of type? Run the same flow in the browser on the
[Try it out](https://docs.accessful.de/try-it-out/) page.