Create an entity's opportunity stages
Operation ID: createOpportunityStages
Group: CRM › Opportunity Stages
Open in the interactive reference
POST /crm/opportunity-stages
Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.
Creates the first opportunity stages of a legal entity that has none yet, in one request. The stages must include at least one active stage of each type, 'open', 'closedWon' and 'closedLost', or the call fails with INCOMPLETE_STAGES. Stages are ordered by orderIndex; a stage without one goes after every stage that has one, in the order you sent them. To change an entity's existing stages, use PATCH crm/opportunity-stages/:id. The response contains only the id.
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. |
Request body
Required, application/json: createOpportunityStagesInput.
| Field | Type | Required | Description |
|---|---|---|---|
entityId |
string | yes | The legal entity to create the stages for. It must be active and must not have stages yet. See id on GET base/entities. Example: "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3". |
stages |
array<object> | yes | The stages to create. Example: [{"stageName":"Qualification","stageType":"open","probability":"20"},{"stageName":"Negotiation","stageType":"open","probability":"60"},{"stageName":"Closed Won","stageType":"closedWon","probability":"100"},{"stageName":"Closed Lost","stageType":"closedLost","probability":"0"}]. |
stages[].stageName |
string | yes | The display name of the stage. Must not be empty. |
stages[].stageType |
any | yes | What reaching the stage means for an opportunity. One of: "open", "closedWon", "closedLost". |
stages[].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%. |
stages[].orderIndex |
number | no | Where the stage goes: the stages are ordered by this value, which must be unique among them. The stored positions are 0, 1, 2 … with no gaps. Omit to place the stage after every stage that has one. |
stages[].isDeactivated |
boolean | no | Whether the stage starts out retired. Defaults to false. |
{
"entityId": "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3",
"stages": [
{
"stageName": "Qualification",
"stageType": "open",
"probability": "20"
},
{
"stageName": "Negotiation",
"stageType": "open",
"probability": "60"
},
{
"stageName": "Closed Won",
"stageType": "closedWon",
"probability": "100"
},
{
"stageName": "Closed Lost",
"stageType": "closedLost",
"probability": "0"
}
]
}
Response
200 Success
Under data (createOpportunityStagesOutput):
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | yes | The identifier of the created set of stages, which is the entity's id. The other opportunity stages endpoints are keyed by it. Example: "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3". |
{
"data": {
"id": "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3"
},
"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 |
|---|---|
ENTITY_NOT_FOUND |
400 |
STAGES_ALREADY_EXIST |
400 |
STAGES_MANAGED_BY_INTEGRATION |
400 |
INVALID_STAGE_NAME |
400 |
INVALID_PROBABILITY |
400 |
DUPLICATE_ORDER_INDEX |
400 |
INCOMPLETE_STAGES |
400 |
IDEMPOTENCY_KEY_CONFLICT |
409 |
IDEMPOTENCY_PAYLOAD_MISMATCH |
422 |
Statuses
400— Invalid request or business failure. Codes: ENTITY_NOT_FOUND, STAGES_ALREADY_EXIST, STAGES_MANAGED_BY_INTEGRATION, INVALID_STAGE_NAME, INVALID_PROBABILITY, DUPLICATE_ORDER_INDEX, 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