## Merge two opportunities `client.Merge.MergeOpportunities(ctx, body) (*MergeMergeOpportunitiesResponse, error)` **post** `/v1/opportunities/merge` Merges two opportunities into one. The primary opportunity retains its ID; the duplicate is soft-deleted. Both opportunities must belong to the same account. **[Required scopes](/using-the-api/scopes/):** `opportunities:update` + `opportunities:delete` **[Rate limit category](/using-the-api/rate-limits/):** Write ### Parameters - `body MergeMergeOpportunitiesParams` - `DuplicateID param.Field[string]` ID of the duplicate record to merge into the primary and then discard. - `PrimaryID param.Field[string]` ID of the record to keep. - `FieldResolutions param.Field[map[string, MergeMergeOpportunitiesParamsFieldResolutionUnion]]` Per-field resolution overrides keyed by attribute slug. - `type MergeMergeOpportunitiesParamsFieldResolutionString string` - `const MergeMergeOpportunitiesParamsFieldResolutionStringPrimary MergeMergeOpportunitiesParamsFieldResolutionString = "primary"` - `const MergeMergeOpportunitiesParamsFieldResolutionStringDuplicate MergeMergeOpportunitiesParamsFieldResolutionString = "duplicate"` - `type MergeMergeOpportunitiesParamsFieldResolutionValue struct{…}` - `Value MergeMergeOpportunitiesParamsFieldResolutionValueValueUnion` - `string` - `float64` - `bool` - `type MergeMergeOpportunitiesParamsFieldResolutionValueValueArray []string` - `type MergeMergeOpportunitiesParamsFieldResolutionValueValueAddress 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 MergeMergeOpportunitiesParamsFieldResolutionValueValueFullName struct{…}` - `FirstName string` The contact's first name. - `LastName string` The contact's last name. - `Options param.Field[MergeMergeOpportunitiesParamsOptions]` - `MultiSelectUnion bool` When true, multi-select fields are merged by union rather than primary-takes-all. ### Returns - `type MergeMergeOpportunitiesResponse struct{…}` - `Merge MergeMergeOpportunitiesResponseMerge` - `ID string` Unique identifier for the merge operation. - `Status string` Current status of the merge: `cleanup_pending`, `done`, or `failed`. - `Primary MergeMergeOpportunitiesResponsePrimary` - `ID string` Unique identifier for the entity. - `CreatedAt string` ISO 8601 timestamp of when the entity was created. - `Fields map[string, MergeMergeOpportunitiesResponsePrimaryField]` Map of field names to their typed values. System fields are prefixed with `$` (e.g. `$name`, `$email`); custom attributes use their bare slug. - `Value MergeMergeOpportunitiesResponsePrimaryFieldValueUnion` The field value, or null if unset. - `string` - `float64` - `bool` - `type MergeMergeOpportunitiesResponsePrimaryFieldValueArray []string` - `type MergeMergeOpportunitiesResponsePrimaryFieldValueAddress 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 MergeMergeOpportunitiesResponsePrimaryFieldValueFullName struct{…}` - `FirstName string` The contact's first name. - `LastName string` The contact's last name. - `ValueType string` The data type of the field. - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeAddress MergeMergeOpportunitiesResponsePrimaryFieldValueType = "ADDRESS"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeCheckbox MergeMergeOpportunitiesResponsePrimaryFieldValueType = "CHECKBOX"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeCurrency MergeMergeOpportunitiesResponsePrimaryFieldValueType = "CURRENCY"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeDatetime MergeMergeOpportunitiesResponsePrimaryFieldValueType = "DATETIME"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeEmail MergeMergeOpportunitiesResponsePrimaryFieldValueType = "EMAIL"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeFullName MergeMergeOpportunitiesResponsePrimaryFieldValueType = "FULL_NAME"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeMarkdown MergeMergeOpportunitiesResponsePrimaryFieldValueType = "MARKDOWN"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeMultiSelect MergeMergeOpportunitiesResponsePrimaryFieldValueType = "MULTI_SELECT"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeNumber MergeMergeOpportunitiesResponsePrimaryFieldValueType = "NUMBER"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeSingleSelect MergeMergeOpportunitiesResponsePrimaryFieldValueType = "SINGLE_SELECT"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeSocialHandle MergeMergeOpportunitiesResponsePrimaryFieldValueType = "SOCIAL_HANDLE"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeTelephone MergeMergeOpportunitiesResponsePrimaryFieldValueType = "TELEPHONE"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeText MergeMergeOpportunitiesResponsePrimaryFieldValueType = "TEXT"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeURL MergeMergeOpportunitiesResponsePrimaryFieldValueType = "URL"` - `const MergeMergeOpportunitiesResponsePrimaryFieldValueTypeHTML MergeMergeOpportunitiesResponsePrimaryFieldValueType = "HTML"` - `HTTPLink string` URL to view the entity in the Lightfield web app, or null. - `Relationships map[string, MergeMergeOpportunitiesResponsePrimaryRelationship]` 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. - `Summary MergeMergeOpportunitiesResponseSummary` - `FieldWriteCount int64` Number of attribute fields written onto the primary record. - `SyncRepointedCount int64` Number of related records re-pointed from the duplicate to the primary. - `Warnings []string` Non-fatal warnings from the merge (e.g. skipped transfers). ### 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"), ) mergeMergeOpportunitiesResponse, err := client.Merge.MergeOpportunities(context.TODO(), githubcomlightfldlightfieldgo.MergeMergeOpportunitiesParams{ DuplicateID: "duplicateId", PrimaryID: "primaryId", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", mergeMergeOpportunitiesResponse.Merge) } ``` #### Response ```json { "merge": { "id": "id", "status": "status" }, "primary": { "id": "id", "createdAt": "createdAt", "fields": { "foo": { "value": "string", "valueType": "ADDRESS" } }, "httpLink": "httpLink", "relationships": { "foo": { "cardinality": "cardinality", "objectType": "objectType", "values": [ "string" ] } }, "updatedAt": "updatedAt", "externalId": "externalId" }, "summary": { "fieldWriteCount": -9007199254740991, "syncRepointedCount": -9007199254740991, "warnings": [ "string" ] } } ```