Update an entity's opportunity stages
Operation ID: updateOpportunityStages
Group: CRM › Opportunity Stages
Open in the interactive reference
PATCH /crm/opportunity-stages/{id}
Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.
Updates a legal entity's opportunity stages in one all-or-nothing request. The :id in the path is the legal entity's id. createStages adds stages, updateStages changes stages by id, and deleteStages removes stages by id. The rules apply to the stages as they will be afterward: there must be an active stage of each type, 'open', 'closedWon' and 'closedLost' (INCOMPLETE_STAGES), and no two stages may share an orderIndex (DUPLICATE_ORDER_INDEX). Stages are ordered by orderIndex, and the stored positions are rewritten to 0, 1, 2 … after every call, so sending back the values you read changes nothing. To reorder, send the new orderIndex of every stage that moves in the same call. For example, to swap the stages at 1 and 2, send updateStages [{ id: A, orderIndex: 2 }, { id: B, orderIndex: 1 }]. A stage that has opportunities cannot be deleted or deactivated (STAGE_IN_USE).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Api-Version |
header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1. |
Idempotency-Key |
header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored. |
id |
path | string | yes | The legal entity whose stages to change. See id on GET base/entities. Example: "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3". |
Request body
Required, application/json: updateOpportunityStagesInput.
| Field | Type | Required | Description |
|---|---|---|---|
createStages |
array<object> | no | New stages to add. Omit for none. Example: [{"stageName":"Proposal","stageType":"open","probability":"50","orderIndex":2}]. |
createStages[].stageName |
string | yes | The display name of the stage. Must not be empty. |
createStages[].stageType |
any | yes | What reaching the stage means for an opportunity. One of: "open", "closedWon", "closedLost". |
createStages[].probability |
decimal | yes | The likelihood that an opportunity in this stage closes as won, as a percentage from 0 to 100. For example, 25 means 25%. |
createStages[].orderIndex |
number | no | Where the stage goes: the stages are ordered by this value, which must be unique among the resulting stages. Omit to place the stage after every other stage. |
createStages[].isDeactivated |
boolean | no | Whether the stage starts out retired. Defaults to false. |
updateStages |
array<object> | no | Changes to existing stages, each keyed by the stage's id. Omit for none. Example: [{"id":"5b0e7c3a-2f6d-4a8b-9c1e-7d4f3a2b1c09","orderIndex":3},{"id":"0e3a9f41-6c2b-4d7e-8a15-2b9c7d4e6f10","stageName":"Contract Sent"}]. |
updateStages[].id |
string | yes | The unique identifier for the stage to change. It must belong to this entity. |
updateStages[].stageName |
string | no | The new display name. Must not be empty. Omit to leave unchanged. |
updateStages[].stageType |
any | no | The new stage type. Omit to leave unchanged. One of: "open", "closedWon", "closedLost". |
updateStages[].probability |
decimal | no | The new probability, as a percentage from 0 to 100. Omit to leave unchanged. |
updateStages[].orderIndex |
number | no | Where the stage goes: the stages are ordered by this value, which must be unique among the resulting stages. Omit to leave unchanged. |
updateStages[].isDeactivated |
boolean | no | Whether the stage is retired. A stage that has opportunities cannot be deactivated. Omit to leave unchanged. |
deleteStages |
array<string> | no | The ids of the stages to delete. A stage that has opportunities cannot be deleted. Omit for none. Example: ["7d1c2b3a-9e8f-4a6b-b5c4-3d2e1f0a9b87"]. |
{
"createStages": [
{
"stageName": "Proposal",
"stageType": "open",
"probability": "50",
"orderIndex": 2
}
],
"updateStages": [
{
"id": "5b0e7c3a-2f6d-4a8b-9c1e-7d4f3a2b1c09",
"orderIndex": 3
},
{
"id": "0e3a9f41-6c2b-4d7e-8a15-2b9c7d4e6f10",
"stageName": "Contract Sent"
}
],
"deleteStages": [
"7d1c2b3a-9e8f-4a6b-b5c4-3d2e1f0a9b87"
]
}
Response
200 Success
{
"data": {},
"diagnostics": [
{
"code": "<code>",
"message": "<message>",
"severity": "error",
"path": [
"<path>"
],
"details": "<details>"
}
]
}
Response headers
Idempotency-Replayed— Present andtrueonly when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent asfalse.
Errors
| Code | Status |
|---|---|
NOT_FOUND |
400 |
STAGES_MANAGED_BY_INTEGRATION |
400 |
UNKNOWN_STAGE |
400 |
CONFLICTING_STAGE_OPERATIONS |
400 |
INVALID_STAGE_NAME |
400 |
INVALID_PROBABILITY |
400 |
DUPLICATE_ORDER_INDEX |
400 |
STAGE_IN_USE |
400 |
INCOMPLETE_STAGES |
400 |
IDEMPOTENCY_KEY_CONFLICT |
409 |
IDEMPOTENCY_PAYLOAD_MISMATCH |
422 |
Statuses
400— Invalid request or business failure. Codes: NOT_FOUND, STAGES_MANAGED_BY_INTEGRATION, UNKNOWN_STAGE, CONFLICTING_STAGE_OPERATIONS, INVALID_STAGE_NAME, INVALID_PROBABILITY, DUPLICATE_ORDER_INDEX, STAGE_IN_USE, INCOMPLETE_STAGES401— The request carries no valid access token.403— Not authorized404— Not found409— The Idempotency-Key is still being processed by another request.422— The Idempotency-Key was already used with a different request payload.429— Too many requests from this client address. The response has no body and noRetry-Afterheader.500— Internal server error