# Step-by-step scenarios (/en/docs/b24/scenarios)

Each scenario is a common task in order: the commands to run, why each one runs and what to look at in the answer. The same scenarios are in the terminal: `b24 guide` lists them and `b24 guide <name>` prints one.

Commands that use an account start with your profile, the name you gave the account at login: `b24 <profile> …`.

## First sync and the pipeline board [#first-sync-and-the-pipeline-board]

Copy your deals and leads into the local store and see where each one stands.

1. ```sh
   b24 session start
   ```

   paste the portal's incoming webhook address; it is checked against the portal and kept in the keyring

2. ```sh
   b24 session status --check
   ```

   the employee the webhook acts as, and whether they are a Bitrix24 administrator

3. ```sh
   b24 users list
   ```

   your own user id and the ids of the colleagues whose deals you want

4. ```sh
   b24 config set crm.bitrix24:example.bitrix24.ru.unassigned 1
   ```

   whose deals and leads to copy, by user id, comma-separated, with your portal's host in place of example.bitrix24.ru; until you choose, a sync copies nothing

5. ```sh
   b24 sync
   ```

   copies the chosen users' deals and leads and their clients; the next sync takes only the changes

6. ```sh
   b24 pipelines show Sales
   ```

   the pipeline as a board, how many deals stand in each stage and how many reached it

7. ```sh
   b24 deals list status:open
   ```

   the open deals with stage, amount and owner, from the store, offline too

What to look at:

- scope in the sync answer, which says whose deals and leads it copied
- issues in the sync answer, such as a user it could not take or a scope the webhook lacks
- the stage where most deals wait

`example.bitrix24.ru` stands for your portal's host, and `1` for the ids you chose. A webhook is often a colleague's,
so b24 never picks whose deals you copy.

In the terminal: `b24 guide first-sync`

<a id="keep-in-sync" />

## Keep the copy up to date [#keep-the-copy-up-to-date]

Have the local store follow the portal on its own, and search it beside your other WireCat tools.

1. ```sh
   b24 schedule command crm --every 1h -- sync
   ```

   a timer on this computer that runs sync every hour; it reads only what changed

2. ```sh
   b24 schedule list
   ```

   the schedule, when it runs next and how its last run went

3. ```sh
   b24 store status
   ```

   how far each kind's sync is, how many records are stored and when it last ran

4. ```sh
   b24 search all kitchen
   ```

   stored deals and leads beside your messages, notes and meetings from other WireCat tools

What to look at:

- a schedule whose last run failed
- a kind in store status that is partial, which the next sync goes on with

In the terminal: `b24 guide keep-in-sync`

<a id="safe-agent-writes" />

## Let an agent change the CRM without surprises [#let-an-agent-change-the-crm-without-surprises]

Give an agent your CRM over MCP while the writes that reach clients or cannot be undone stay yours.

1. ```sh
   b24 config set permissions.deals.move readonly
   ```

   a stage change can start the portal's robots, which write to clients; over MCP ask does not ask, so ask stops nothing there

2. ```sh
   b24 config set permissions.deals.delete deny
   ```

   no agent deletes a deal, whatever it is asked

3. ```sh
   b24 mcp add claude-code --permission leads.delete=deny --allow-writes
   ```

   add this profile to Claude Code; this server also refuses lead deletes, and --allow-writes acknowledges the writes it still offers

4. ```sh
   b24 config show
   ```

   each permission with its level and where it came from

5. ```sh
   b24 runs list
   ```

   what the agent ran, refused writes too

What to look at:

- the levels of deals.move, deals.delete and leads.delete in config show
- refused runs in runs list, and which command asked

At a terminal `ask` still asks before the write. Over MCP nobody is there to answer, so a write at `ask` goes ahead;
set `readonly` or `deny`, or turn on approval of `b24_write` in the agent client.

In the terminal: `b24 guide safe-agent-writes`
