# Pipedrive Integration via LowCodeAPI

## Overview

Pipedrive is a sales-focused CRM platform helping teams manage leads and deals. The Pipedrive API provides comprehensive functionality for:

- **Activities** - Manage tasks, calls, meetings, and other activities
- **Deals** - Track and manage sales opportunities
- **Persons** - Manage contact information
- **Organizations** - Handle company accounts
- **Products** - Manage product catalog
- **Notes** - Attach notes to deals and contacts
- **Search** - Find items across the CRM

## Base Endpoint

```
https://api.lowcodeapi.com/pipedrive/
```

## Authentication

LowCodeAPI handles authentication automatically using Bearer token authentication. You only need to:

1. **Sign up** at [Pipedrive](https://pipedrive.com) to get your Access Token
2. **Connect your account** in the LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Pipedrive access token
- Apply it to each request as a Bearer token

**Auth Type**: Bearer Token

## API Categories

- **CRM & Marketing** - Customer relationship management and sales

## Common Endpoints

### Category: Activities

#### Get Activities

**Method**: `GET` | **LowCodeAPI Path**: `/v1/activities`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/activities?api_token={api_token}
```

**Description**: Get all activities assigned to a particular user.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | integer | No | User ID whose activities to fetch |
| `filter_id` | integer | No | Filter ID to apply |
| `start` | date | No | Pagination start date |
| `end` | date | No | Pagination end date |
| `limit` | integer | No | Number of items (default: 0, all) |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/activities?api_token=YOUR_API_TOKEN&user_id=1&limit=50"
```

**Official Documentation**: [Get Activities](https://developers.pipedrive.com/docs/api/v1/#!/Activities)

---

#### Add Activity

**Method**: `POST` | **LowCodeAPI Path**: `/v1/activities`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/activities?api_token={api_token}
```

**Description**: Add a new activity (task, call, meeting, etc.).

**Request Body**:
```json
{
  "subject": "Follow-up call",
  "type": "call",
  "due_date": "2024-01-30",
  "due_time": "14:00",
  "duration": "01:00:00",
  "note": "Discuss proposal details",
  "deal_id": 123,
  "person_id": 456,
  "user_id": 1
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `subject` | string | Yes | Activity subject/title |
| `type` | string | Yes | Activity type: call, meeting, task, etc. |
| `due_date` | date | No | Due date (YYYY-MM-DD) |
| `due_time` | time | No | Due time (HH:MM) |
| `duration` | string | No | Duration (HH:MM:SS) |
| `note` | string | No | Activity notes |
| `deal_id` | integer | No | Associated deal ID |
| `person_id` | integer | No | Associated person ID |
| `user_id` | integer | No | Assigned user ID |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/activities?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Product Demo",
    "type": "meeting",
    "due_date": "2024-02-01",
    "due_time": "15:00",
    "person_id": 123
  }'
```

**Official Documentation**: [Add Activity](https://developers.pipedrive.com/docs/api/v1/#!/Activities)

---

### Category: Deals

#### Get Deals

**Method**: `GET` | **LowCodeAPI Path**: `/v1/deals`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/deals?api_token={api_token}
```

**Description**: Get all deals.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | integer | No | Filter by user ID |
| `filter_id` | integer | No | Filter ID to apply |
| `stage_id` | integer | No | Filter by pipeline stage |
| `status` | string | No | Filter by status: open, won, lost |
| `limit` | integer | No | Number of items |
| `start` | integer | No | Pagination start |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/deals?api_token=YOUR_API_TOKEN&status=open&limit=50"
```

**Official Documentation**: [Get Deals](https://developers.pipedrive.com/docs/api/v1/#!/Deals)

---

#### Add Deal

**Method**: `POST` | **LowCodeAPI Path**: `/v1/deals`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/deals?api_token={api_token}
```

**Description**: Add a new deal.

**Request Body**:
```json
{
  "title": "Enterprise License Deal",
  "value": 50000,
  "currency": "USD",
  "user_id": 1,
  "person_id": 456,
  "org_id": 789,
  "stage_id": 1,
  "status": "open",
  "expected_close_date": "2024-06-30"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `title` | string | Yes | Deal title |
| `value` | number | No | Deal value |
| `currency` | string | No | Currency code (default: account default) |
| `user_id` | integer | No | Assigned user ID |
| `person_id` | integer | No | Associated person ID |
| `org_id` | integer | No | Associated organization ID |
| `stage_id` | integer | No | Pipeline stage ID |
| `status` | string | No | Status: open, won, lost, deleted |
| `expected_close_date` | date | No | Expected close date |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/deals?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "New Software License",
    "value": 25000,
    "currency": "USD",
    "stage_id": 1,
    "person_id": 123
  }'
```

**Official Documentation**: [Add Deal](https://developers.pipedrive.com/docs/api/v1/#!/Deals)

---

#### Update Deal

**Method**: `PUT` | **LowCodeAPI Path**: `/v1/deals/id`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/deals/id?id={id}&api_token={api_token}
```

**Description**: Update a deal.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | integer | Yes | Deal ID |

**Request Body**:
```json
{
  "title": "Updated Deal Title",
  "value": 75000,
  "stage_id": 2,
  "status": "won"
}
```

**Example Request**:
```bash
curl -X PUT "https://api.lowcodeapi.com/pipedrive/v1/deals/id?id=123&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Deal",
    "value": 75000,
    "status": "won"
  }'
```

**Official Documentation**: [Update Deal](https://developers.pipedrive.com/docs/api/v1/#!/Deals)

---

### Category: Persons

#### Get Persons

**Method**: `GET` | **LowCodeAPI Path**: `/v1/persons`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/persons?api_token={api_token}
```

**Description**: Get all persons.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | integer | No | Filter by user ID |
| `filter_id` | integer | No | Filter ID to apply |
| `limit` | integer | No | Number of items |
| `start` | integer | No | Pagination start |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/persons?api_token=YOUR_API_TOKEN&limit=100"
```

**Official Documentation**: [Get Persons](https://developers.pipedrive.com/docs/api/v1/#!/Persons)

---

#### Add Person

**Method**: `POST` | **LowCodeAPI Path**: `/v1/persons`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/persons?api_token={api_token}
```

**Description**: Add a new person.

**Request Body**:
```json
{
  "name": "John Doe",
  "first_name": "John",
  "last_name": "Doe",
  "email": [{"value": "[email protected]", "primary": true}],
  "phone": [{"value": "+15555555555", "primary": true}],
  "org_id": 456,
  "owner_id": 1
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | Yes | Full name |
| `first_name` | string | No | First name |
| `last_name` | string | No | Last name |
| `email` | array | No | Email addresses |
| `phone` | array | No | Phone numbers |
| `org_id` | integer | No | Organization ID |
| `owner_id` | integer | No | Owner user ID |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/persons?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Jane Smith",
    "email": [{"value": "[email protected]", "primary": true}],
    "phone": [{"value": "+15551234567", "primary": true}]
  }'
```

**Official Documentation**: [Add Person](https://developers.pipedrive.com/docs/api/v1/#!/Persons)

---

### Category: Organizations

#### Get Organizations

**Method**: `GET` | **LowCodeAPI Path**: `/v1/organizations`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/organizations?api_token={api_token}
```

**Description**: Get all organizations.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | integer | No | Filter by user ID |
| `filter_id` | integer | No | Filter ID to apply |
| `limit` | integer | No | Number of items |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/organizations?api_token=YOUR_API_TOKEN&limit=100"
```

**Official Documentation**: [Get Organizations](https://developers.pipedrive.com/docs/api/v1/#!/Organizations)

---

#### Add Organization

**Method**: `POST` | **LowCodeAPI Path**: `/v1/organizations`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/organizations?api_token={api_token}
```

**Description**: Add a new organization.

**Request Body**:
```json
{
  "name": "Acme Corporation",
  "owner_id": 1,
  "address": "123 Business Ave",
  "email": "[email protected]",
  "phone": "+15555555555"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | Yes | Organization name |
| `owner_id` | integer | No | Owner user ID |
| `address` | string | No | Address |
| `email` | string | No | Email |
| `phone` | string | No | Phone number |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/organizations?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TechStart Inc",
    "owner_id": 1,
    "email": "[email protected]"
  }'
```

**Official Documentation**: [Add Organization](https://developers.pipedrive.com/docs/api/v1/#!/Organizations)

---

### Category: Products

#### Get Products

**Method**: `GET` | **LowCodeAPI Path**: `/v1/products`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/products?api_token={api_token}
```

**Description**: Get all products.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `limit` | integer | No | Number of items |
| `start` | integer | No | Pagination start |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/products?api_token=YOUR_API_TOKEN&limit=100"
```

**Official Documentation**: [Get Products](https://developers.pipedrive.com/docs/api/v1/#!/Products)

---

#### Add Product

**Method**: `POST` | **LowCodeAPI Path**: `/v1/products`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/products?api_token={api_token}
```

**Description**: Add a new product.

**Request Body**:
```json
{
  "name": "Enterprise License",
  "code": "ENT-001",
  "unit_price": 10000,
  "tax": 21,
  "currency": "USD"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | Yes | Product name |
| `code` | string | No | Product code |
| `unit_price` | number | No | Unit price |
| `tax` | number | No | Tax percentage |
| `currency` | string | No | Currency code |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/products?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pro Plan Annual",
    "unit_price": 4999,
    "currency": "USD"
  }'
```

**Official Documentation**: [Add Product](https://developers.pipedrive.com/docs/api/v1/#!/Products)

---

### Category: Notes

#### Add Note

**Method**: `POST` | **LowCodeAPI Path**: `/v1/notes`

**Full URL**:
```
https://api.lowcodeapi.com/pipedrive/v1/notes?api_token={api_token}
```

**Description**: Add a note to a deal, person, or organization.

**Request Body**:
```json
{
  "content": "Meeting summary: Client interested in enterprise plan",
  "deal_id": 123,
  "person_id": 456,
  "pinned_to_deal_flag": true
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `content` | string | Yes | Note content |
| `deal_id` | integer | No | Associated deal ID |
| `person_id` | integer | No | Associated person ID |
| `org_id` | integer | No | Associated organization ID |
| `pinned_to_deal_flag` | boolean | No | Pin to deal |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/notes?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Discussed budget approval process with client",
    "deal_id": 123,
    "person_id": 456
  }'
```

**Official Documentation**: [Add Note](https://developers.pipedrive.com/docs/api/v1/#!/Notes)

---

## Usage Examples

### Example 1: Create Sales Opportunity

Create a new deal with contact:

```bash
# Step 1: Add a person/contact
# No ID needed - creates new person
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/persons?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Robert Johnson",
    "email": [{"value": "[email protected]", "primary": true}],
    "phone": [{"value": "+15559876543", "primary": true}]
  }'

# Step 2: Add organization/company
# No ID needed - creates new organization
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/organizations?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Johnson Technologies",
    "email": "[email protected]"
  }'

# Step 3: Create deal
# No ID needed - creates new deal
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/deals?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Software License Deal",
    "value": 50000,
    "currency": "USD",
    "person_id": 123,
    "org_id": 456,
    "stage_id": 1
  }'
```

### Example 2: Track Activities

Schedule and manage sales activities:

```bash
# Step 1: Add follow-up activity
# No ID needed - creates activity
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/activities?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Product Demo",
    "type": "meeting",
    "due_date": "2024-02-15",
    "due_time": "14:00",
    "deal_id": 123,
    "person_id": 456
  }'

# Step 2: Add note after activity
# No ID needed - creates note
curl -X POST "https://api.lowcodeapi.com/pipedrive/v1/notes?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Demo went well, client interested in premium features",
    "deal_id": 123
  }'

# Step 3: Update deal stage
# Replace DEAL_ID with actual deal ID
curl -X PUT "https://api.lowcodeapi.com/pipedrive/v1/deals/id?id=DEAL_ID&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"stage_id": 2, "value": 60000}'
```

### Example 3: Search and Filter

Find and analyze deals:

```bash
# Step 1: Get open deals by user
# No ID needed - filters by user
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/deals?api_token=YOUR_API_TOKEN&user_id=1&status=open&limit=50"

# Step 2: Get specific deal details
# Replace DEAL_ID with actual deal ID
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/deals/id?id=DEAL_ID&api_token=YOUR_API_TOKEN"

# Step 3: Get activities for user
# No ID needed - filters by user
curl -X GET "https://api.lowcodeapi.com/pipedrive/v1/activities?api_token=YOUR_API_TOKEN&user_id=1&limit=100"
```

## Complete Endpoint Reference

For a complete list of all 245 endpoints and their parameters, refer to:

- **OpenAPI Definition**: https://backend.lowcodeapi.com/pipedrive/definition
- **Official Pipedrive Documentation**: https://developers.pipedrive.com/docs/api/v1

## Rate Limits & Best Practices

- **Rate Limit**: Refer to your Pipedrive plan for rate limits
- **Best Practices**:
  - Store Pipedrive IDs (persons, deals, organizations) for efficient updates
  - Use filters for efficient data retrieval
  - Keep activity records up to date for accurate tracking
  - Link persons to organizations for better organization
  - Add notes to document important deal interactions
  - Use appropriate deal stages for pipeline management

## Error Handling

All responses are wrapped in a `data` key:
```json
{
  "data": {
    // Actual response from Pipedrive
  }
}
```