Skip to content

MngUnlinkLeadAffiliate

Unlinks one lead from its affiliate by customer_id. The affiliate code and the attribution fields are cleared, and the record stops counting for the affiliate in the Affiliate API, the affiliate cabinet and marketing stats. Deposits, withdrawals and trading accounts are not changed. What exactly changes is described in Unlinking From an Affiliate.

The command is available through the manager command API only; there is no REST path for it. The kind is fixed by the command name. See Clients and Leads Commands.

To unlink many records at once, use MngUnlinkLeadsAffiliateByFilter.

Access Control

Allowed sessions:

  • SESSION_MANAGER
  • SESSION_ADMIN
  • SESSION_DEALER
  • SESSION_CRM_MANAGER
  • SESSION_CRM_ADMIN

The caller must have CRM access, set_leads and set_marketing. The record brand and desk must be inside the manager scope; admin scope bypasses this check.

The call is written to the journal. Each unlinked record is also logged with the manager, the customer_id and the previous affiliate id and code.

Request

{
  "command": "MngUnlinkLeadAffiliate",
  "extID": "1",
  "data": {
    "customer_id": 1
  }
}

Request Data

Field Type Required Description
customer_id int Yes Target customer id, 1 or greater

Response Data

{
  "customer": {
    "customer_id": 1,
    "customer_kind": 0,
    "brand": "default",
    "affiliate_id": "",
    "campaign": "",
    "lead_source": "",
    "source_type": 0,
    "utm_source": "",
    "utm_medium": "",
    "utm_campaign": "",
    "utm_content": "",
    "utm_term": "",
    "landing_url": "",
    "referrer_url": "",
    "introducer_id": "IB-7"
  },
  "unlinked": true,
  "previous_affiliate": {
    "id": 4,
    "code": "AFF-PARTNER",
    "name": "Partner Media Ltd"
  }
}
Field Type Description
customer object The stored record after the call, in the same shape and with the same field visibility as MngGetLead. The example shows only the fields this command touches
unlinked bool true when something was changed. false when the record had no affiliate link; nothing is written then
previous_affiliate object or null The affiliate the record was linked to. null when no affiliate is known
previous_affiliate.id int Affiliate id. 0 when the affiliate code no longer resolves to an affiliate
previous_affiliate.code string Affiliate code. Empty when only the id is known and the affiliate no longer exists
previous_affiliate.name string Affiliate company name. Empty when the affiliate no longer exists

The previous affiliate is taken from affiliate_id of the record. If affiliate_id was already empty, it is taken from the marketing attribution.

Calling the command again for an unlinked record returns 200 with unlinked: false and the current record.

Errors

HTTP Error Description
400 INVALID_DATA Request validation failed
400 RET_INVALID_DATA The customer exists but is not a lead, or its brand changed during the call
403 RET_NOT_ENOUGH_RIGHTS Missing permission, missing scope, or the record is outside the caller's visibility
404 RET_NOT_FOUND No customer with that identifier exists
500 RET_ERROR The marketing storage did not answer; nothing on the customer record was changed

Every error carries a message field with free-form text. Its contents are not part of the contract; branch on error.