For AI agents: markdown of this page — /docs-content-en/entities/crm-forms/embedding.md documentation index — /llms.txt
Get form embedding codes
GET /v1/crm-forms/:id/embedding
Returns HTML code for embedding a form in a page (inline), opening it on click (click), or displaying it after a delay (auto). Without variant, returns all three variants, their settings, and the public form URL. Query overrides affect the generated code without saving the settings.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Parameterid (path) |
Typenumber | Requiredyes | DescriptionPositive form ID from List forms |
Parametervariant (query) |
Typestring | Requiredno | Descriptioninline, click, auto. Omit to get all variants |
ParameterbuttonText (query) |
Typestring | Requiredno | DescriptionButton caption, only with variant=click |
ParameterbuttonType (query) |
Typestring | Requiredno | Descriptionbutton or link, only with variant=click |
Parameterdelay (query) |
Typeinteger | Requiredno | DescriptionDelay in seconds, only with variant=auto. Passing it with another variant or without a variant returns 400 INVALID_PARAMS |
Examples
curl — personal key
curl "https://vibecode.bitrix24.com/v1/crm-forms/59/embedding?variant=auto&delay=7" \
-H "X-Api-Key: YOUR_API_KEY"
curl — OAuth application
curl "https://vibecode.bitrix24.com/v1/crm-forms/59/embedding?variant=auto&delay=7" \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN"
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-forms/59/embedding?variant=auto&delay=7', {
headers: {
'X-Api-Key': 'YOUR_API_KEY',
},
})
const { success, data } = await res.json()
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-forms/59/embedding?variant=auto&delay=7', {
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
},
})
const { success, data } = await res.json()
Response fields
| Field | Type | Description |
|---|---|---|
Fieldsuccess |
Typeboolean | Descriptiontrue on success |
Fielddata |
Typeobject | DescriptionComplete embedding settings without variant, or {variant, code} when it is set |
Fielddata.formActive |
Typeboolean | DescriptionWhether the form is active |
Fielddata.resourcesReady |
Typeboolean | DescriptionWhether form resources are ready |
Fielddata.publicUrl |
Typestring | DescriptionPublic form URL, including its public signature |
Fielddata.inline |
Typeobject | DescriptionForm embedded in the page |
Fielddata.click |
Typeobject | DescriptionForm opened on click |
Fielddata.auto |
Typeobject | DescriptionForm opened after a delay |
Fielddata.<variant>.code |
Typestring | DescriptionHTML embed code, returned unchanged |
Fielddata.<variant>.previewUrl |
Typestring | DescriptionPreview URL, returned unchanged |
Fielddata.<variant>.settings |
Typeobject / null | DescriptionCurrent settings listed in Update embedding settings. inline has null |
Fielddata.<variant>.options |
Typeobject / null | DescriptionAllowed values for the variant settings. inline has null |
Fielddata.<variant>.options.type |
Typestring[] | Descriptionpopup, panel |
Fielddata.<variant>.options.position |
Typestring[] | Descriptionleft, center, right |
Fielddata.<variant>.options.vertical |
Typestring[] | Descriptionbottom, top |
Fielddata.click.options.button.font |
Typestring[] | Descriptionmodern, classic, elegant |
Fielddata.click.options.button.align |
Typestring[] | Descriptioninline, left, center, right |
Fielddata.auto.options.delay |
Typenumber[] | Description3, 5, 7, 10, 15, 20, 25, 30, 40, 60, 120 |
Fielddata.variant |
Typestring | DescriptionSelected variant, only when variant is set |
Fielddata.code |
Typestring | DescriptionEmbed code for the selected variant, only when variant is set |
Response example
Response for variant=auto&delay=7. Public domains and signatures in this example are placeholders.
{
"success": true,
"data": {
"variant": "auto",
"code": "<script id=\"bx24_form_delay\" data-skip-moving=\"true\">\n\t(function(w,d,u,b){w['Bitrix24FormObject']=b;w[b] = w[b] || function(){arguments[0].ref=u;\n\t\t(w[b].forms=w[b].forms||[]).push(arguments[0])};\n\t\tif(w[b]['forms']) return;\n\t\tvar s=d.createElement('script');s.async=1;s.src=u+'?'+(1*new Date());\n\t\tvar h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);\n\t})(window,document,'https://example.bitrix24.com/bitrix/js/crm/form_loader.js','b24form');\n\n\tb24form({\"id\":59,\"lang\":\"ru\",\"sec\":\"p4yyaj\",\"type\":\"delay\",\"delay\":7});\n</script>"
}
}
Error response example
400 — unsupported variant:
{
"success": false,
"error": {
"code": "INVALID_PARAMS",
"message": "variant must be inline, click or auto"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | CodeINVALID_PARAMS |
DescriptionInvalid form ID or request structure |
| HTTP400 | CodeUNKNOWN_FILTER_FIELD |
DescriptionUnknown query parameter |
| HTTP400 | CodeINVALID_PARAMS |
DescriptionAn override is used with the wrong variant, or its value is rejected. Field diagnostics are returned in error.validation |
| HTTP404 | CodeENTITY_NOT_FOUND |
DescriptionForm not found |
| HTTP403 | CodeSCOPE_DENIED |
DescriptionAPI key lacks the crm scope |
| HTTP403 | CodeBITRIX_ACCESS_DENIED |
DescriptionUser lacks access |
| HTTP403 | CodeCRM_FORM_ACCESS_DENIED |
DescriptionForm access is denied |
| HTTP401 | CodeTOKEN_MISSING |
DescriptionAPI key has no configured credentials |
| HTTP502 | CodeBITRIX_UNAVAILABLE |
DescriptionInvalid embedding response |
For common API errors, see Errors.
Known specifics
Copy the returned HTML code and public URLs with their public signatures unchanged.