Integration of 1C-Bitrix with AmoCRM

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1173
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    745
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Integration of 1C-Bitrix with amoCRM

Orders in Bitrix, leads in amoCRM, managers switch between two tabs and manually copy data. Client contact in CRM doesn't match order data, conversation history is broken. Integration eliminates manual labor and builds a unified funnel: from first site visit to deal closure. Let's examine the architecture, amoCRM API, typical data flows, and pitfalls.

Data Flows

Flow Direction Trigger Priority
Leads from site forms Bitrix → amoCRM Form submission High
Orders Bitrix → amoCRM Order checkout Critical
Contacts Bitrix ↔ amoCRM On lead/order creation High
Deal statuses amoCRM → Bitrix Pipeline stage change Medium
Catalog products Bitrix → amoCRM By schedule Low

Main flow — orders and leads from Bitrix to amoCRM. Reverse flow (statuses) is needed if site has personal account with order processing tracking.

amoCRM API v4

amoCRM uses OAuth 2.0 with long-lived refresh token. After authorization via integration (Settings → Integrations in amoCRM), you receive client_id, client_secret, redirect_uri. Initial code-to-token exchange — standard OAuth flow. Refresh token updates on each token refresh (access token lifetime — 20 minutes).

Token Storage in Bitrix: b_option table of module or separate table. Mandatory to encrypt or store outside public directory. Cache access token in runtime, refresh only on 401.

Base API URL: https://{subdomain}.amocrm.ru/api/v4/.

Key endpoints:

  • POST /leads — deal creation.
  • POST /contacts — contact creation.
  • POST /leads/complex — deal creation with contact and company in one request. Recommended method — atomic operation.
  • GET /leads/{id} — get deal.
  • PATCH /leads/{id} — update deal (status change, field addition).
  • POST /catalogs/{catalog_id}/elements — products in amoCRM catalog.

Limitations: 7 requests per second per account. Exceeding returns HTTP 429 with Retry-After header.

Deal Creation on Order Checkout

Event handler OnSaleOrderSaved (module sale):

use Bitrix\Main\EventManager;

EventManager::getInstance()->addEventHandler(
    'sale', 'OnSaleOrderSaved',
    ['AmoCrmIntegration', 'onOrderSaved']
);

Method onOrderSaved extracts order data and forms request to amoCRM:

  1. Contact SearchGET /contacts?query={phone_or_email}. If found — use its ID. If not — create new.
  2. Deal CreationPOST /leads/complex with contact binding, name "Order #{ORDER_ID}", amount, UTM-tags in custom fields.

Order field mapping Bitrix → amoCRM:

Bitrix (order) amoCRM (deal) Field Type
PRICE (order amount) price Standard
STATUS_ID status_id (pipeline stage) Standard
Buyer first name + last name contacts[0].first_name/last_name Contact
Phone contacts[0].custom_fields (PHONE) Contact
Email contacts[0].custom_fields (EMAIL) Contact
Product list Note or amoCRM catalog Custom
UTM-tags (from cookie/properties) Deal custom fields Custom

UTM-tags — separate task. Bitrix out of box doesn't save UTM in order. Need to catch them on front (JavaScript), save in cookie or $_SESSION, and on order checkout write to properties (PROPERTY_UTM_SOURCE, PROPERTY_UTM_MEDIUM, etc.). From there — to deal custom fields in amoCRM.

Status Synchronization Back

amoCRM supports webhooks — on pipeline stage change, sends POST to specified URL. Create handler /local/tools/amocrm_webhook.php:

  1. Accept POST from amoCRM (array leads[status][0]).
  2. Extract deal id and status_id (pipeline stage ID).
  3. Find Bitrix order by deal id (via order custom field PROPERTY_AMO_LEAD_ID or mapping table).
  4. Update order status via \Bitrix\Sale\Order::load($orderId)setField('STATUS_ID', $mappedStatus)save().

Mapping of amoCRM funnel statuses → Bitrix order statuses stored in config: array [amo_status_id => bitrix_status_id].

Webhook Security: amoCRM doesn't sign requests. Verify sender IP (amoCRM IP list in docs) or use secret parameter in URL.

Site Form Processing

Feedback forms, callback, questions — all are leads. Two approaches:

  1. Via Bitrix Web Forms — handler OnAfterResultAdd (module form) or OnAfterFormResultAdd creates deal in amoCRM.
  2. Via amoCRM Forms — amoCRM JS-widget on site, data goes directly to CRM, bypassing Bitrix. Simpler but loses Bitrix connection.

Recommendation — first option. Data first saved in Bitrix (reliable storage), then async sent to amoCRM.

Queue and Error Handling

amoCRM API may be unavailable (HTTP 500, 429, network error). Put order/lead sending in queue:

  • Table amocrm_queue with fields id, type (lead/order/status), payload (JSON), attempts, status, last_error, created_at.
  • Agent or cron-script processes queue every minute. On error — increment attempts, if attempts > 5status = 'failed', notify.

Timelines

Stage Time
OAuth-integration + token storage 1 day
Order transmission → deals 2-3 days
Contacts: duplicate search + creation 1-2 days
UTM-tags: collection + transmission 1 day
Webhook reverse status sync 1-2 days
Forms → leads 1 day
Queue + error handling 1 day
Testing, edge cases 1-2 days
Total 1-2 weeks