How to Connect WordPress to the Bitrix24 API: A Step-by-Step Guide

Illustrative image on the topic, with the title

The integration between WordPress and Bitrix24 allows you to automate registrations, leads, and contact forms, saving time and reducing manual errors.

In this guide, you’ll learn how to connect WordPress to the Bitrix24 API using PHP.

What Is Bitrix24?

Bitrix24 is a CRM, sales automation, and internal communication platform.

It provides a REST API that allows you to create, edit, and retrieve data such as leads, contacts, deals, tasks, products, and users.

Prerequisites

Before getting started, you’ll need:

  • A WordPress website with access to its code (via FTP or your server’s control panel);

  • A Bitrix24 account (cloud or self-hosted);

  • The Bitrix24 API Webhook (we’ll generate one below).

Step 1: Generate the Webhook in Bitrix24

  1. In Bitrix24, go to: Menu → Developers → Webhooks → Add Webhook.

  2. Select the “Incoming” webhook type.

  3. Select the permissions you need (for example, crm, user, and lead).

  4. Copy the generated URL, which will look something like:

https://yourdomain.bitrix24.com/rest/1/abc123xyz456/

This is your base endpoint for all API requests.

Step 2: Create a PHP File in WordPress

You can create a small script inside your theme or, preferably, in a custom plugin.

Create the file:

wp-content/plugins/wp-bitrix-integration/wp-bitrix-integration.php

Then add:

<?php
/**
 * Plugin Name: WP Bitrix Integration
 * Description: Connects WordPress to the Bitrix24 API.
 * Version: 1.0
 * Author: Your Name
 */

add_action('wp_ajax_send_to_bitrix', 'send_to_bitrix');
add_action('wp_ajax_nopriv_send_to_bitrix', 'send_to_bitrix');

function send_to_bitrix() {
    $webhook = 'https://yourdomain.bitrix24.com/rest/1/abc123xyz456/';

    $leadData = [
        'fields' => [
            'TITLE' => 'New lead from website',
            'NAME' => sanitize_text_field($_POST['name']),
            'EMAIL' => [
                [
                    'VALUE' => sanitize_email($_POST['email']),
                    'VALUE_TYPE' => 'WORK'
                ]
            ],
            'PHONE' => [
                [
                    'VALUE' => sanitize_text_field($_POST['phone']),
                    'VALUE_TYPE' => 'WORK'
                ]
            ],
            'COMMENTS' => sanitize_textarea_field($_POST['message']),
        ]
    ];

    $response = wp_remote_post($webhook . 'crm.lead.add.json', [
        'body' => $leadData,
    ]);

    if (is_wp_error($response)) {
        wp_send_json_error(['message' => 'Error sending lead.']);
    } else {
        wp_send_json_success(['message' => 'Lead sent successfully!']);
    }
}

Step 3: Create the Form in WordPress

On any page or template, insert the following HTML:

<form id="leadForm">
    <input type="text" name="name" placeholder="Your name" required>
    <input type="email" name="email" placeholder="Your email" required>
    <input type="tel" name="phone" placeholder="Your phone">
    <textarea name="message" placeholder="Message"></textarea>
    <button type="submit">Send</button>
</form>

<div id="result"></div>

<script>
document.querySelector('#leadForm').addEventListener('submit', async (e) => {
    e.preventDefault();

    const formData = new FormData(e.target);

    const response = await fetch('<?php echo admin_url("admin-ajax.php?action=send_to_bitrix"); ?>', {
        method: 'POST',
        body: formData
    });

    const result = await response.json();

    document.querySelector('#result').innerText =
        result.data?.message || 'Error sending lead';
});
</script>

Step 4: Test the Integration

  1. Go to the form page.

  2. Fill it out and submit it.

  3. Go to CRM → Leads in Bitrix24.

  4. You should see the new lead created automatically!

Tip: Create a Class to Organize Your Code

You can refactor the code into a PHP class, such as BitrixIntegration, to:

  • Centralize functions;

  • Reuse them across other plugins;

  • Add logging and error handling.

Integrating WordPress with the Bitrix24 API is simple and powerful.With just a few steps, you can automate lead capture, form submissions, and even create deals automatically in your CRM.
Scroll to Top