﻿---
sidebar_position: 3
---

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

# Create user
 Create new user by fields structure



`Function CreateUser(Val URL, 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 |
  | FieldsStructure | --fields | Structure Of KeyAndValue | &#x2714; | New user data. See. GetUserFieldsStructure |
  | 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: [user.add](https://dev.1c-bitrix.ru/rest_help/users/user_add.php)

If you want to add an extranet user, you must pass in the fields: EXTRANET: Y and SONET_GROUP_ID: [...]

If you want to add an intranet user, you must pass UF_DEPARTMENT field: [...]
:::
<br/>



```bsl title="1C:Enterprise/OneScript code example"
    URL   = "https://b24-ar17wx.bitrix24.by/rest/1/h0m...";
    Email = String(New UUID) + "@exepmple.org";
    // The full structure can be obtained with the function GetUserFieldsStructure

    UserStructure = New Structure;
    UserStructure.Insert("EMAIL"        , Email);
    UserStructure.Insert("UF_DEPARTMENT", 7);

    Result = OPI_Bitrix24.CreateUser(URL, UserStructure);

    URL   = "b24-ar17wx.bitrix24.by";
    Token = "e0159667006e9f06006b12e400000001000...";
    Email = String(New UUID) + "@exepmple.org";

    UserStructure = New Structure;
    UserStructure.Insert("EMAIL"          , Email);
    UserStructure.Insert("NAME"           , "Vitaly");
    UserStructure.Insert("LAST_NAME"      , "Alpaca");
    UserStructure.Insert("PERSONAL_MOBILE", "88003553535");
    UserStructure.Insert("UF_DEPARTMENT"  , 1);

    Result = OPI_Bitrix24.CreateUser(URL, UserStructure, Token);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint bitrix24 CreateUser \
             --url "b24-ar17wx.bitrix24.by" \
             --fields "{'EMAIL':'90e826a9-7ebe-42e0-8bc7-588ba5396c62@exepmple.org','NAME':'Vitaly','LAST_NAME':'Alpaca','PERSONAL_MOBILE':'88003553535','UF_DEPARTMENT':1}" \
             --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 CreateUser ^
             --url "b24-ar17wx.bitrix24.by" ^
             --fields "{'EMAIL':'90e826a9-7ebe-42e0-8bc7-588ba5396c62@exepmple.org','NAME':'Vitaly','LAST_NAME':'Alpaca','PERSONAL_MOBILE':'88003553535','UF_DEPARTMENT':1}" ^
             --token "***"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": 606,
 "time": {
  "start": 1728454933.44558,
  "finish": 1728454935.61149,
  "duration": 2.16591095924377,
  "processing": 2.13802599906921,
  "date_start": "2024-10-09T09:22:13+03:00",
  "date_finish": "2024-10-09T09:22:15+03:00",
  "operating_reset_at": 1728455533,
  "operating": 2.13800406455994
 }
}
```
