opportunity/close
Close an Opportunity as Won or Lost. A semantic convenience that sets StageName, IsClosed, and IsWon in a single operation.
How It Works: Closing as Won sets StageName to Closed Won and IsWon to true. Closing as Lost sets StageName to Closed Lost and IsWon to false. Under the hood, this performs a standard field update via the Salesforce REST API.
When to Use
- Close an opportunity as Won immediately after a contract is signed.
- Mark an opportunity as Lost when a competitor wins or the prospect declines.
- Batch-close expired opportunities during end-of-quarter pipeline cleanup.
Configuration
Connection
| Field | Type | Required | Description |
InstanceUrl | string | required | Salesforce org URL. |
AccessToken | string | required | Valid OAuth2 access token. |
Operation Fields
| Field | Type | Required | Description |
OpportunityId | string | required | 18-character Salesforce Opportunity ID. |
IsClosed | bool | required | Set to true to close the opportunity. |
IsWon | bool | required | Set to true for Closed Won, false for Closed Lost. |
Sample Configuration
{
"Resource": "opportunity",
"Operation": "close",
"InstanceUrl": "https://myorg.my.salesforce.com",
"AccessToken": "{{credentials.salesforce.accessToken}}",
"OpportunityId": "{{trigger.opportunityId}}",
"IsClosed": true,
"IsWon": true
}
Validation Errors
| Error Code | Condition |
CFG_MISSING_INSTANCE | InstanceUrl is missing. |
CFG_MISSING_TOKEN | AccessToken is missing. |
VAL_MISSING_FIELD | OpportunityId, IsClosed, or IsWon is missing. |
UNEXPECTED_ERROR | Unexpected exception. |
Output
Success Port
| Field | Type | Description |
status | string | Always closed. |
resource | string | Always opportunity. |
operation | string | Always close. |
Error Port
| Field | Type | Description |
errorCode | string | Machine-readable error code. |
message | string | Error description. |
Sample Output
{ "status": "closed", "resource": "opportunity", "operation": "close" }
Expression Reference
| Expression | Description |
{{nodes.CloseOpportunity.status}} | Close operation result. |
{{nodes.CloseOpportunity.errorCode}} | Error code from error port. |
Node Policies & GuardRails
| Policy | Detail |
| Already closed | Closing an already-closed opportunity may trigger validation rule errors. Use opportunity/get to check IsClosed before calling this operation. |
| Stage name requirement | Your org must have Closed Won and Closed Lost defined as pipeline stages. Verify in Opportunity Stage settings. |
| Downstream triggers | Closing an opportunity may fire Salesforce workflow rules and Process Builder automations. Test in sandbox. |
| Error port wiring | Always wire the error port. |
| Sandbox testing | Test in sandbox before production. Especially important given downstream automation triggers. |
Examples
Close as Won on Contract Signature
{
"OpportunityId": "{{trigger.opportunityId}}",
"IsClosed": true,
"IsWon": true
}
// Downstream: trigger onboarding workflow, send congratulations Slack message
Mark as Lost When Competitor Wins
{
"OpportunityId": "{{trigger.opportunityId}}",
"IsClosed": true,
"IsWon": false
}
Batch Close Expired Opportunities
// GetAll: Query = "IsClosed = false AND CloseDate < TODAY"
// Loop: opportunity/close each
{
"OpportunityId": "{{loop.current.Id}}",
"IsClosed": true,
"IsWon": false
}