> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dockiln.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate your first PDF

> Submit a small HTML document, follow its job and save the PDF. This walkthrough uses Bash, curl and jq against a running DocKiln instance.

## Connect to a workspace

Open the [workspace](https://dockiln.io/app), sign in and choose **Settings → API keys → Create key**. Copy the key when it appears. For local development, [start the Docker stack](https://docs.dockiln.io/deployment.md#run-locally) first.

Set the instance URL to the origin you use in your browser. For the hosted service:

```bash title="Terminal" theme={null}
export DOCKILN_URL=https://dockiln.io
read -rsp 'Workspace API key: ' DOCKILN_API_KEY; echo
export DOCKILN_API_KEY
```

## Submit the HTML

```bash theme={null}
curl --fail-with-body -sS "$DOCKILN_URL/v1/documents" \
  -H "Authorization: Bearer $DOCKILN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Order confirmed</h1><p>Order DK-1042</p>"}'
```

Copy the returned `id`. The status in the initial response describes the job at admission. Rendering continues on the worker.

## Download the result

Set `JOB_ID` to the ID from your response. This loop checks for up to one minute, stops on an error and only writes a file when the worker has finished.

```bash title="download.sh" theme={null}
set -eu
: "${JOB_ID:?Set JOB_ID to the returned document ID}"
for attempt in {1..30}; do
  job=$(curl -fsS -H "Authorization: Bearer $DOCKILN_API_KEY" \
    "$DOCKILN_URL/v1/documents/$JOB_ID")
  case "$(jq -r '.status' <<<"$job")" in
    completed)
      curl -fsS -H "Authorization: Bearer $DOCKILN_API_KEY" \
        "$DOCKILN_URL$(jq -r '.download' <<<"$job")" -o order.pdf
      exit 0 ;;
    failed) jq -r '.error' <<<"$job" >&2; exit 1 ;;
  esac
  sleep 2
done
echo "Still processing. Keep JOB_ID and check again." >&2
exit 1
```

Open `order.pdf`. The first page should read **Order confirmed** and show **Order DK-1042**. The same job appears under **Documents** in the workspace.

## Use it in an application

Submit requests from your server so the workspace key stays private. The [Next.js invoice guide](https://dockiln.io/guides/nextjs-invoice) and [Node client example](https://dockiln.io/examples/client.mjs) show how to integrate submission, bounded polling and downloads. Use [idempotency keys](https://docs.dockiln.io/api.md#retry-a-submission) when retrying a submission.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.