Create an opportunity

Operation ID: createOpportunity

Group: CRM › Opportunities

Open in the interactive reference

POST /crm/opportunities

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates an opportunity for a customer or a prospect of a legal entity. customerId may name either; which one it is follows from the id. The customer must belong to entityId, and a partner customer also needs an endCustomerId, one of that partner's end customers. Without a stageId the opportunity starts in the entity's first stage; a stageId must be an open stage (STAGE_CLOSED).An entity whose opportunities are kept in sync by a CRM integration accepts no creates here (OPPORTUNITIES_MANAGED_BY_INTEGRATION). The response contains only the id; read the stored opportunity, including its opportunityNumber, with GET crm/opportunities/: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: createOpportunityInput.

Field Type Required Description
entityId string yes The legal entity that owns the opportunity. It must be active. See id on GET base/entities. Example: "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3".
customerId string yes The customer or prospect the opportunity is for. It must belong to entityId. See id on GET accounting/customers/:id or GET crm/prospects/:id. Example: "0e3a9f41-6c2b-4d7e-8a15-2b9c7d4e6f10".
endCustomerId string no The end customer behind a partner customer: required when customerId is a partner, not allowed otherwise. See id on GET accounting/customers/:id.
currency string yes The currency the opportunity is denominated in, and the currency of amount. Format ISO 4217, for example 'USD'. Example: "USD".
priceBookId string yes The price book quotes on this opportunity are priced from. See id on GET accounting/price-books/:id. Example: "5b0e7c3a-2f6d-4a8b-9c1e-7d4f3a2b1c09".
stageId string no The stage the opportunity starts in: an active stage on GET crm/opportunity-stages/:id, where :id is entityId. Omit to start in the entity's first stage.
opportunityName string yes The display name of the opportunity. Must not be empty. Example: "Acme renewal 2027".
closeDate date no The expected close date of the deal. Format YYYY-MM-DD. Example: "2027-03-31".
amount decimal no The expected deal amount, as a decimal in currency. Example: "125000.00".
crmId string no The identifier of this opportunity in an external system, for example a Salesforce record id. Free text.
{
  "entityId": "ebbe16c9-2c44-4a8e-a813-6ed5a78ffab3",
  "customerId": "0e3a9f41-6c2b-4d7e-8a15-2b9c7d4e6f10",
  "endCustomerId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "currency": "USD",
  "priceBookId": "5b0e7c3a-2f6d-4a8b-9c1e-7d4f3a2b1c09",
  "stageId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "opportunityName": "Acme renewal 2027",
  "closeDate": "2027-03-31",
  "amount": "125000.00",
  "crmId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}

Response

200 Success

Under data (createOpportunityOutput):

Field Type Required Description
id string yes The identifier of the created opportunity. Example: "7d1c2b3a-9e8f-4a6b-b5c4-3d2e1f0a9b87".
{
  "data": {
    "id": "7d1c2b3a-9e8f-4a6b-b5c4-3d2e1f0a9b87"
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

Errors

Code Status
ENTITY_NOT_FOUND 400
OPPORTUNITIES_MANAGED_BY_INTEGRATION 400
INVALID_OPPORTUNITY_NAME 400
CUSTOMER_NOT_FOUND 400
CUSTOMER_NOT_IN_ENTITY 400
END_CUSTOMER_REQUIRED 400
INVALID_END_CUSTOMER 400
INVALID_CURRENCY 400
PRICE_BOOK_NOT_FOUND 400
STAGE_NOT_FOUND 400
STAGE_CLOSED 400
ENTITY_HAS_NO_STAGES 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses