﻿---
sidebar_position: 5
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Update lead
 Modifies an existing lead



`Function UpdateLead(Val URL, Val LeadID, Val FieldsStructure, Val Token = "") Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | URL | --url | String | &#x2714; | URL of webhook or a Bitrix24 domain, when token used |
  | LeadID | --lead | Number, String | &#x2714; | Lead ID |
  | FieldsStructure | --fields | Structure of KeyAndValue | &#x2714; | Structure of lead fields |
  | Token | --token | String | &#x2716; | Access token, when app auth method used |

  
  Returns:  Map Of KeyAndValue - serialized JSON of answer from Bitrix24 API

<br/>

:::tip
Method at API documentation: [crm.lead.update](https://dev.1c-bitrix.ru/rest_help/crm/leads/crm_lead_update.php)
:::
<br/>


```bsl title="1C:Enterprise/OneScript code example"
    FieldsStructure = New Structure;
    FieldsStructure.Insert("ADDRESS"        , "Lermontov st., b. 20");
    FieldsStructure.Insert("ADDRESS_COUNTRY", "Belarus");
    FieldsStructure.Insert("TITLE"          , "SuperClient");

    URL    = "https://b24-ar17wx.bitrix24.by/rest/1/yg2...";
    LeadID = "700";

    Result = OPI_Bitrix24.UpdateLead(URL, LeadID, FieldsStructure);

    FieldsStructure.Insert("NAME"      , "Evgeniy");
    FieldsStructure.Insert("LAST_NAME" , "Evgeniev");

    URL    = "b24-ar17wx.bitrix24.by";
    Token  = "48573267006e9f06006b12e400000001000...";
    LeadID = "702";

    Result = OPI_Bitrix24.UpdateLead(URL, LeadID, FieldsStructure, Token);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint bitrix24 UpdateLead \
             --url "b24-ar17wx.bitrix24.by" \
             --lead 706 \
             --fields "{'ADDRESS':'Lermontov st., b. 20','ADDRESS_COUNTRY':'Belarus','TITLE':'SuperClient','NAME':'Evgeniy','LAST_NAME':'Evgeniev'}" \
             --token "***"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint bitrix24 UpdateLead ^
             --url "b24-ar17wx.bitrix24.by" ^
             --lead 706 ^
             --fields "{'ADDRESS':'Lermontov st., b. 20','ADDRESS_COUNTRY':'Belarus','TITLE':'SuperClient','NAME':'Evgeniy','LAST_NAME':'Evgeniev'}" ^
             --token "***"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": true,
 "time": {
  "start": 1728454942.70493,
  "finish": 1728454942.90789,
  "duration": 0.202960014343262,
  "processing": 0.174932956695557,
  "date_start": "2024-10-09T09:22:22+03:00",
  "date_finish": "2024-10-09T09:22:22+03:00",
  "operating_reset_at": 1728455542,
  "operating": 0.17490816116333
 }
}
```
