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

# API Integration

> Complete guide to integrating Peedief API into your applications

# API Integration

## Authentication

All API requests require authentication using an API key. Create your API key in the [dashboard](https://peedief.com/app/api-keys) under API Keys section.

<Card title="Quick Setup" icon="rocket">
  Dashboard → API Keys → Generate New API Key → Copy for use in headers
</Card>

## Basic API Usage

### Template PDF Generation

**Endpoint**: `POST https://peedief.com/api/templates/by-name/{templateName}/pdf`

**Headers**:

```
x-api-key: YOUR_API_KEY
Content-Type: application/json
```

**Basic Request**:

```json theme={null}
{
  "contextJson": {
    "customerName": "John Doe",
    "invoiceNumber": "INV-001",
    "amount": 150.00
  },
  "fileName": "invoice-001.pdf"
}
```

**Response**:

```json theme={null}
{
  "success": true,
  "downloadUrl": "https://peedief.com/download/abc123...",
  "previewUrl": "https://peedief.com/preview/abc123...",
  "fileName": "invoice-001.pdf",
  "fileSize": 245760,
  "templateId": "tpl_abc123",
  "templateName": "invoice"
}
```

### Template Context Data

Provide dynamic data to populate your template:

```json theme={null}
{
  "contextJson": {
    "companyName": "Acme Corp",
    "customerInfo": {
      "name": "Jane Smith",
      "email": "jane@example.com",
      "address": "123 Main St, City, State 12345"
    },
    "items": [
      {
        "description": "Product A",
        "quantity": 2,
        "price": 50.00
      },
      {
        "description": "Product B",
        "quantity": 1,
        "price": 75.00
      }
    ],
    "total": 175.00,
    "dueDate": "2024-02-15"
  },
  "fileName": "invoice-jane-smith.pdf"
}
```

<Card title="Template Features">
  * **Dynamic content**: Populate templates with any JSON data
  * **Nested objects**: Support for complex data structures
  * **Arrays**: Handle lists and tables in your templates
  * **Custom filename**: Optional filename generation
  * **Template variables**: Use placeholders in your pre-designed templates
</Card>

## No-Code Tools Integration

### Zapier Integration

<Steps>
  <Step title="Create New Zap">
    Start a new automation in Zapier
  </Step>

  <Step title="Add Webhook Action">
    Use "Webhooks by Zapier" as your action
  </Step>

  <Step title="Configure Action Event">
    Action event: POST
  </Step>

  <Step title="Set URL">
    URL: `https://peedief.com/api/templates/by-name/invoice/pdf`
  </Step>

  <Step title="Configure Payload">
    * Payload Type: Json
    * Data:
      * contextJson: `{"customerName": "John Doe", "amount": 100}`
      * fileName: `invoice.pdf`
  </Step>

  <Step title="Add Headers">
    Headers:

    * `x-api-key`: `YOUR_API_KEY`
  </Step>
</Steps>

### Make.com Integration

<Steps>
  <Step title="Add HTTP Module">
    Create a new scenario and add "HTTP > Make a request" module
  </Step>

  <Step title="Configure URL">
    URL: `https://peedief.com/api/templates/by-name/invoice/pdf`
  </Step>

  <Step title="Set Method">
    Method: POST
  </Step>

  <Step title="Add Header">
    * Name: `x-api-key`
    * Value: `YOUR_API_KEY`
  </Step>

  <Step title="Configure Body">
    * Body type: Raw
    * Content type: application/json
    * Request content: `{ "contextJson": {"customerName": "John Doe", "amount": 100}, "fileName": "invoice.pdf" }`
  </Step>

  <Step title="Save">
    Save your configuration to complete the setup
  </Step>
</Steps>

<Card title="Embed Previews" icon="eye">
  Use the `previewUrl` from the response as the `src` of an iframe for instant, read-only previews. The signed link shares the same expiration window as `downloadUrl`.
</Card>

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Complete API endpoint documentation
  </Card>

  <Card title="Best Practices" icon="star" href="/best-practices">
    Optimize your API usage and security
  </Card>
</CardGroup>
