## Update an opportunity `client.Opportunity.Update(ctx, id, body) (*OpportunityUpdateResponse, error)` **post** `/v1/opportunities/{id}` Updates an existing opportunity by ID. Only included fields and relationships are modified. The `$opportunityStatus` field is read-only and cannot be updated. The `$task` and `$note` relationships are also read-only — manage them via the `$opportunity` relationship on the task, or the `$account`/`$opportunity` note relationships instead. Supports idempotency via the `Idempotency-Key` header. **[Required scope](/using-the-api/scopes/):** `opportunities:update` **[Rate limit category](/using-the-api/rate-limits/):** Write ### Parameters - `id string` Unique identifier of the opportunity to update. - `body OpportunityUpdateParams` - `Fields param.Field[map[string, OpportunityUpdateParamsFieldUnion]]` Field values to update — only provided fields are modified; omitted fields are left unchanged. System fields use a `$` prefix (e.g. `$name`, `$stage`); custom attributes use their bare slug. `SINGLE_SELECT` and `MULTI_SELECT` fields accept an option ID or label — call the [definitions endpoint](/api/resources/opportunity/methods/definitions) for available options. See [Fields and relationships](/using-the-api/fields-and-relationships/) for value type details. - `map[string, OpportunityUpdateParamsFieldUnion]` - `string` - `float64` - `bool` - `type OpportunityUpdateParamsFieldArray []string` - `type OpportunityUpdateParamsFieldAddress struct{…}` - `City string` City name. - `Country string` 2-letter ISO 3166-1 alpha-2 country code. - `Latitude float64` Latitude coordinate. - `Longitude float64` Longitude coordinate. - `PostalCode string` Postal or ZIP code. - `State string` State or province. - `Street string` Street address line 1. - `Street2 string` Street address line 2. - `type OpportunityUpdateParamsFieldFullName struct{…}` - `FirstName string` The contact's first name. - `LastName string` The contact's last name. - `Relationships param.Field[map[string, OpportunityUpdateParamsRelationship]]` Relationship operations to apply. System relationships use a `$` prefix (e.g. `$owner`, `$champion`). Each value is an operation object with `add`, `remove`, or `replace`. - `map[string, OpportunityUpdateParamsRelationship]` - `Add OpportunityUpdateParamsRelationshipAddUnion` Entity ID(s) to add to the relationship. - `string` - `type OpportunityUpdateParamsRelationshipAddArray []string` - `Remove OpportunityUpdateParamsRelationshipRemoveUnion` Entity ID(s) to remove from the relationship. - `string` - `type OpportunityUpdateParamsRelationshipRemoveArray []string` - `Replace OpportunityUpdateParamsRelationshipReplaceUnion` Entity ID(s) to set as the entire relationship, replacing all existing associations. - `string` - `type OpportunityUpdateParamsRelationshipReplaceArray []string` ### Returns - `type OpportunityUpdateResponse struct{…}` - `ID string` Unique identifier for the entity. - `CreatedAt string` ISO 8601 timestamp of when the entity was created. - `Fields map[string, OpportunityUpdateResponseField]` Map of field names to their typed values. System fields are prefixed with `$` (e.g. `$name`, `$email`); custom attributes use their bare slug. - `Value OpportunityUpdateResponseFieldValueUnion` The field value, or null if unset. - `string` - `float64` - `bool` - `type OpportunityUpdateResponseFieldValueArray []string` - `type OpportunityUpdateResponseFieldValueAddress struct{…}` - `City string` City name. - `Country string` 2-letter ISO 3166-1 alpha-2 country code. - `Latitude float64` Latitude coordinate. - `Longitude float64` Longitude coordinate. - `PostalCode string` Postal or ZIP code. - `State string` State or province. - `Street string` Street address line 1. - `Street2 string` Street address line 2. - `type OpportunityUpdateResponseFieldValueFullName struct{…}` - `FirstName string` The contact's first name. - `LastName string` The contact's last name. - `ValueType string` The data type of the field. - `const OpportunityUpdateResponseFieldValueTypeAddress OpportunityUpdateResponseFieldValueType = "ADDRESS"` - `const OpportunityUpdateResponseFieldValueTypeCheckbox OpportunityUpdateResponseFieldValueType = "CHECKBOX"` - `const OpportunityUpdateResponseFieldValueTypeCurrency OpportunityUpdateResponseFieldValueType = "CURRENCY"` - `const OpportunityUpdateResponseFieldValueTypeDatetime OpportunityUpdateResponseFieldValueType = "DATETIME"` - `const OpportunityUpdateResponseFieldValueTypeEmail OpportunityUpdateResponseFieldValueType = "EMAIL"` - `const OpportunityUpdateResponseFieldValueTypeFullName OpportunityUpdateResponseFieldValueType = "FULL_NAME"` - `const OpportunityUpdateResponseFieldValueTypeMarkdown OpportunityUpdateResponseFieldValueType = "MARKDOWN"` - `const OpportunityUpdateResponseFieldValueTypeMultiSelect OpportunityUpdateResponseFieldValueType = "MULTI_SELECT"` - `const OpportunityUpdateResponseFieldValueTypeNumber OpportunityUpdateResponseFieldValueType = "NUMBER"` - `const OpportunityUpdateResponseFieldValueTypeSingleSelect OpportunityUpdateResponseFieldValueType = "SINGLE_SELECT"` - `const OpportunityUpdateResponseFieldValueTypeSocialHandle OpportunityUpdateResponseFieldValueType = "SOCIAL_HANDLE"` - `const OpportunityUpdateResponseFieldValueTypeTelephone OpportunityUpdateResponseFieldValueType = "TELEPHONE"` - `const OpportunityUpdateResponseFieldValueTypeText OpportunityUpdateResponseFieldValueType = "TEXT"` - `const OpportunityUpdateResponseFieldValueTypeURL OpportunityUpdateResponseFieldValueType = "URL"` - `HTTPLink string` URL to view the entity in the Lightfield web app, or null. - `Relationships map[string, OpportunityUpdateResponseRelationship]` Map of relationship names to their associated entities. System relationships are prefixed with `$` (e.g. `$owner`, `$contact`). - `Cardinality string` Whether the relationship is `has_one` or `has_many`. - `ObjectType string` The type of the related object (e.g. `account`, `contact`). - `Values []string` IDs of the related entities. - `UpdatedAt string` ISO 8601 timestamp of when the entity was last updated, or null. - `ExternalID string` External identifier for the entity, or null if unset. ### Example ```go package main import ( "context" "fmt" "github.com/Lightfld/lightfield-go" "github.com/Lightfld/lightfield-go/option" ) func main() { client := githubcomlightfldlightfieldgo.NewClient( option.WithAPIKey("My API Key"), ) opportunityUpdateResponse, err := client.Opportunity.Update( context.TODO(), "id", githubcomlightfldlightfieldgo.OpportunityUpdateParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", opportunityUpdateResponse.ID) } ``` #### Response ```json { "id": "id", "createdAt": "createdAt", "fields": { "foo": { "value": "string", "valueType": "ADDRESS" } }, "httpLink": "httpLink", "relationships": { "foo": { "cardinality": "cardinality", "objectType": "objectType", "values": [ "string" ] } }, "updatedAt": "updatedAt", "externalId": "externalId" } ```