# PandaDoc

PandaDoc is a document automation and eSignature platform. The Sling PandaDoc connector extracts data from the PandaDoc API, supporting documents, templates, contacts, members, forms, folders, workspaces, and more.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](/sling-cli/cli-pro.md) or [Platform Plan](/sling-platform/platform.md).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `api_key` **(required)** -> Your PandaDoc Sandbox or Production API key

**Inputs:**

* `anchor_date` (optional) -> The starting date for historical data extraction (default: 1 year ago). Format: `YYYY-MM-DDTHH:MM:SSZ`

### Getting Your API Key

PandaDoc provides a free Sandbox API key with trial accounts:

1. Sign up for a free trial at <https://signup.pandadoc.com/>
2. Go to **Settings** > **API and Integrations**
3. Click on **API and Webhooks**
4. Click **Enable** to activate the API
5. Click **Open** to access the Dev Center
6. Under **API keys**, click **Generate** next to **Sandbox key**
7. Copy the generated key

{% hint style="info" %}
**Sandbox vs Production:** The Sandbox key is rate-limited to 10 requests per minute and adds a `[DEV]` prefix to documents. Production keys require an Enterprise plan.
{% endhint %}

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set PANDADOC type=api spec=pandadoc secrets='{ api_key: your_api_key_here }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export PANDADOC='{ type: api, spec: pandadoc, secrets: { api_key: "your_api_key_here" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/connections/api-connections/pages/eAdVs2BHCgdr6RS8GoJC#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  PANDADOC:
    type: api
    spec: pandadoc
    secrets:
      api_key: "your_api_key_here"
```

**With anchor date for historical data:**

```yaml
connections:
  PANDADOC:
    type: api
    spec: pandadoc
    secrets:
      api_key: "your_api_key_here"
    inputs:
      anchor_date: "2024-01-01T00:00:00Z"
```

## Replication

Here's an example replication configuration to sync PandaDoc to a PostgreSQL database:

```yaml
source: PANDADOC
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: public.pandadoc_{stream_name}

streams:
  # sync all endpoints
  '*':

  # incremental sync for documents
  documents:
    mode: incremental
    primary_key: [id]
    update_key: date_modified
```

## Endpoints

| Endpoint                | Description                                                              | Incremental             |
| ----------------------- | ------------------------------------------------------------------------ | ----------------------- |
| `documents`             | All documents with metadata                                              | Yes (`date_modified`)   |
| `document_details`      | Detailed document info including fields, recipients, tokens, and pricing | No (child of documents) |
| `document_fields`       | Fields for each document                                                 | No (child of documents) |
| `document_attachments`  | Attachments for each document                                            | No (child of documents) |
| `document_sections`     | Sections/bundles for each document                                       | No (child of documents) |
| `templates`             | All document templates                                                   | No                      |
| `contacts`              | All contacts                                                             | No                      |
| `members`               | Workspace members                                                        | No                      |
| `forms`                 | All forms                                                                | No                      |
| `document_folders`      | Document folder hierarchy                                                | No                      |
| `template_folders`      | Template folder hierarchy                                                | No                      |
| `api_logs`              | API request logs                                                         | No                      |
| `webhook_subscriptions` | Webhook subscription configurations                                      | No                      |
| `webhook_events`        | Webhook event history                                                    | No                      |
| `workspaces`            | All workspaces                                                           | No                      |

## Incremental Sync

The `documents` endpoint supports incremental sync using the `date_modified` field. On first sync, it fetches all documents modified since `anchor_date` (default: 1 year ago). Subsequent syncs fetch only documents modified since the last successful sync.

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/connections/api-connections/pandadoc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
