@nextsparkjs/theme-crm 0.1.0-beta.44 → 0.1.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/entities/activities/api/docs.md +146 -0
- package/entities/activities/api/presets.ts +132 -0
- package/entities/campaigns/api/docs.md +140 -0
- package/entities/campaigns/api/presets.ts +147 -0
- package/entities/companies/api/docs.md +139 -0
- package/entities/companies/api/presets.ts +107 -0
- package/entities/contacts/api/docs.md +139 -0
- package/entities/contacts/api/presets.ts +98 -0
- package/entities/leads/api/docs.md +132 -0
- package/entities/leads/api/presets.ts +109 -0
- package/entities/notes/api/docs.md +135 -0
- package/entities/notes/api/presets.ts +115 -0
- package/entities/opportunities/api/docs.md +151 -0
- package/entities/opportunities/api/presets.ts +151 -0
- package/entities/pipelines/api/docs.md +145 -0
- package/entities/pipelines/api/presets.ts +118 -0
- package/entities/products/api/docs.md +137 -0
- package/entities/products/api/presets.ts +132 -0
- package/lib/selectors.ts +2 -2
- package/package.json +3 -3
- package/styles/globals.css +19 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Notes API
|
|
2
|
+
|
|
3
|
+
Manage notes and comments on CRM records. Notes can be linked to contacts, companies, and opportunities with support for pinning and privacy settings.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Notes API allows you to create, read, update, and delete note records. Notes provide a way to capture important information and comments about CRM entities.
|
|
8
|
+
|
|
9
|
+
## Authentication
|
|
10
|
+
|
|
11
|
+
All endpoints require authentication via:
|
|
12
|
+
- **Session cookie** (for browser-based requests)
|
|
13
|
+
- **API Key** header (for server-to-server requests)
|
|
14
|
+
|
|
15
|
+
## Endpoints
|
|
16
|
+
|
|
17
|
+
### List Notes
|
|
18
|
+
`GET /api/v1/notes`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of notes.
|
|
21
|
+
|
|
22
|
+
**Query Parameters:**
|
|
23
|
+
- `limit` (number, optional): Maximum records to return. Default: 20
|
|
24
|
+
- `offset` (number, optional): Number of records to skip. Default: 0
|
|
25
|
+
- `type` (string, optional): Filter by type (general, call, meeting, email, followup, feedback, reminder)
|
|
26
|
+
- `contactId` (string, optional): Filter by contact
|
|
27
|
+
- `companyId` (string, optional): Filter by company
|
|
28
|
+
- `opportunityId` (string, optional): Filter by opportunity
|
|
29
|
+
- `search` (string, optional): Search by title or content
|
|
30
|
+
- `sortBy` (string, optional): Field to sort by
|
|
31
|
+
- `sortOrder` (string, optional): Sort direction (asc, desc)
|
|
32
|
+
|
|
33
|
+
**Example Response:**
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"data": [
|
|
37
|
+
{
|
|
38
|
+
"id": "note_abc123",
|
|
39
|
+
"title": "Meeting Summary",
|
|
40
|
+
"content": "Discussed product roadmap and next steps...",
|
|
41
|
+
"type": "meeting",
|
|
42
|
+
"isPinned": true,
|
|
43
|
+
"isPrivate": false,
|
|
44
|
+
"contactId": "contact_456",
|
|
45
|
+
"companyId": "company_xyz",
|
|
46
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"pagination": {
|
|
50
|
+
"total": 234,
|
|
51
|
+
"limit": 20,
|
|
52
|
+
"offset": 0
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Get Single Note
|
|
58
|
+
`GET /api/v1/notes/[id]`
|
|
59
|
+
|
|
60
|
+
Returns a single note by ID.
|
|
61
|
+
|
|
62
|
+
### Create Note
|
|
63
|
+
`POST /api/v1/notes`
|
|
64
|
+
|
|
65
|
+
Create a new note record.
|
|
66
|
+
|
|
67
|
+
**Request Body:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"title": "Call Notes",
|
|
71
|
+
"content": "Key points from the call...",
|
|
72
|
+
"type": "call",
|
|
73
|
+
"contactId": "contact_456",
|
|
74
|
+
"isPinned": false,
|
|
75
|
+
"isPrivate": false
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Update Note
|
|
80
|
+
`PATCH /api/v1/notes/[id]`
|
|
81
|
+
|
|
82
|
+
Update an existing note. Supports partial updates.
|
|
83
|
+
|
|
84
|
+
### Delete Note
|
|
85
|
+
`DELETE /api/v1/notes/[id]`
|
|
86
|
+
|
|
87
|
+
Delete a note record.
|
|
88
|
+
|
|
89
|
+
## Fields
|
|
90
|
+
|
|
91
|
+
| Field | Type | Required | Description |
|
|
92
|
+
|-------|------|----------|-------------|
|
|
93
|
+
| title | text | No | Note title (optional) |
|
|
94
|
+
| content | textarea | Yes | Note content |
|
|
95
|
+
| type | select | No | Type: general, call, meeting, email, followup, feedback, reminder |
|
|
96
|
+
| isPinned | boolean | No | Is note pinned/important |
|
|
97
|
+
| isPrivate | boolean | No | Is note private to creator |
|
|
98
|
+
| entityType | select | No | Related entity type: lead, contact, company, opportunity, campaign |
|
|
99
|
+
| entityId | text | No | ID of related entity |
|
|
100
|
+
| contactId | relation | No | Related contact (→ contacts) |
|
|
101
|
+
| companyId | relation | No | Related company (→ companies) |
|
|
102
|
+
| opportunityId | relation | No | Related opportunity (→ opportunities) |
|
|
103
|
+
| attachments | json | No | Array of attachment objects |
|
|
104
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
105
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
106
|
+
|
|
107
|
+
## Relationships
|
|
108
|
+
|
|
109
|
+
| Relation | Entity | Description |
|
|
110
|
+
|----------|--------|-------------|
|
|
111
|
+
| contactId | contacts | Related contact |
|
|
112
|
+
| companyId | companies | Related company |
|
|
113
|
+
| opportunityId | opportunities | Related opportunity |
|
|
114
|
+
|
|
115
|
+
## Features
|
|
116
|
+
|
|
117
|
+
- **Searchable**: title, content
|
|
118
|
+
- **Sortable**: Most fields
|
|
119
|
+
- **Privacy**: Private notes only visible to creator
|
|
120
|
+
|
|
121
|
+
## Error Responses
|
|
122
|
+
|
|
123
|
+
| Status | Description |
|
|
124
|
+
|--------|-------------|
|
|
125
|
+
| 400 | Bad Request - Invalid parameters |
|
|
126
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
127
|
+
| 403 | Forbidden - Insufficient permissions |
|
|
128
|
+
| 404 | Not Found - Note doesn't exist |
|
|
129
|
+
| 422 | Validation Error - Invalid data |
|
|
130
|
+
|
|
131
|
+
## Related APIs
|
|
132
|
+
|
|
133
|
+
- **[Contacts](/api/v1/contacts)** - Related contact
|
|
134
|
+
- **[Companies](/api/v1/companies)** - Related company
|
|
135
|
+
- **[Opportunities](/api/v1/opportunities)** - Related opportunity
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Presets for Notes Entity
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
|
|
6
|
+
|
|
7
|
+
export default defineApiEndpoint({
|
|
8
|
+
summary: 'Manage notes linked to contacts, companies, and opportunities',
|
|
9
|
+
presets: [
|
|
10
|
+
{
|
|
11
|
+
id: 'list-all',
|
|
12
|
+
title: 'List All Notes',
|
|
13
|
+
description: 'Get all notes with pagination',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
params: {
|
|
16
|
+
limit: 20
|
|
17
|
+
},
|
|
18
|
+
tags: ['read', 'list']
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'list-pinned',
|
|
22
|
+
title: 'List Pinned Notes',
|
|
23
|
+
description: 'Get all pinned notes',
|
|
24
|
+
method: 'GET',
|
|
25
|
+
params: {
|
|
26
|
+
isPinned: 'true'
|
|
27
|
+
},
|
|
28
|
+
tags: ['read', 'filter']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'list-by-type',
|
|
32
|
+
title: 'List by Type',
|
|
33
|
+
description: 'Get notes of a specific type',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
params: {
|
|
36
|
+
type: '{{type}}'
|
|
37
|
+
},
|
|
38
|
+
tags: ['read', 'filter']
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'list-by-contact',
|
|
42
|
+
title: 'List by Contact',
|
|
43
|
+
description: 'Get notes for a specific contact',
|
|
44
|
+
method: 'GET',
|
|
45
|
+
params: {
|
|
46
|
+
contactId: '{{contactId}}'
|
|
47
|
+
},
|
|
48
|
+
tags: ['read', 'filter']
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'list-by-company',
|
|
52
|
+
title: 'List by Company',
|
|
53
|
+
description: 'Get notes for a specific company',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
params: {
|
|
56
|
+
companyId: '{{companyId}}'
|
|
57
|
+
},
|
|
58
|
+
tags: ['read', 'filter']
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'list-by-opportunity',
|
|
62
|
+
title: 'List by Opportunity',
|
|
63
|
+
description: 'Get notes for a specific opportunity',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
params: {
|
|
66
|
+
opportunityId: '{{opportunityId}}'
|
|
67
|
+
},
|
|
68
|
+
tags: ['read', 'filter']
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'search-notes',
|
|
72
|
+
title: 'Search Notes',
|
|
73
|
+
description: 'Search notes by content',
|
|
74
|
+
method: 'GET',
|
|
75
|
+
params: {
|
|
76
|
+
search: '{{searchTerm}}'
|
|
77
|
+
},
|
|
78
|
+
tags: ['read', 'search']
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'create-note',
|
|
82
|
+
title: 'Create Note',
|
|
83
|
+
description: 'Create a new note',
|
|
84
|
+
method: 'POST',
|
|
85
|
+
payload: {
|
|
86
|
+
content: 'Note content here...',
|
|
87
|
+
type: 'general'
|
|
88
|
+
},
|
|
89
|
+
tags: ['write', 'create']
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'pin-note',
|
|
93
|
+
title: 'Pin Note',
|
|
94
|
+
description: 'Pin a note',
|
|
95
|
+
method: 'PATCH',
|
|
96
|
+
pathParams: {
|
|
97
|
+
id: '{{id}}'
|
|
98
|
+
},
|
|
99
|
+
payload: {
|
|
100
|
+
isPinned: true
|
|
101
|
+
},
|
|
102
|
+
tags: ['write', 'update']
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'delete-note',
|
|
106
|
+
title: 'Delete Note',
|
|
107
|
+
description: 'Delete a note record',
|
|
108
|
+
method: 'DELETE',
|
|
109
|
+
pathParams: {
|
|
110
|
+
id: '{{id}}'
|
|
111
|
+
},
|
|
112
|
+
tags: ['write', 'delete']
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
})
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Opportunities API
|
|
2
|
+
|
|
3
|
+
Manage sales opportunities in the pipeline. Opportunities track deals from initial contact through close, with pipeline stages, amounts, and probabilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Opportunities API allows you to create, read, update, and delete opportunity records. Opportunities represent potential sales deals and are linked to companies, contacts, and pipelines.
|
|
8
|
+
|
|
9
|
+
## Authentication
|
|
10
|
+
|
|
11
|
+
All endpoints require authentication via:
|
|
12
|
+
- **Session cookie** (for browser-based requests)
|
|
13
|
+
- **API Key** header (for server-to-server requests)
|
|
14
|
+
|
|
15
|
+
## Endpoints
|
|
16
|
+
|
|
17
|
+
### List Opportunities
|
|
18
|
+
`GET /api/v1/opportunities`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of opportunities.
|
|
21
|
+
|
|
22
|
+
**Query Parameters:**
|
|
23
|
+
- `limit` (number, optional): Maximum records to return. Default: 20
|
|
24
|
+
- `offset` (number, optional): Number of records to skip. Default: 0
|
|
25
|
+
- `status` (string, optional): Filter by status (open, won, lost, abandoned)
|
|
26
|
+
- `companyId` (string, optional): Filter by company
|
|
27
|
+
- `pipelineId` (string, optional): Filter by pipeline
|
|
28
|
+
- `search` (string, optional): Search by name
|
|
29
|
+
- `sortBy` (string, optional): Field to sort by
|
|
30
|
+
- `sortOrder` (string, optional): Sort direction (asc, desc)
|
|
31
|
+
|
|
32
|
+
**Example Response:**
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"data": [
|
|
36
|
+
{
|
|
37
|
+
"id": "opp_abc123",
|
|
38
|
+
"name": "Enterprise License Deal",
|
|
39
|
+
"companyId": "company_xyz",
|
|
40
|
+
"contactId": "contact_456",
|
|
41
|
+
"pipelineId": "pipeline_001",
|
|
42
|
+
"stageId": "stage_negotiation",
|
|
43
|
+
"amount": 50000,
|
|
44
|
+
"currency": "USD",
|
|
45
|
+
"probability": 75,
|
|
46
|
+
"expectedRevenue": 37500,
|
|
47
|
+
"closeDate": "2024-03-15",
|
|
48
|
+
"status": "open",
|
|
49
|
+
"assignedTo": "user_789",
|
|
50
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"pagination": {
|
|
54
|
+
"total": 28,
|
|
55
|
+
"limit": 20,
|
|
56
|
+
"offset": 0
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Get Single Opportunity
|
|
62
|
+
`GET /api/v1/opportunities/[id]`
|
|
63
|
+
|
|
64
|
+
Returns a single opportunity by ID.
|
|
65
|
+
|
|
66
|
+
### Create Opportunity
|
|
67
|
+
`POST /api/v1/opportunities`
|
|
68
|
+
|
|
69
|
+
Create a new opportunity record.
|
|
70
|
+
|
|
71
|
+
**Request Body:**
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"name": "New Product Launch",
|
|
75
|
+
"companyId": "company_xyz",
|
|
76
|
+
"pipelineId": "pipeline_001",
|
|
77
|
+
"stageId": "stage_discovery",
|
|
78
|
+
"amount": 25000,
|
|
79
|
+
"currency": "USD",
|
|
80
|
+
"probability": 30,
|
|
81
|
+
"closeDate": "2024-06-30",
|
|
82
|
+
"type": "new_business"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Update Opportunity
|
|
87
|
+
`PATCH /api/v1/opportunities/[id]`
|
|
88
|
+
|
|
89
|
+
Update an existing opportunity. Supports partial updates.
|
|
90
|
+
|
|
91
|
+
### Delete Opportunity
|
|
92
|
+
`DELETE /api/v1/opportunities/[id]`
|
|
93
|
+
|
|
94
|
+
Delete an opportunity record.
|
|
95
|
+
|
|
96
|
+
## Fields
|
|
97
|
+
|
|
98
|
+
| Field | Type | Required | Description |
|
|
99
|
+
|-------|------|----------|-------------|
|
|
100
|
+
| name | text | Yes | Opportunity name or title |
|
|
101
|
+
| companyId | relation | Yes | Company (→ companies) |
|
|
102
|
+
| contactId | relation | No | Primary contact (→ contacts) |
|
|
103
|
+
| pipelineId | relation | Yes | Pipeline (→ pipelines) |
|
|
104
|
+
| stageId | text | Yes | Current stage in pipeline |
|
|
105
|
+
| amount | number | Yes | Deal amount value |
|
|
106
|
+
| currency | select | No | Currency: USD, EUR, GBP, MXN, etc. |
|
|
107
|
+
| probability | number | No | Win probability percentage (0-100) |
|
|
108
|
+
| expectedRevenue | number | Auto | Calculated: amount × probability |
|
|
109
|
+
| closeDate | date | Yes | Expected or actual close date |
|
|
110
|
+
| type | select | No | Type: new_business, existing_business, renewal, upgrade, downgrade |
|
|
111
|
+
| source | select | No | Source: web, referral, cold_call, etc. |
|
|
112
|
+
| competitor | text | No | Main competitor for this deal |
|
|
113
|
+
| status | select | No | Status: open, won, lost, abandoned |
|
|
114
|
+
| lostReason | text | No | Reason if opportunity was lost |
|
|
115
|
+
| assignedTo | user | No | Sales rep assigned |
|
|
116
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
117
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
118
|
+
|
|
119
|
+
## Relationships
|
|
120
|
+
|
|
121
|
+
| Relation | Entity | Description |
|
|
122
|
+
|----------|--------|-------------|
|
|
123
|
+
| companyId | companies | Company this opportunity is for |
|
|
124
|
+
| contactId | contacts | Primary contact for this deal |
|
|
125
|
+
| pipelineId | pipelines | Pipeline this opportunity is in |
|
|
126
|
+
|
|
127
|
+
## Features
|
|
128
|
+
|
|
129
|
+
- **Searchable**: name, competitor, lost reason
|
|
130
|
+
- **Sortable**: Most fields
|
|
131
|
+
- **Bulk Operations**: Supported
|
|
132
|
+
- **Import/Export**: Supported
|
|
133
|
+
- **Metadata**: Supported
|
|
134
|
+
|
|
135
|
+
## Error Responses
|
|
136
|
+
|
|
137
|
+
| Status | Description |
|
|
138
|
+
|--------|-------------|
|
|
139
|
+
| 400 | Bad Request - Invalid parameters |
|
|
140
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
141
|
+
| 403 | Forbidden - Insufficient permissions |
|
|
142
|
+
| 404 | Not Found - Opportunity doesn't exist |
|
|
143
|
+
| 422 | Validation Error - Invalid data |
|
|
144
|
+
|
|
145
|
+
## Related APIs
|
|
146
|
+
|
|
147
|
+
- **[Companies](/api/v1/companies)** - Associated company
|
|
148
|
+
- **[Contacts](/api/v1/contacts)** - Primary contact
|
|
149
|
+
- **[Pipelines](/api/v1/pipelines)** - Pipeline configuration
|
|
150
|
+
- **[Activities](/api/v1/activities)** - Related activities
|
|
151
|
+
- **[Notes](/api/v1/notes)** - Notes about this opportunity
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Presets for Opportunities Entity
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineApiEndpoint } from '@nextsparkjs/core/types/api-presets'
|
|
6
|
+
|
|
7
|
+
export default defineApiEndpoint({
|
|
8
|
+
summary: 'Manage sales opportunities with pipeline tracking',
|
|
9
|
+
presets: [
|
|
10
|
+
{
|
|
11
|
+
id: 'list-all',
|
|
12
|
+
title: 'List All Opportunities',
|
|
13
|
+
description: 'Get all opportunities with pagination',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
params: {
|
|
16
|
+
limit: 20
|
|
17
|
+
},
|
|
18
|
+
tags: ['read', 'list']
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'list-open',
|
|
22
|
+
title: 'List Open Opportunities',
|
|
23
|
+
description: 'Get all open opportunities',
|
|
24
|
+
method: 'GET',
|
|
25
|
+
params: {
|
|
26
|
+
status: 'open'
|
|
27
|
+
},
|
|
28
|
+
tags: ['read', 'filter']
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'list-won',
|
|
32
|
+
title: 'List Won Opportunities',
|
|
33
|
+
description: 'Get all won opportunities',
|
|
34
|
+
method: 'GET',
|
|
35
|
+
params: {
|
|
36
|
+
status: 'won'
|
|
37
|
+
},
|
|
38
|
+
tags: ['read', 'filter']
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'list-by-company',
|
|
42
|
+
title: 'List by Company',
|
|
43
|
+
description: 'Get opportunities for a specific company',
|
|
44
|
+
method: 'GET',
|
|
45
|
+
params: {
|
|
46
|
+
companyId: '{{companyId}}'
|
|
47
|
+
},
|
|
48
|
+
tags: ['read', 'filter']
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'list-by-pipeline',
|
|
52
|
+
title: 'List by Pipeline',
|
|
53
|
+
description: 'Get opportunities in a specific pipeline',
|
|
54
|
+
method: 'GET',
|
|
55
|
+
params: {
|
|
56
|
+
pipelineId: '{{pipelineId}}'
|
|
57
|
+
},
|
|
58
|
+
tags: ['read', 'filter']
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'list-closing-soon',
|
|
62
|
+
title: 'List Closing Soon',
|
|
63
|
+
description: 'Get opportunities sorted by close date',
|
|
64
|
+
method: 'GET',
|
|
65
|
+
params: {
|
|
66
|
+
status: 'open',
|
|
67
|
+
sortBy: 'closeDate',
|
|
68
|
+
sortOrder: 'asc'
|
|
69
|
+
},
|
|
70
|
+
tags: ['read', 'filter', 'priority']
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'list-high-value',
|
|
74
|
+
title: 'List High Value',
|
|
75
|
+
description: 'Get opportunities sorted by amount',
|
|
76
|
+
method: 'GET',
|
|
77
|
+
params: {
|
|
78
|
+
status: 'open',
|
|
79
|
+
sortBy: 'amount',
|
|
80
|
+
sortOrder: 'desc'
|
|
81
|
+
},
|
|
82
|
+
tags: ['read', 'filter', 'priority']
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'create-opportunity',
|
|
86
|
+
title: 'Create New Opportunity',
|
|
87
|
+
description: 'Create an opportunity with sample data',
|
|
88
|
+
method: 'POST',
|
|
89
|
+
payload: {
|
|
90
|
+
name: 'Sample Deal',
|
|
91
|
+
companyId: '{{companyId}}',
|
|
92
|
+
pipelineId: '{{pipelineId}}',
|
|
93
|
+
stageId: 'discovery',
|
|
94
|
+
amount: 10000,
|
|
95
|
+
currency: 'USD',
|
|
96
|
+
closeDate: '2024-12-31'
|
|
97
|
+
},
|
|
98
|
+
tags: ['write', 'create']
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'update-stage',
|
|
102
|
+
title: 'Update Stage',
|
|
103
|
+
description: 'Move opportunity to a new stage',
|
|
104
|
+
method: 'PATCH',
|
|
105
|
+
pathParams: {
|
|
106
|
+
id: '{{id}}'
|
|
107
|
+
},
|
|
108
|
+
payload: {
|
|
109
|
+
stageId: '{{newStageId}}'
|
|
110
|
+
},
|
|
111
|
+
tags: ['write', 'update']
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 'mark-won',
|
|
115
|
+
title: 'Mark as Won',
|
|
116
|
+
description: 'Mark opportunity as won',
|
|
117
|
+
method: 'PATCH',
|
|
118
|
+
pathParams: {
|
|
119
|
+
id: '{{id}}'
|
|
120
|
+
},
|
|
121
|
+
payload: {
|
|
122
|
+
status: 'won'
|
|
123
|
+
},
|
|
124
|
+
tags: ['write', 'update']
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: 'mark-lost',
|
|
128
|
+
title: 'Mark as Lost',
|
|
129
|
+
description: 'Mark opportunity as lost with reason',
|
|
130
|
+
method: 'PATCH',
|
|
131
|
+
pathParams: {
|
|
132
|
+
id: '{{id}}'
|
|
133
|
+
},
|
|
134
|
+
payload: {
|
|
135
|
+
status: 'lost',
|
|
136
|
+
lostReason: '{{reason}}'
|
|
137
|
+
},
|
|
138
|
+
tags: ['write', 'update']
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'delete-opportunity',
|
|
142
|
+
title: 'Delete Opportunity',
|
|
143
|
+
description: 'Delete an opportunity record',
|
|
144
|
+
method: 'DELETE',
|
|
145
|
+
pathParams: {
|
|
146
|
+
id: '{{id}}'
|
|
147
|
+
},
|
|
148
|
+
tags: ['write', 'delete']
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
})
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Pipelines API
|
|
2
|
+
|
|
3
|
+
Manage sales pipelines with customizable stages. Pipelines define the workflow for tracking opportunities from initial contact to close.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Pipelines API allows you to create, read, update, and delete pipeline configurations. Pipelines contain stages that define the sales process and are used by opportunities to track progress.
|
|
8
|
+
|
|
9
|
+
## Authentication
|
|
10
|
+
|
|
11
|
+
All endpoints require authentication via:
|
|
12
|
+
- **Session cookie** (for browser-based requests)
|
|
13
|
+
- **API Key** header (for server-to-server requests)
|
|
14
|
+
|
|
15
|
+
## Endpoints
|
|
16
|
+
|
|
17
|
+
### List Pipelines
|
|
18
|
+
`GET /api/v1/pipelines`
|
|
19
|
+
|
|
20
|
+
Returns a paginated list of pipelines.
|
|
21
|
+
|
|
22
|
+
**Query Parameters:**
|
|
23
|
+
- `limit` (number, optional): Maximum records to return. Default: 20
|
|
24
|
+
- `offset` (number, optional): Number of records to skip. Default: 0
|
|
25
|
+
- `type` (string, optional): Filter by type (sales, support, project, custom)
|
|
26
|
+
- `isActive` (boolean, optional): Filter by active status
|
|
27
|
+
- `sortBy` (string, optional): Field to sort by
|
|
28
|
+
- `sortOrder` (string, optional): Sort direction (asc, desc)
|
|
29
|
+
|
|
30
|
+
**Example Response:**
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"data": [
|
|
34
|
+
{
|
|
35
|
+
"id": "pipeline_abc123",
|
|
36
|
+
"name": "Sales Pipeline",
|
|
37
|
+
"description": "Main sales process",
|
|
38
|
+
"type": "sales",
|
|
39
|
+
"isDefault": true,
|
|
40
|
+
"isActive": true,
|
|
41
|
+
"stages": [
|
|
42
|
+
{"id": "discovery", "name": "Discovery", "probability": 10, "order": 1},
|
|
43
|
+
{"id": "proposal", "name": "Proposal", "probability": 30, "order": 2},
|
|
44
|
+
{"id": "negotiation", "name": "Negotiation", "probability": 60, "order": 3},
|
|
45
|
+
{"id": "closed", "name": "Closed Won", "probability": 100, "order": 4}
|
|
46
|
+
],
|
|
47
|
+
"dealRottenDays": 30,
|
|
48
|
+
"createdAt": "2024-01-15T10:30:00Z"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"pagination": {
|
|
52
|
+
"total": 3,
|
|
53
|
+
"limit": 20,
|
|
54
|
+
"offset": 0
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Get Single Pipeline
|
|
60
|
+
`GET /api/v1/pipelines/[id]`
|
|
61
|
+
|
|
62
|
+
Returns a single pipeline by ID.
|
|
63
|
+
|
|
64
|
+
### Create Pipeline
|
|
65
|
+
`POST /api/v1/pipelines`
|
|
66
|
+
|
|
67
|
+
Create a new pipeline configuration.
|
|
68
|
+
|
|
69
|
+
**Request Body:**
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"name": "New Sales Pipeline",
|
|
73
|
+
"description": "Custom sales process",
|
|
74
|
+
"type": "sales",
|
|
75
|
+
"isActive": true,
|
|
76
|
+
"stages": [
|
|
77
|
+
{"id": "lead", "name": "Lead", "probability": 5, "order": 1},
|
|
78
|
+
{"id": "qualified", "name": "Qualified", "probability": 25, "order": 2},
|
|
79
|
+
{"id": "demo", "name": "Demo", "probability": 50, "order": 3},
|
|
80
|
+
{"id": "proposal", "name": "Proposal", "probability": 75, "order": 4},
|
|
81
|
+
{"id": "won", "name": "Won", "probability": 100, "order": 5}
|
|
82
|
+
],
|
|
83
|
+
"dealRottenDays": 14
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Update Pipeline
|
|
88
|
+
`PATCH /api/v1/pipelines/[id]`
|
|
89
|
+
|
|
90
|
+
Update an existing pipeline. Supports partial updates.
|
|
91
|
+
|
|
92
|
+
### Delete Pipeline
|
|
93
|
+
`DELETE /api/v1/pipelines/[id]`
|
|
94
|
+
|
|
95
|
+
Delete a pipeline configuration. Note: Cannot delete pipelines with active opportunities.
|
|
96
|
+
|
|
97
|
+
## Fields
|
|
98
|
+
|
|
99
|
+
| Field | Type | Required | Description |
|
|
100
|
+
|-------|------|----------|-------------|
|
|
101
|
+
| name | text | Yes | Pipeline name |
|
|
102
|
+
| description | textarea | No | Pipeline description |
|
|
103
|
+
| type | select | No | Type: sales, support, project, custom |
|
|
104
|
+
| isDefault | boolean | No | Is this the default pipeline |
|
|
105
|
+
| isActive | boolean | No | Is pipeline currently active |
|
|
106
|
+
| stages | json | Yes | Array of stage objects |
|
|
107
|
+
| dealRottenDays | number | No | Days until deal is considered stale |
|
|
108
|
+
| createdAt | datetime | Auto | Creation timestamp |
|
|
109
|
+
| updatedAt | datetime | Auto | Last update timestamp |
|
|
110
|
+
|
|
111
|
+
## Stage Object Structure
|
|
112
|
+
|
|
113
|
+
Each stage in the `stages` array should have:
|
|
114
|
+
|
|
115
|
+
| Property | Type | Description |
|
|
116
|
+
|----------|------|-------------|
|
|
117
|
+
| id | string | Unique stage identifier |
|
|
118
|
+
| name | string | Display name |
|
|
119
|
+
| probability | number | Win probability percentage |
|
|
120
|
+
| order | number | Sort order |
|
|
121
|
+
| color | string | Optional hex color for UI |
|
|
122
|
+
|
|
123
|
+
## Features
|
|
124
|
+
|
|
125
|
+
- **Searchable**: name, description
|
|
126
|
+
- **Sortable**: name, type, isDefault, isActive
|
|
127
|
+
|
|
128
|
+
## Permissions
|
|
129
|
+
|
|
130
|
+
- **Create/Update/Delete**: Owner only
|
|
131
|
+
|
|
132
|
+
## Error Responses
|
|
133
|
+
|
|
134
|
+
| Status | Description |
|
|
135
|
+
|--------|-------------|
|
|
136
|
+
| 400 | Bad Request - Invalid parameters |
|
|
137
|
+
| 401 | Unauthorized - Missing or invalid auth |
|
|
138
|
+
| 403 | Forbidden - Insufficient permissions (owner only) |
|
|
139
|
+
| 404 | Not Found - Pipeline doesn't exist |
|
|
140
|
+
| 409 | Conflict - Cannot delete pipeline with active opportunities |
|
|
141
|
+
| 422 | Validation Error - Invalid data |
|
|
142
|
+
|
|
143
|
+
## Related APIs
|
|
144
|
+
|
|
145
|
+
- **[Opportunities](/api/v1/opportunities)** - Deals using this pipeline
|