Skip to content

Latest commit

 

History

History
277 lines (217 loc) · 7.08 KB

File metadata and controls

277 lines (217 loc) · 7.08 KB

Connect an External Open Channel to the Account imopenlines.network.join

{% note tip "" %}

If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.

{% endnote %}

Scope: imopenlines

Who can execute the method: any user

The method imopenlines.network.join connects an external open channel from another Bitrix24 to the current Bitrix24.

Method Parameters

{% include Note on required parameters %}

#| || Name type | Description || || CODE* string | The code of the open channel as a string of 32 characters.

You can find the channel code in the detail form of the connected open channel in Bitrix24 Network on the Contact Center page.

{% note tip "User Documentation" %}

{% endnote %}

|| |#

Code Examples

{% include Note on Examples %}

{% list tabs %}

  • cURL (Webhook)

    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -d '{
        "CODE": "ab515f5d85a8b844d484f6ea75a2e494"
      }' \
      https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/imopenlines.network.join
  • cURL (OAuth)

    curl -X POST \
      -H "Content-Type: application/json" \
      -H "Accept: application/json" \
      -d '{
        "CODE": "ab515f5d85a8b844d484f6ea75a2e494",
        "auth": "**put_access_token_here**"
      }' \
      https://**put_your_bitrix24_address**/rest/imopenlines.network.join
  • JS (TS)

    // This snippet is an ES module: top-level await requires type="module" or a bundler.
    // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
    import { Text } from '@bitrix24/b24jssdk'
    import type { B24Frame } from '@bitrix24/b24jssdk'
    
    declare const $b24: B24Frame
    
    try {
      const response = await $b24.actions.v2.call.make<number>({
        method: 'imopenlines.network.join',
        params: {
          CODE: 'ab515f5d85a8b844d484f6ea75a2e494',
        },
        requestId: Text.getUuidRfc4122()
      })
    
      // The payload is available only on a successful response
      if (!response.isSuccess) {
        console.error(response.getErrorMessages().join('; '))
      } else {
        const result = response.getData()!.result
        console.info('Connected network bot ID:', result)
      }
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  • JS (UMD)

    <!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
    <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
    <script>
      async function joinOpenLine() {
        try {
          // Initialize the SDK inside a Bitrix24 frame
          const $b24 = await B24Js.initializeB24Frame()
    
          const response = await $b24.actions.v2.call.make({
            method: 'imopenlines.network.join',
            params: {
              CODE: 'ab515f5d85a8b844d484f6ea75a2e494',
            },
            requestId: B24Js.Text.getUuidRfc4122()
          })
    
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
            return
          }
    
          const result = response.getData().result
          console.info('Connected network bot ID:', result)
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
      }
    
      document.addEventListener('DOMContentLoaded', joinOpenLine)
    </script>
  • PHP

    try {
        $response = $b24Service
            ->core
            ->call(
                'imopenlines.network.join',
                [
                    'CODE' => 'ab515f5d85a8b844d484f6ea75a2e494',
                ]
            );
    
        $result = $response
            ->getResponseData()
            ->getResult();
    
        print_r($result);
    } catch (Throwable $e) {
        echo $e->getMessage();
    }
  • BX24.js

    BX24.callMethod(
        'imopenlines.network.join',
        {
            CODE: 'ab515f5d85a8b844d484f6ea75a2e494'
        },
        function(result)
        {
            if (result.error())
            {
                console.error(result.error());
            }
            else
            {
                console.log(result.data());
            }
        }
    );
  • PHP CRest

    require_once('crest.php');
    
    $result = CRest::call(
        'imopenlines.network.join',
        [
            'CODE' => 'ab515f5d85a8b844d484f6ea75a2e494',
        ]
    );
    
    print_r($result);
  • Go

    // client and ctx are already created — see the Go SDK section
    res, err := client.Core().Call(ctx, "imopenlines.network.join", b24.Params{
    	"CODE": "ab515f5d85a8b844d484f6ea75a2e494",
    })
    if err != nil {
    	return fmt.Errorf("imopenlines.network.join: %w", err)
    }
    
    var value b24.ID
    if err := json.Unmarshal(res.Result, &value); err != nil {
    	return fmt.Errorf("parse response: %w", err)
    }
    fmt.Println("result:", value)

{% endlist %}

Response Handling

HTTP Status: 200

{
    "result": 603,
    "time": {
        "start": 1773735146,
        "finish": 1773735146.911103,
        "duration": 0.9111030101776123,
        "processing": 0,
        "date_start": "2026-03-17T11:12:26+02:00",
        "date_finish": "2026-03-17T11:12:26+02:00",
        "operating_reset_at": 1773735746,
        "operating": 0.44127893447875977
    }
}

Returned Data

#| || Name type | Description || || result integer | The identifier of the network bot for the connected external open channel.

If the channel was previously connected, the method returns the existing identifier || || time time | Information about the request execution time || |#

Error Handling

HTTP Status: 400

{
    "error": "NOT_FOUND",
    "error_description": "Line not found"
}

{% include notitle error handling %}

Possible Error Codes

#| || Status | Code | Description | Value || || 400 | CODE | You entered an invalid code | Invalid code in parameter CODE, expected a string of 32 characters || || 400 | IMBOT_ERROR | Module IMBOT is not installed | The imbot module is not installed || || 400 | NOT_FOUND | Line not found | Open channel not found || || 400 | INACTIVE | Openline is inactive | The open channel is currently unavailable || |#

{% include system errors %}

Continue Learning