# POST /api/v1/o2c/deals

> Create a deal

- **Tag:** deals
- **Operation ID:** `create_deal_api_v1_o2c_deals_post`

## Description

Create a pipeline deal. Provide either `prospect_name` (before a real customer record exists) or `customer_id` (an expansion deal on an existing customer). `stage` defaults to `prospecting`.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `DealCreate`

- `prospect_name` (string) — Free-text prospect/company name, used before a real customer record exists. Required unless customer_id is set.
- `customer_id` (string) — Existing customer this deal is for (expansion deal). Required unless prospect_name is set.
- `name` (string) — Deal name. Defaults to the prospect/customer name.
- `contact_name` (string) — Sales contact.
- `contact_email` (string) — Sales contact email. Never written to the customer record -- may later become the order signer.
- `source` (string) — One of ['event', 'expansion', 'inbound', 'other', 'outbound', 'partner', 'referral'].
- `stage` (string) — One of ['closed_lost', 'closed_won', 'negotiation', 'proposal', 'prospecting', 'qualified']. Defaults to 'prospecting'.
- `is_expansion` (boolean) — True if this is expansion revenue on an existing customer.
- `expected_value_cents` (integer) — Estimated deal value in cents.
- `expected_hours` (number | string) — Estimated hours.
- `expected_term_months` (integer) — Estimated contract term in months.
- `expected_start_date` (string · date) — Estimated start date.
- `expected_close_date` (string · date) — Estimated close date.
- `notes` (string) — Free-text notes.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_DealResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (DealResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/o2c/deals' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "prospect_name": "string",
  "customer_id": "string",
  "name": "string",
  "contact_name": "string",
  "contact_email": "string",
  "source": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/o2c/deals', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "prospect_name": "string",
  "customer_id": "string",
  "name": "string",
  "contact_name": "string",
  "contact_email": "string",
  "source": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "prospect_name": "string",
  "customer_id": "string",
  "name": "string",
  "contact_name": "string",
  "contact_email": "string",
  "source": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/o2c/deals", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/deals/create-deal
- OpenAPI slice: https://www.ondayzero.com/docs/reference/deals/create-deal/openapi.json
- Other endpoints in **deals**: https://www.ondayzero.com/docs/reference/deals
