# Update an opportunity

Updates an existing opportunity. stageId takes priority over stage (a name, matched case-insensitively). Sending status won or lost selects the workspace's matching closed stage and leaves the opportunity's status field unchanged. value sets the total and the services forecast together and cannot be combined with forecastedValueServices. Every amount is in the workspace's current currency. null clears the description, notes, source, business unit, decision criteria, timeline notes, tags, close date, site or a contact. Moving the opportunity to another client clears its site unless a site of the new client is given, and is refused with conflict for an opportunity ConnectWise holds, which is moved in ConnectWise. An opportunity id outside the tenant, on an archived client, or that does not exist answers not_found, as does a client, contact or site id outside the tenant or a site that is not the client's; giving no field to change answers validation_failed. customFields can only be set from a signed-in session. A stage change starts the workspace's stage-changed workflows, and a change to the name, close date, contact, site, probability or description of an opportunity ConnectWise holds is queued for ConnectWise; connectwiseWriteBack says what was queued and which fields ConnectWise could not take. record is the full opportunity for a signed-in caller and null for an API key.

**POST** /v1/opportunities/{opportunityId}



## Parameters
- opportunityId (path, required): string
- Idempotency-Key (header, required): Opaque idempotency key, at most 255 characters, scoped to (tenant, principal, operation). A missing key is validation_failed.

## Request body
- name: string
- value: number
- stageId: string
- stage: string
- status: string
- notes: object
- clientId: string
- contactId: object
- siteId: object
- billingContactId: object
- shippingContactId: object
- description: object
- probability: integer
- forecastedValueServices: number
- forecastedValueProducts: number
- forecastedValueRecurring: number
- expectedCloseDate: object
- businessUnit: object
- source: object
- decisionCriteria: object
- timelineNotes: object
- tags: object
- customFields: object

## Responses
- **200** Update an opportunity — opportunity (required): object; record (required): object; connectwiseWriteBack (required): object
- **202** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ApprovalRequiredError:; allOf: ErrorEnvelope
- **400** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ValidationFailedError:; allOf: ErrorEnvelope
- **401** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — UnauthorizedError:; allOf: ErrorEnvelope
- **403** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ForbiddenError:; allOf: ErrorEnvelope
- **404** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — NotFoundError:; allOf: ErrorEnvelope
- **409** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ConflictError:; allOf: ErrorEnvelope
- **429** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — RateLimitedError:; allOf: ErrorEnvelope
- **503** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — UnavailableError:; allOf: ErrorEnvelope

## Example
```bash
curl --request POST \
  --url 'https://api.scopable.io/v1/opportunities/{opportunityId}' \
  --header 'Authorization: Bearer $SCOPABLE_API_KEY' \
  --data '<JSON request body>'
```

OpenAPI source: https://api.scopable.io/v1/openapi.json