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

# cURL Examples

> Command-line examples for DocIntell

Command-line examples using cURL.

## Set Your API Key

```bash theme={null}
export DOCINTELL_API_KEY="dk_live_YOUR_KEY_HERE"
```

## Upload a Document

```bash theme={null}
curl -X POST https://api.docintell.com/v1/documents \
  -H "Authorization: Bearer $DOCINTELL_API_KEY" \
  -F "file=@invoice.pdf" \
  -F "retention_years=7"
```

**Response:**

```json theme={null}
{
  "document_id": "019370ab-c123-7def-8901-234567890abc",
  "job_id": "019370ab-c456-7def-8901-234567890def",
  "status": "pending"
}
```

## Check Job Status

```bash theme={null}
curl -X GET https://api.docintell.com/v1/jobs/019370ab-c456-7def-8901-234567890def \
  -H "Authorization: Bearer $DOCINTELL_API_KEY"
```

## List Documents

```bash theme={null}
curl -X GET "https://api.docintell.com/v1/documents?page=1&per_page=20" \
  -H "Authorization: Bearer $DOCINTELL_API_KEY"
```

## Create a Webhook

```bash theme={null}
curl -X POST https://api.docintell.com/v1/webhooks \
  -H "Authorization: Bearer $DOCINTELL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/docintell",
    "events": ["job.completed", "job.failed"]
  }'
```

## Health Check

```bash theme={null}
curl -X GET https://api.docintell.com/health
```

## Shell Script: Complete Workflow

```bash theme={null}
#!/bin/bash
set -e

API_KEY="$DOCINTELL_API_KEY"
FILE="$1"

if [ -z "$FILE" ]; then
  echo "Usage: $0 <pdf-file>"
  exit 1
fi

# Upload
echo "Uploading $FILE..."
RESULT=$(curl -s -X POST https://api.docintell.com/v1/documents \
  -H "Authorization: Bearer $API_KEY" \
  -F "file=@$FILE")

JOB_ID=$(echo $RESULT | jq -r '.job_id')
DOC_ID=$(echo $RESULT | jq -r '.document_id')

echo "Document ID: $DOC_ID"
echo "Job ID: $JOB_ID"

# Wait for completion
echo "Waiting for extraction to complete..."
while true; do
  STATUS=$(curl -s -X GET "https://api.docintell.com/v1/jobs/$JOB_ID" \
    -H "Authorization: Bearer $API_KEY" | jq -r '.status')

  if [ "$STATUS" = "completed" ]; then
    echo "Extraction completed!"
    break
  elif [ "$STATUS" = "failed" ]; then
    echo "Extraction failed!"
    exit 1
  fi

  sleep 2
done
```
