Deals API

Manage deals — sales opportunities with a value, status, and position in a pipeline.

See also: Deals & Pipelines concepts

Endpoints

MethodPathDescription
POST/dealsCreate a deal
GET/dealsList deals
GET/deals/:idGet a deal
PATCH/deals/:idUpdate a deal
DELETE/deals/:idDelete a deal
POST/deals/:id/stageMove a deal to a new stage
GET/deals/:id/historyGet stage change history
GET/deals/:id/activitiesList activities for a deal
GET/deals/:id/tasksList tasks for a deal

Create a deal

POST /deals

Request body

FieldTypeRequiredDescription
namestringyesDeal name
pipeline_idstringyesPipeline this deal belongs to
stage_idstringyesInitial stage within the pipeline
contact_idstringnoPrimary contact
company_idstringnoAssociated company
valueintegernoDeal value in cents (default 0)
currencystringnoISO 4217 currency code (default USD)
statusstringnoStatus: open, won, lost, stalled
expected_closedatetimenoExpected close date
owner_idstringnoAssigned team member
sourcestringnoHow the deal originated
metadataobjectnoArbitrary key-value data

Example

curl -X POST "$REX_URL/deals" \
  -H "X-Api-Key: $REX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Enterprise Plan",
    "pipeline_id": "pipe_01HQ...",
    "stage_id": "stg_01HQ...",
    "contact_id": "cont_01HQ...",
    "value": 500000,
    "currency": "USD"
  }'

Response

{
  "data": {
    "id": "deal_01HQ...",
    "name": "Acme Enterprise Plan",
    "pipeline_id": "pipe_01HQ...",
    "stage_id": "stg_01HQ...",
    "contact_id": "cont_01HQ...",
    "value": 500000,
    "currency": "USD",
    "status": "open",
    "days_in_stage": 0,
    "deal_age_days": 0,
    "created_at": "2026-03-16T12:00:00Z",
    "updated_at": "2026-03-16T12:00:00Z"
  }
}

List deals

GET /deals

Query parameters

ParameterTypeDescription
cursorstringPagination cursor
limitintegerResults per page (default 50, max 200)
statusstringFilter by status: open, won, lost, stalled
pipeline_idstringFilter by pipeline
stage_idstringFilter by stage
contact_idstringFilter by contact
company_idstringFilter by company
owner_idstringFilter by owner
min_valueintegerMinimum deal value in cents
max_valueintegerMaximum deal value in cents
days_since_activity_gtintegerDeals with no activity for more than N days
created_afterdatetimeCreated after this time
created_beforedatetimeCreated before this time

Example

curl "$REX_URL/deals?status=open&pipeline_id=pipe_01HQ...&limit=25" \
  -H "X-Api-Key: $REX_API_KEY"

Response

{
  "data": [
    {
      "id": "deal_01HQ...",
      "name": "Acme Enterprise Plan",
      "pipeline_id": "pipe_01HQ...",
      "stage_id": "stg_01HQ...",
      "value": 500000,
      "currency": "USD",
      "status": "open",
      "days_in_stage": 3,
      "deal_age_days": 12,
      "created_at": "2026-03-04T12:00:00Z",
      "updated_at": "2026-03-16T12:00:00Z"
    }
  ],
  "has_more": false
}

Get a deal

GET /deals/:id

Example

curl "$REX_URL/deals/deal_01HQ..." \
  -H "X-Api-Key: $REX_API_KEY"

Response

