For AI agents: markdown of this page — /docs-content-en/entities/crm-tracking/sources-update.md documentation index — /llms.txt

Update an end-to-end analytics source

PATCH /v1/crm-tracking/sources/:id

PATCH /v1/crm-tracking/sources/by-code/:code

Updates the supplied fields of an end-to-end analytics source and returns its state after saving.

The method ships in the crm 26.2100.0 update and is not yet available on all Bitrix24 accounts. Until the feature is enabled for your Bitrix24 account, the API returns 422 METHOD_NOT_YET_AVAILABLE.

Requires the crm scope and a key that permits writes.

Parameters

Parameter Type Required Description
Parameterid (path) Typenumber Requiredfor the ID path DescriptionPositive integer ID from the source list
Parametercode (path) Typestring Requiredfor the code path DescriptionBuilt-in source code from the source list, such as google

Choose exactly one address: /sources/2 or /sources/by-code/google. Query parameters are not accepted.

The first update of a built-in source by code creates its record. Before saving, that source can have id: null.

Request body fields

Field Type Required Description
Fieldname Typestring Requiredno DescriptionSource name
Fieldcolor Typestring Requiredno DescriptionCustom source color in #rgb or #rrggbb format. A request to change a built-in source color is refused
FieldrefDomains Typestring[] Requiredno DescriptionComplete list of referring domains. Built-in sources with predefined domains do not allow changes to this list
FieldutmSources Typestring[] Requiredno DescriptionComplete list of utm_source values

Lists are replaced in full. [] clears a list. Omitted fields keep their values. Bitrix24 trims whitespace, removes empty values, and limits each list to 100 values. The API validates the shape: an array of strings.

An empty object is forwarded without adding fields. color: null keeps the existing color.

Examples

curl — personal key

Terminal

curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-tracking/sources/2" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Partner campaign updated",
  "utmSources": [
    "partner-new"
  ]
}'

curl — OAuth application

Terminal

curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-tracking/sources/2" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Partner campaign updated",
  "utmSources": [
    "partner-new"
  ]
}'

JavaScript — personal key

javascript

const res = await fetch('https://vibecode.bitrix24.com/v1/crm-tracking/sources/2', {

  method: 'PATCH',

  headers: {
    "X-Api-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
  },

  body: JSON.stringify({
    "name": "Partner campaign updated",
    "utmSources": [
      "partner-new"
    ]
  }),

})

const { success, data } = await res.json()

console.log(data.id)

JavaScript — OAuth application

javascript

const res = await fetch('https://vibecode.bitrix24.com/v1/crm-tracking/sources/2', {

  method: 'PATCH',

  headers: {
    "X-Api-Key": "YOUR_APP_KEY",
    "Authorization": "Bearer USER_SESSION_TOKEN",
    "Content-Type": "application/json"
  },

  body: JSON.stringify({
    "name": "Partner campaign updated",
    "utmSources": [
      "partner-new"
    ]
  }),

})

const { success, data } = await res.json()

console.log(data.id)

Response fields

HTTP 200. The source is read again after saving.

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on success
Fielddata Typeobject DescriptionSource state
Fielddata.id Typenumber / null DescriptionSource ID for reading
Fielddata.code Typestring / null DescriptionBuilt-in source code, null for a custom source
Fielddata.kind Typestring Descriptionown for a custom source, builtIn for a built-in source
Fielddata.name Typestring DescriptionName
Fielddata.color Typestring / null DescriptionColor
Fielddata.isActive Typeboolean DescriptionWhether the source is active
Fielddata.isConfigurable Typeboolean DescriptionWhether the source can be configured
Fielddata.isConfigured Typeboolean DescriptionWhether UTM values or referring domains are configured
Fielddata.refDomains Typestring[] DescriptionReferring domains
Fielddata.utmSources Typestring[] Descriptionutm_source values

Response example

Response shape example, not a live call result.

JSON

{
  "success": true,
  "data": {
    "id": 2,
    "code": null,
    "kind": "own",
    "name": "Partner campaign updated",
    "color": "#55d0e0",
    "isActive": true,
    "isConfigurable": true,
    "isConfigured": true,
    "refDomains": [
      "partner.example.com"
    ],
    "utmSources": [
      "partner-new"
    ]
  }
}

Error response example

400 — an invalid color in the update body:

JSON

{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "color must be #rgb or #rrggbb"
  }
}

Errors

HTTP Code Description
HTTP404 CodeENTITY_NOT_FOUND DescriptionSource was not found
HTTP400 CodeINVALID_PARAMS DescriptionInvalid field type, color, or source address
HTTP400 CodeUNKNOWN_FILTER_FIELD DescriptionA query parameter was supplied
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key permits reads only
HTTP403 CodeSCOPE_DENIED DescriptionThe crm scope is missing
HTTP401 CodeTOKEN_MISSING DescriptionNo credentials are configured for the key
HTTP422 CodeMETHOD_NOT_YET_AVAILABLE DescriptionThe feature is not enabled for the portal yet
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 returned an invalid response

Bitrix24 refusals retain their code and message. For common errors, see Errors.

See also