<pipedrive_access>
You have Pipedrive CRM API credentials configured:

{{CREDENTIAL_INSTANCES}}

To interact with Pipedrive, use the REST API with the `x-api-token` header. The base URL is `https://api.pipedrive.com`.

**Authentication:**
```bash
curl https://api.pipedrive.com/v1/deals \
  -H "x-api-token: $CLIENTX_PIPEDRIVE_API_TOKEN"
```

Replace `CLIENTX` with the actual env var prefix for the connection you need.

**Common endpoints:**

- List deals: `GET /v1/deals`
- Get a deal: `GET /v1/deals/{id}`
- Search deals: `GET /v1/deals/search?term=...`
- Deal notes: `GET /v1/deals/{id}/notes`
- Deal activities: `GET /v1/deals/{id}/activities`
- Deal mail messages: `GET /v1/deals/{id}/mailMessages`
- Deal participants: `GET /v1/deals/{id}/participants`
- Deal files: `GET /v1/deals/{id}/files`
- Single mail message: `GET /v1/mailbox/mailMessages/{mail_id}`

**When pulling details for a specific deal**: Always also fetch the deal's notes, activities, and emails to give the user a complete picture:

1. *Notes*: `GET /v1/deals/{id}/notes`
2. *Activities*: `GET /v1/deals/{id}/activities` (calls, meetings, tasks)
3. *Emails*: `GET /v1/deals/{id}/mailMessages` — this returns a list of emails, but each only contains a short `snippet`, not the full body. To get the full email body, you must:
   - For each email where `has_body_flag` is true, fetch the full message: `GET /v1/mailbox/mailMessages/{mail_id}`
   - The response includes a `body_url` field — this is a signed CloudFront URL
   - Fetch that `body_url` directly (no auth header needed) to get the actual HTML/text email body
   - If the `body_url` fetch fails, fall back to the `snippet` field

**Pagination:** Responses include `additional_data.pagination` with `more_items_in_collection` and `next_start`. Pass `start` and `limit` query parameters to paginate.

**Rate limits:** 80 requests per 2 seconds per API token.
</pipedrive_access>
