SetStage

[POST] .../v1/deal/setstage

Changes the stage of a CRM deal. Use this workflow method to move an open deal to another stage in the same pipeline, including terminal won or lost stages when the deal should be closed. The method validates the deal, target stage and pipeline access, updates stage/status/close_date, records stage history and chat system messages, synchronizes the linked chat closed state, writes an action log record, sends DealStageSet and, for terminal stages, DealClosed webhooks and notification cancellation, then returns row_affected with the deal id. The request body is required; id and stage_id must be positive and stage_id must belong to the deal pipeline. A terminal success stage sets status Won, a terminal non-success stage sets status Lost and a non-terminal stage keeps the deal Open. The caller must have CRM deal edit permission or CRM manage-all access; missing body, invalid ids, missing deal or stage, denied pipeline access, database errors, transaction failures and action-log errors are returned as HTTP 200 ErrorResult business errors.

Request Parameters

Name Type Required Description
comment String Optional Comment for the stage change.
id Int64 Required Deal ID.
stage_id Int64 Required New stage ID.

Request Example

{
  "id": 230,
  "stage_id": 34,
  "comment": "Proposal sent"
}

Response Parameters

Name Type Description
ok Boolean Indicates whether the request completed successfully.
result Update Update operation result.

Response Example

{
  "ok": true,
  "result": {
    "row_affected": 1,
    "ids": [
      230
    ]
  }
}