This project helps developers build Bitrix24 applications with help from AI agents. It ships with a preconfigured code base plus a modular instruction system that explains how to extend the starter safely.
You act as the expert developer working on top of this repository: https://github.com/bitrix-tools/b24-ai-starter.
- Three backend options (PHP, Python, Node.js)
- Nuxt 3 frontend with Bitrix24 UI Kit already wired up
- Background workers for async workloads
- Docker containers for quick bootstrap
- SDK bundles & shared utilities for Bitrix24 API calls
- Makefile with day-to-day commands
- Documented API endpoints
- π Modular instructions for AI agents in
instructions/ - β»οΈ Versioning support via
scripts/create-version.shand the extendeddev-initwizard - π Authentication & security out of the box
- π¨ Bitrix24 UI Kit & JS SDK integration
- π RabbitMQ service with stack-specific recipes
Need another backend stack? Create a folder under backends/ that follows the same structure and register it in Docker Compose.
-
π Central knowledge hub:
instructions/knowledge.mdβ language-agnostic entry point that links to specialized guides. -
ποΈ Modular layout:
instructions/
βββ knowledge.md # π― Start here
βββ php/knowledge.md # π PHP-specific guidance
βββ python/knowledge.md # π Python-specific guidance
βββ node/knowledge.md # π’ Node.js-specific guidance
βββ queues/ # π Queues & background jobs
βββ frontend/knowledge.md # π¨ Frontend guidance
βββ bitrix24/ # π’ Platform specifics
βββ versioning/ # β»οΈ Version management
βββ [stack]/[topic].md # π Deep dives
- π‘ Reading workflow
- Start with
knowledge.md. - Pick the technology stack.
- Read
[stack]/knowledge.mdfor language-specific tips. - Open specialized files only when necessary.
- Start with
- π Agent prompt:
instructions/versioning/create-version-prompt.mdβ explains how to βcreate V2β, verify it, and switch versions. - π Create:
./scripts/create-version.sh v2clones the current project intoversions/v2and writesAPP_VERSION=v2to.env. - π Make shortcuts:
make create-version VERSION=v2andmake delete-version VERSION=v2proxy the scripts (interactive whenVERSIONis omitted). - π Delete:
./scripts/delete-version.sh v2removesversions/v2and clearsAPP_VERSIONif needed. - π Pick a copy:
make dev-initcan listversions/*and let you choose, or runDEV_INIT_VERSION=v2 make dev-init/./scripts/dev-init.sh --version v2. - π§Ή Git hygiene:
versions/is tracked by default. Add it to.gitignoreif a copy should stay local.
- Required scopes:
crm,user_brief,pull,placement,userfieldconfig - Tooling: Ngrok for public HTTPS tunnels, Docker for container orchestration
b24-ai-starter/
βββ frontend/ # Nuxt 3 + Bitrix24 UI Kit
βββ backends/
β βββ php/ # Symfony + Bitrix24 PHP SDK
β βββ python/ # Django + b24pysdk
β βββ node/ # Express + Bitrix24 JS SDK
βββ infrastructure/
β βββ database/ # PostgreSQL init scripts
βββ instructions/ # π Modular AI guidance
β βββ knowledge.md
β βββ php/ | python/ | node/
β βββ frontend/
β βββ versioning/
β βββ queues/
β βββ bitrix24/
βββ logs/
βββ versions/
βββ README.md # π€ Main AI prompt
βββ docker-compose.yml
The starter already contains a working Bitrix24 app stub suitable for local development or marketplace-ready distribution.
-
Run the automatic initialization described below. It provisions an Ngrok domain, launches Docker, and configures
.env. To verify the setup, open the technical domain in a regular browser β youβll see an error in the browser stating that the page must be opened inside Bitrix24. That means everything is configured, but the app still needs Bitrix24 authorization tokens. -
Register the technical domain in your Bitrix24 portal settings or via https://vendors.bitrix24.com to continue development/testing.
- Main URL:
[technical-domain]/ - Install URL:
[technical-domain]/install - Scopes:
crm,user_brief,pull,placement,userfieldconfig
- Main URL:
-
After adding the app youβll get
CLIENT_IDandCLIENT_SECRET. Put them into.env, then restart containers (make down && make dev-php, ormake dev-python/make dev-node). -
Reinstall the app inside your portal to refresh tokens.
You can now build on top of the starter kit.
make dev-initThe wizard will:
- Ask for the Ngrok authtoken
- Let you choose PHP/Python/Node backend
- Remove unused backend folders
- Configure environment variables
- Request a public Ngrok domain
- Launch Docker containers
cp .env.example .env
# PHP backend
make dev-php
# Python backend
make dev-python
# Node.js backend
make dev-node
# Stop everything
make down
# Production targets
make prod-php
make prod-python
make prod-node
# DB + frontend only
COMPOSE_PROFILES= docker-compose up database frontend
# Full stack
COMPOSE_PROFILES=php,worker docker-compose up -dConfigure these variables before going live:
JWT_SECRETβ JWT encryption between frontend and backendDB_USER,DB_PASSWORD,DB_NAMEβ PostgreSQL credentialsBUILD_TARGET=productionβ Nuxt prod buildDJANGO_SUPERUSER_USERNAME,DJANGO_SUPERUSER_EMAIL,DJANGO_SUPERUSER_PASSWORDβ required for the Python backend
- Nuxt 3 (Vue 3, TypeScript)
- Bitrix24 UI Kit (
@bitrix24/b24ui-nuxt) - Bitrix24 JS SDK (
@bitrix24/b24jssdk-nuxt) - Pinia, Vue I18n, TailwindCSS
- PHP: Symfony 7, Doctrine ORM, Bitrix24 PHP SDK
- Python: Django, Bitrix24 Python SDK
- Node.js: Express,
pg, JWT, Bitrix24 JS SDK
- Docker & Docker Compose
- PostgreSQL 17
- Ngrok (public HTTPS tunnel)
- Nginx (production ingress)
- PHP: if
api-phpfails on Windows, resavebackends/php/docker/php-fpm/docker-entrypoint.sh. - Python: Django admin lives at
https://<VIRTUAL_HOST>/api/admin(DJANGO_SUPERUSER_*from.env).
- Run
make security-scanβ executesscripts/security-scan.sh. - PHP audit:
composer audit --locked --format=jsonin thephp-clicontainer. - Frontend audit:
pnpm audit --prod --jsonin thefrontendcontainer. - Reports land in
reports/security/php-composer.jsonandreports/security/frontend-pnpm.json. - Non-zero exit when vulnerabilities are detected. Override via
SECURITY_SCAN_ALLOW_FAILURES=1 make security-scanor./scripts/security-scan.sh --allow-fail. - Nothing runs automatically; add the command to local checklists or CI manually.
make security-testsrunsscripts/security-tests.sh, launching dependency audits, static analyzers and generic scanners (Semgrep OWASP Top 10, Gitleaks, Trivy) inside Docker.- The script auto-detects active backend (PHP/Python/Node) and the frontend, so no manual selection is required.
- Profiles:
quick(default) β dependency audit + Semgrep.fullβ quick profile plus phpstan/bandit/eslint, Gitleaks and Trivy.customβ interactive step selection.
- In interactive mode findings are reported as warnings so newcomers see results without stopping the flow; in
--cimode the same steps fail the run. - Reports are placed in
reports/security/<timestamp>/.... Strict CI mode is enabled via--ci, and--allow-faillets the script exit with 0 even if steps fail. - You can pass parameters via make:
make security-tests SECURITY_TESTS_ARGS="--profile full --allow-fail".
- Run
make security-scanto executescripts/security-scan.sh. - The script runs
composer audit --locked --format=jsoninside thephp-clicontainer ifbackends/phpexists. - For the frontend it executes
pnpm audit --prod --jsonin thefrontendcontainer. - JSON reports go to
reports/security/php-composer.jsonandreports/security/frontend-pnpm.json. - By default the script exits with a non-zero code when vulnerabilities are found; enable βsoft modeβ with
SECURITY_SCAN_ALLOW_FAILURES=1 make security-scan(or./scripts/security-scan.sh --allow-fail) to always exit with 0. - The command runs on demand, so you can add it to local release checklists or call it in CI manually.
make dev-initcan automatically enable RabbitMQ and store credentials in.env.- Broker endpoints: AMQP
5672, management UI15672(profilequeue). - Manual control:
make queue-up,make queue-down. - Detailed guides:
- Service & env vars β
instructions/queues/server.md - PHP + Messenger β
instructions/queues/php.md - Python + Celery β
instructions/queues/python.md - Node.js + amqplib β
instructions/queues/node.md
- Service & env vars β
- Bitrix24 JS SDK: use
@bitrix24/b24jssdk-nuxt, seeinstructions/frontend/bitrix24-js-sdk.md. - Bitrix24 UI Kit: use
@bitrix24/b24ui-nuxt, seeinstructions/frontend/bitrix24-ui-kit.md. - PHP SDK: see
instructions/php/bitrix24-php-sdk.md. - Python SDK (b24pysdk): see
instructions/python/bitrix24-python-sdk.md.
Every endpoint except /api/install and /api/getToken requires:
Authorization: `Bearer ${tokenJWT}`- App installation (
/api/install)- Receives Bitrix24 data (
DOMAIN,AUTH_ID,REFRESH_TOKEN,member_id,user_id, etc.) - Stores installation info
- No JWT required
- Receives Bitrix24 data (
- Issue token (
/api/getToken)- Accepts Bitrix24 auth payload
- Generates a JWT (TTL = 1 hour)
- Binds a Bitrix24 account
- No JWT required
- Protected endpoints
- Validate JWT via middleware/decorators
- Extract
bitrix24_account - Use SDK to call Bitrix24 API
All protected requests must include a JWT header:
const { data, error } = await $fetch('/api/protected-route', {
method: 'GET',
headers: { Authorization: `Bearer ${someJWT}` }
});- Responses are JSON.
- Errors use HTTP status
401,404, or500and return{ "error": "Internal server error" }.
- Method: GET
- Response:
{ status: string, backend: string, timestamp: number } - Curl:
curl http://localhost:8000/api/health
- Method: GET
- Response:
string[] - Curl:
curl http://localhost:8000/api/enum
- Method: GET
- Response:
string[] - Curl:
curl http://localhost:8000/api/list
- Method: POST
- Payload:
DOMAIN,PROTOCOL,LANG,APP_SID,AUTH_ID,AUTH_EXPIRES,REFRESH_ID,member_id,user_id,PLACEMENT,PLACEMENT_OPTIONS - Response:
{ message: string }
curl -X POST http://localhost:8000/api/install \
-H "Content-Type: application/json" \
-d '{"AUTH_ID":"27exx66815","AUTH_EXPIRES":3600,"REFRESH_ID":"176xxxe","member_id":"a3xxx22","user_id":"1","PLACEMENT":"DEFAULT","PLACEMENT_OPTIONS":"{\"any\":\"6\/\"}"}'- Method: POST
- Payload: same as installation
- Response:
{ token: string }
curl -X POST http://localhost:8000/api/getToken \
-H "Content-Type: application/json" \
-d '{"AUTH_ID":"27exx66815","AUTH_EXPIRES":3600,"REFRESH_ID":"176xxxe","member_id":"a3xxx22","user_id":1}'PHP (Symfony):
#[Route('/api/my-endpoint', name: 'api_my_endpoint', methods: ['GET'])]
public function myEndpoint(Request $request): JsonResponse
{
$jwtPayload = $request->attributes->get('jwt_payload');
return new JsonResponse(['data' => 'value']);
}Python (Django):
@xframe_options_exempt
@require_GET
@log_errors("my_endpoint")
@auth_required
def my_endpoint(request: AuthorizedRequest):
client = request.bitrix24_account.client
response = client._bitrix_token.call_method(
api_method='method.name',
params={'param': 'value'}
)
return JsonResponse({'data': 'value'})Node.js (Express):
app.get('/api/my-endpoint', verifyToken, async (req, res) => {
const jwtPayload = req.jwtPayload;
res.json({ data: 'value' });
});app/pages/β pages (index.client.vue,install.client.vue, other*.client.vuefiles)app/stores/β Pinia stores (api.ts,user.ts,appSettings.ts,userSettings.ts)app/composables/β shared logic (useAppInit.ts,useBackend.ts)app/middleware/01.app.page.or.slider.global.tsβ initializes the B24 frame for every pageapp/layouts/βdefault.vue,placement.vue,slider.vue,uf-placement.vue
const { $initializeB24Frame } = useNuxtApp()
const $b24: B24Frame = await $initializeB24Frame()
const batch = await $b24.callBatch({
appInfo: { method: 'app.info' },
profile: { method: 'profile' }
})
const data = batch.getData()
const result = await $b24.callMethod('method.name', { param: 'value' })
const authData = $b24.auth.getAuthData()
await $b24.slider.openPath('/path/to/page')const apiStore = useApiStore()
await apiStore.init($b24)
const list = await apiStore.getList()
const enumData = await apiStore.getEnum()
const myMethod = async (): Promise<MyType> => {
return await $api('/api/my-endpoint', {
headers: { Authorization: `Bearer ${tokenJWT.value}` }
})
}Components from @bitrix24/b24ui-nuxt are available automatically:
<template>
<B24Card>
<template #header>
<h1>Title</h1>
</template>
<B24Button
label="Action"
color="air-primary"
@click="handleClick"
/>
<B24Input
v-model="inputValue"
placeholder="Type here"
/>
<B24Badge
label="Status"
color="air-primary-success"
/>
<B24Avatar
:src="photoUrl"
size="md"
/>
</B24Card>
</template>If your feature involves widgets, events, or robots, review these docs first.
Widgets
Events
- API reference
- Register via
event.bindduring installation - Handle data at
/api/app-events(public endpoint, no JWT) - Support both
application/x-www-form-urlencodedand JSON
Robots
- Instruction
- Register via
bizproc.robot.add - Handle data at
/api/robot-handler(public endpoint, no JWT) - Accept every payload format Bitrix24 may send
Implementation tips
- Public endpoints donβt require JWT.
- Support both form-urlencoded and JSON payloads.
- Build proper
OAuthPlacementDatafor the SDK. - Register everything during installation (
install.client.vue).
Backend guides
- π PHP Knowledge β plus PHP SDK and Code Review
- π Python Knowledge β plus Python SDK and Code Review
- π’ Node.js Knowledge β plus Code Review
Frontend guides
- π¨ Frontend Knowledge β plus UI Kit, JS SDK, and component recipes inside
instructions/front/
Platform guides
- π’ Bitrix24 Platform β see CRM robots and Widgets
- Backend endpoint
- Add a controller/view handler
- Use middleware/decorators for authentication
- Return JSON
- Frontend API method
- Extend
app/stores/api.ts - Use
$apiwith a JWT header - Handle errors centrally
- Extend
- Frontend page/component
- Create
.vuefiles underapp/pages/orapp/components/ - Use Bitrix24 UI Kit components
- Connect to the API store
- Create
- Error handling
- Use
processErrorGlobalfromuseAppInit - Log via
$logger - Return actionable server errors
- Use
- Typing
- Use TypeScript interfaces
- Rely on
AuthorizedRequestin Python and JWT payloads in PHP/Node
- State
- Keep global state in Pinia
- Use Vue 3 Composition API reactivity
- Cache data where it makes sense
- Performance
- Use batch REST calls when possible
- Lazy-load heavy components
- Optimize images and assets
This starter kit exists to help AI agents build Bitrix24 apps faster. You can:
- Use the documentation to brief AI agents.
- Extend SDK samples.
- Add new backends under
backends/. - Improve documentation and instructions.
Important reminders for AI agents
- Respect the architecture of the chosen backend (PHP/Python/Node.js).
- Follow established project patterns.
- Use Bitrix24 UI Kit components on the frontend.
- Handle errors and typing properly.
- Match the projectβs coding style.
Licensed under MIT. See LICENSE for details.