Skip to content

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: opportunities:update + opportunities:delete

Rate limit category: Write

ParametersExpand Collapse
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]]Optional

Per-field resolution overrides keyed by attribute slug.

type MergeMergeOpportunitiesParamsFieldResolutionString string
One of the following:
const MergeMergeOpportunitiesParamsFieldResolutionStringPrimary MergeMergeOpportunitiesParamsFieldResolutionString = "primary"
const MergeMergeOpportunitiesParamsFieldResolutionStringDuplicate MergeMergeOpportunitiesParamsFieldResolutionString = "duplicate"
type MergeMergeOpportunitiesParamsFieldResolutionValue struct{…}
Value MergeMergeOpportunitiesParamsFieldResolutionValueValueUnion
One of the following:
string
float64
bool
type MergeMergeOpportunitiesParamsFieldResolutionValueValueArray []string
type MergeMergeOpportunitiesParamsFieldResolutionValueValueAddress struct{…}
City stringOptional

City name.

Country stringOptional

2-letter ISO 3166-1 alpha-2 country code.

Latitude float64Optional

Latitude coordinate.

Longitude float64Optional

Longitude coordinate.

PostalCode stringOptional

Postal or ZIP code.

State stringOptional

State or province.

Street stringOptional

Street address line 1.

Street2 stringOptional

Street address line 2.

type MergeMergeOpportunitiesParamsFieldResolutionValueValueFullName struct{…}
FirstName stringOptional

The contact’s first name.

LastName stringOptional

The contact’s last name.

Options param.Field[MergeMergeOpportunitiesParamsOptions]Optional
MultiSelectUnion boolOptional

When true, multi-select fields are merged by union rather than primary-takes-all.

ReturnsExpand Collapse
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.

One of the following:
string
float64
bool
type MergeMergeOpportunitiesResponsePrimaryFieldValueArray []string
type MergeMergeOpportunitiesResponsePrimaryFieldValueAddress struct{…}
City stringOptional

City name.

Country stringOptional

2-letter ISO 3166-1 alpha-2 country code.

Latitude float64Optional

Latitude coordinate.

Longitude float64Optional

Longitude coordinate.

PostalCode stringOptional

Postal or ZIP code.

State stringOptional

State or province.

Street stringOptional

Street address line 1.

Street2 stringOptional

Street address line 2.

type MergeMergeOpportunitiesResponsePrimaryFieldValueFullName struct{…}
FirstName stringOptional

The contact’s first name.

LastName stringOptional

The contact’s last name.

ValueType string

The data type of the field.

One of the following:
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"
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 stringOptional

External identifier for the entity, or null if unset.

Summary MergeMergeOpportunitiesResponseSummary
FieldWriteCount int64

Number of attribute fields written onto the primary record.

minimum-9007199254740991
maximum9007199254740991
SyncRepointedCount int64

Number of related records re-pointed from the duplicate to the primary.

minimum-9007199254740991
maximum9007199254740991
Warnings []string

Non-fatal warnings from the merge (e.g. skipped transfers).

Merge two opportunities

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)
}
{
  "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"
    ]
  }
}
Returns Examples
{
  "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"
    ]
  }
}