{
  "data": {
    "id": "deal_01HQ...",
    "name": "Acme Enterprise Plan",
    "pipeline_id": "pipe_01HQ...",
    "stage_id": "stg_01HQ...",
    "contact_id": "cont_01HQ...",
    "company_id": "comp_01HQ...",
    "value": 500000,
    "currency": "USD",
    "status": "open",
    "expected_close": "2026-04-01T00:00:00Z",
    "owner_id": "user_01HQ...",
    "source": "inbound",
    "stage_entered_at": "2026-03-13T09:00:00Z",
    "last_activity_at": "2026-03-15T14:30:00Z",
    "days_in_stage": 3,
    "deal_age_days": 12,
    "metadata": {},
    "relationships": {
      "contact": { "type": "contact", "id": "cont_01HQ...", "name": "Ada Lovelace" },
      "company": { "type": "company", "id": "comp_01HQ...", "name": "Acme Corp" },
      "pipeline": { "type": "pipeline", "id": "pipe_01HQ...", "name": "Sales" },
      "stage": { "type": "stage", "id": "stg_01HQ...", "name": "Proposal Sent" }
    },
    "created_at": "2026-03-04T12:00:00Z",
    "updated_at": "2026-03-16T12:00:00Z"
  },
  "included": [
    { "type": "contact", "id": "cont_01HQ...", "name": "Ada Lovelace" },
    { "type": "company", "id": "comp_01HQ...", "name": "Acme Corp" }
  ]
}

Update a deal

PATCH /deals/:id

All fields from the create request body are accepted, plus loss_reason. Only provided fields are updated.

Example

curl -X PATCH "$REX_URL/deals/deal_01HQ..." \
  -H "X-Api-Key: $REX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": 750000,
    "expected_close": "2026-04-15T00:00:00Z"
  }'

Response

Returns the full updated deal in the same format as Get a deal.

Delete a deal

DELETE /deals/:id

Example

curl -X DELETE "$REX_URL/deals/deal_01HQ..." \
  -H "X-Api-Key: $REX_API_KEY"

Response

204 No Content on success.

Move a deal to a new stage

POST /deals/:id/stage

Moves the deal to a new pipeline stage and creates a stage history record.

Request body

FieldTypeRequiredDescription
stage_idstringyesTarget stage ID

Example

curl -X POST "$REX_URL/deals/deal_01HQ.../stage" \
  -H "X-Api-Key: $REX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stage_id": "stg_01HQ..."
  }'

Response

Returns the updated deal in the same format as Get a deal.

Get stage change history

GET /deals/:id/history

Returns a chronological list of stage transitions for this deal. Supports cursor and limit query parameters.

Example

curl "$REX_URL/deals/deal_01HQ.../history" \
  -H "X-Api-Key: $REX_API_KEY"

Response

{
  "data": [
    {
      "id": "sh_01HQ...",
      "deal_id": "deal_01HQ...",
      "from_stage_id": null,
      "to_stage_id": "stg_01HQ...",
      "changed_at": "2026-03-04T12:00:00Z",
      "changed_by": "user_01HQ..."
    },
    {
      "id": "sh_01HQ...",
      "deal_id": "deal_01HQ...",
      "from_stage_id": "stg_01HQ...",
      "to_stage_id": "stg_02HQ...",
      "changed_at": "2026-03-10T09:00:00Z",
      "changed_by": "user_01HQ..."
    }
  ],
  "has_more": false
}

List activities for a deal

GET /deals/:id/activities

Returns activities linked to this deal. Supports cursor and limit query parameters.

Example

curl "$REX_URL/deals/deal_01HQ.../activities" \
  -H "X-Api-Key: $REX_API_KEY"

Response

{
  "data": [
    {
      "id": "act_01HQ...",
      "type": "meeting",
      "status": "completed",
      "subject": "Demo call",
      "occurred_at": "2026-03-15T14:30:00Z",
      "created_at": "2026-03-15T14:30:00Z",
      "updated_at": "2026-03-15T14:30:00Z"
    }
  ],
  "has_more": false
}

List tasks for a deal

GET /deals/:id/tasks

Returns tasks linked to this deal. Supports cursor and limit query parameters.

Example

curl "$REX_URL/deals/deal_01HQ.../tasks" \
  -H "X-Api-Key: $REX_API_KEY"

Response

{
  "data": [
    {
      "id": "task_01HQ...",
      "title": "Send revised proposal",
      "priority": "high",
      "status": "pending",
      "due_at": "2026-03-20T17:00:00Z",
      "created_at": "2026-03-16T12:00:00Z",
      "updated_at": "2026-03-16T12:00:00Z"
    }
  ],
  "has_more": false
}

Was this page helpful?

·