Skip to main content

Overview

The Deals API provides endpoints for managing deals, tracking pipeline stages, and forecasting revenue. Base Path: /api/deals

Endpoints

List Deals

GET /api/deals
Query Parameters:
ParameterTypeDescription
pageintegerPage number
page_sizeintegerItems per page
company_idUUIDFilter by company
stagestringFilter by pipeline stage
owner_idUUIDFilter by deal owner
value_minnumberMinimum deal value
value_maxnumberMaximum deal value
Example:
curl -H "Authorization: Bearer TOKEN" \
  "http://localhost:8000/api/deals?stage=pipeline&value_min=100000"
Response:
{
  "data": [
    {
      "id": "hh0e8400-e29b-41d4-a716-446655442222",
      "name": "Enterprise Deal - Acme Corp",
      "company_id": "550e8400-e29b-41d4-a716-446655440000",
      "company_name": "Acme Corp",
      "value": 250000,
      "stage": "pipeline",
      "probability": 75,
      "owner_id": "user-uuid",
      "owner_name": "John Doe",
      "close_date": "2024-03-15",
      "created_at": "2024-01-10T09:00:00Z",
      "updated_at": "2024-01-20T14:30:00Z"
    }
  ],
  "total": 42,
  "total_value": 8500000
}

Create Deal

POST /api/deals
Request Body:
{
  "name": "Strategic Partnership",
  "company_id": "550e8400-e29b-41d4-a716-446655440000",
  "value": 150000,
  "stage": "qualification",
  "probability": 50,
  "close_date": "2024-04-30",
  "description": "Partnership opportunity for platform integration"
}
Response (201 Created):
{
  "id": "ii0e8400-e29b-41d4-a716-446655443333",
  "name": "Strategic Partnership",
  "company_id": "550e8400-e29b-41d4-a716-446655440000",
  "value": 150000,
  "stage": "qualification",
  "probability": 50,
  "close_date": "2024-04-30",
  "created_at": "2024-01-22T12:00:00Z"
}

Pipeline Stages

StageDescriptionTypical Probability
leadInitial lead10-20%
qualificationQualified opportunity25-40%
proposalProposal submitted50-60%
negotiationIn negotiation70-80%
closed_wonDeal won100%
closed_lostDeal lost0%

Deal Object

FieldTypeDescription
idUUIDUnique identifier
namestringDeal name
company_idUUIDAssociated company
valuenumberDeal value in USD
stageenumPipeline stage
probabilityintegerWin probability (0-100)
owner_idUUIDDeal owner
close_datedateExpected close date
descriptiontextDeal description
created_attimestampCreation timestamp
updated_attimestampLast update

Examples

TypeScript

// Get pipeline deals
const deals = await fetch('http://localhost:8000/api/deals?stage=pipeline', {
  headers: { 'Authorization': `Bearer ${token}` }
}).then(r => r.json())

// Create deal
const newDeal = await fetch('http://localhost:8000/api/deals', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Enterprise Deal',
    company_id: companyId,
    value: 200000,
    stage: 'qualification'
  })
}).then(r => r.json())

Next Steps