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

# cURL Examples

> Generate PDFs using cURL from the command line.

## Basic Generation

```bash theme={null}
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"htmlContent": "<h1>Hello World</h1>"}'
```

## With Dynamic Data

```bash theme={null}
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "htmlContent": "<h1>Invoice #{{invoiceNumber}}</h1>",
    "templateData": {"invoiceNumber": "INV-001"},
    "filename": "invoice.pdf"
  }'
```

## Using a Template

```bash theme={null}
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "tpl_invoice_v2",
    "templateData": {
      "invoiceNumber": "INV-2024-001",
      "customer": {"name": "Acme Corp"},
      "items": [{"description": "Web Dev", "quantity": 10, "price": 150}],
      "total": 1500
    }
  }'
```

## With Options

```bash theme={null}
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "htmlContent": "<h1>Document</h1>",
    "options": {
      "format": "Letter",
      "orientation": "landscape",
      "margin": {"top": 20, "right": 15, "bottom": 20, "left": 15}
    }
  }'
```

## Download PDF

```bash theme={null}
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"htmlContent": "<h1>Hello</h1>"}' \
  | jq -r '.data.url' \
  | xargs curl -o document.pdf
```

## Shell Script

```bash theme={null}
#!/bin/bash
API_KEY="${FILELOOM_API_KEY}"

generate_pdf() {
  curl -s -X POST "https://api.fileloom.io/v1/pdf/generate" \
    -H "X-API-Key: $API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"htmlContent\": \"$1\", \"filename\": \"$2\"}"
}

result=$(generate_pdf "<h1>Report</h1>" "report.pdf")
url=$(echo "$result" | jq -r '.data.url')
curl -s -o "report.pdf" "$url"
```
