> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/b2b/b2b-setup.md).

# Configuration Reference

This page lists every configuration that B2B needs on the B2B, Commerce and Omnitron sides, with the required values. To apply them in the right order, follow **Tutorials > B2B > How to Set Up B2B from Scratch**.

## <mark style="color:red;">Values Shared Across Systems</mark> <a href="#values-shared-across-systems" id="values-shared-across-systems"></a>

The following values must match on both sides. A mismatch is the most common reason why B2B can't create an order.

| Value                | B2B                                                                                                     | Commerce                                                  |
| -------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| Shared password      | `password` in the [`SHOP`](https://docs.akinon.com/pages/UNJjlWf2Aosk6sU0ZVi7#id-2.-shop) setting       | `password` in [`B2B_EXTENSION_CONF`](#b2b_extension_conf) |
| B2B API URL          | B2B application domain                                                                                  | `api_url` in [`B2B_EXTENSION_CONF`](#b2b_extension_conf)  |
| Storefront URL       | `url` in `SHOP`                                                                                         | Storefront domain                                         |
| Sales channel        | `channel_id` in [`OMNITRON_API`](https://docs.akinon.com/pages/UNJjlWf2Aosk6sU0ZVi7#id-1.-omnitron-api) | ID of the Commerce sales channel in Omnitron              |
| Shipping option slug | `shipping_option_slug` in `SHOP`                                                                        | Slug of the [B2B shipping option](#shipping-option)       |
| Payment option slug  | `payment_option_slug` in `SHOP`                                                                         | Slug of the [B2B payment option](#payment-option)         |

## <mark style="color:red;">B2B</mark> <a href="#b2b" id="b2b"></a>

### <mark style="color:red;">Configured During Installation</mark> <a href="#configured-during-installation" id="configured-during-installation"></a>

When B2B is installed from the ACC App Store, ACC saves the following [dynamic settings](https://docs.akinon.com/technical-guides/b2b/dynamic-settings.md). No manual action is needed.

| Setting                | Field                  | Value                                                        |
| ---------------------- | ---------------------- | ------------------------------------------------------------ |
| `OMNITRON_API`         | `api_url`              | Omnitron API address of the project, ending with `/api/v1/`. |
| `OMNITRON_API`         | `token`                | Omnitron token that B2B uses for every call to Omnitron.     |
| `OMNITRON_API`         | `channel_id`           | Commerce sales channel of the selected project.              |
| `OMNITRON_API`         | `application_id`       | ID of the B2B application in Omnitron.                       |
| `SHOP`                 | `url`                  | Storefront URL.                                              |
| `SHOP`                 | `shipping_option_slug` | `b2b`                                                        |
| `SHOP`                 | `payment_option_slug`  | `b2b`                                                        |
| `OMNITRON_API`, `SHOP` | `request_timeout`      | `30` seconds.                                                |

### <mark style="color:red;">Shared Password</mark> <a href="#shared-password" id="shared-password"></a>

The installation doesn't save the shared password. Add it as `password` to the [`SHOP`](https://docs.akinon.com/pages/UNJjlWf2Aosk6sU0ZVi7#id-2.-shop) setting in **B2B > Settings > Dynamic Settings** in Omnitron. B2B signs every order with it, and Commerce accepts B2B orders only when the signature matches the password in [`B2B_EXTENSION_CONF`](#b2b_extension_conf). Until it is added, every order fails.

### <mark style="color:red;">Notification Templates</mark> <a href="#notification-templates" id="notification-templates"></a>

B2B sends an email to the quotation owner for each of the following notification types. Each type has one template, managed in **B2B > Settings > Mailing Templates** in Omnitron or through the Notification Templates endpoints in **API Reference > B2B > B2B API**.

| Notification type              | Sent when                                                               |
| ------------------------------ | ----------------------------------------------------------------------- |
| `quotation_created`            | A quotation is created.                                                 |
| `quotation_updated`            | Headquarters adds a product to the quotation or removes one.            |
| `quotation_approval_requested` | Headquarters sends the edited quotation back to its owner for approval. |
| `quotation_approved`           | The quotation is approved.                                              |
| `quotation_rejected`           | The quotation is rejected.                                              |

If a type has no template, B2B creates one whose subject and body are only the type name. The texts are saved per language, and users receive emails in their own language.

## <mark style="color:red;">Commerce</mark> <a href="#commerce" id="commerce"></a>

### <mark style="color:red;">B2B\_EXTENSION\_CONF</mark> <a href="#b2b_extension_conf" id="b2b_extension_conf"></a>

Environment variable of the Commerce application. When it is set, Commerce serves the B2B API under the storefront's `/b2b/` path. The B2B payment rule and the B2B promotion gateway use its password and API address. A change takes effect after the Commerce application is redeployed.

| Field      | Required | Description                                                              |
| ---------- | -------- | ------------------------------------------------------------------------ |
| `api_url`  | Yes      | B2B API address. Must end with `/api/v1/`, including the trailing slash. |
| `password` | Yes      | Shared password. Must match `password` in the B2B `SHOP` setting.        |

```
B2B_EXTENSION_CONF={"api_url": "{b2b_api_url}", "password": "{shared_password}"}
```

The variable is also described in [Commerce environment variables](https://docs.akinon.com/pages/BbJsQTBycgR9Tyz5sUVK#id-81.-b2b_extension_conf).

### <mark style="color:red;">User Attribute Schema</mark> <a href="#user-attribute-schema" id="user-attribute-schema"></a>

B2B saves these attributes on every Commerce user that it creates or updates. The `/b2b/` proxy rejects users without `b2b_token` with `403 Forbidden`.

| Attribute           | Description                                           |
| ------------------- | ----------------------------------------------------- |
| `b2b_token`         | Token that links the Commerce user to their B2B user. |
| `division_erp_code` | ERP code of the user's division.                      |

```json
{
  "b2b_token": {
    "key": "b2b_token",
    "label": "B2B Token",
    "data_type": "text"
  },
  "division_erp_code": {
    "key": "division_erp_code",
    "label": "B2B Division ERP Code",
    "data_type": "text"
  }
}
```

* The attributes are added to the user schema through the Commerce API, because Omnitron forms don't show them. Updating the schema replaces it as a whole, so the existing attributes must be sent too.
* `is_editable_by_user` must not be `false` for these attributes, because B2B writes them on behalf of the user.
* B2B creates Commerce users through the storefront's registration. Extra mandatory registration fields or verification steps make B2B user creation fail.

### <mark style="color:red;">Promotion Gateway</mark> <a href="#promotion-gateway" id="promotion-gateway"></a>

Applies the discounts given on a quotation to its orders during order creation.

| Field                 | Value                                                                                                    |
| --------------------- | -------------------------------------------------------------------------------------------------------- |
| `name`                | `b2b`                                                                                                    |
| `gateway`             | `b2b`                                                                                                    |
| `is_active`           | `true`                                                                                                   |
| `conf.klass`          | `omnishop.promotions.backend.b2b.service.B2BPromotionService`                                            |
| `conf.offer_priority` | Higher than the priority of every other campaign, for example `9999`. If it is omitted, `10000` is used. |

```json
{
  "name": "b2b",
  "gateway": "b2b",
  "is_active": true,
  "conf": {
    "klass": "omnishop.promotions.backend.b2b.service.B2BPromotionService",
    "offer_priority": 9999
  }
}
```

B2B checks that the amount to pay in Commerce equals the quotation total. If another campaign changes the order total, or the gateway is missing or inactive so that the quotation discount isn't applied, the order fails with `UnpaidAmountCheck`.

### <mark style="color:red;">Shipping Option</mark> <a href="#shipping-option" id="shipping-option"></a>

The shipping option that B2B selects at checkout.

| Field           | Value                                                                                                |
| --------------- | ---------------------------------------------------------------------------------------------------- |
| `name`          | `b2b`                                                                                                |
| `slug`          | Same as `shipping_option_slug` in `SHOP` (`b2b` by default).                                         |
| `calculator`    | `free-calculator`                                                                                    |
| `delivery_type` | `standard`                                                                                           |
| `rule`          | Client Type Rule (`client-type-rule`) with the `b2b` client, so that only B2B orders see the option. |
| `is_active`     | `true`                                                                                               |

```json
{
  "name": "b2b",
  "slug": "b2b",
  "delivery_type": "standard",
  "is_active": true,
  "calculator": {
    "name": "Free Calculator",
    "slug": "free-calculator"
  },
  "rule": {
    "name": "Client Type Rule",
    "slug": "client-type-rule",
    "clients": ["b2b"]
  },
  "kwargs": {}
}
```

{% hint style="warning" %}
B2B 1.4.0 and earlier can't see this option when the brand has an active [segment](https://docs.akinon.com/technical-guides/commerce/user-segmentation-and-rules.md) whose rule checks the client type, and orders fail with `b2b shipping option is not found`. Later versions aren't affected.
{% endhint %}

### <mark style="color:red;">Payment Option</mark> <a href="#payment-option" id="payment-option"></a>

The payment option that B2B selects at checkout. Its [B2B payment rule](https://docs.akinon.com/technical-guides/commerce/payment-option-rules.md#b2bpaymentrule) shows the option only to orders signed with the shared password.

| Field               | Value                                                       |
| ------------------- | ----------------------------------------------------------- |
| `name`              | `b2b`                                                       |
| `slug`              | Same as `payment_option_slug` in `SHOP` (`b2b` by default). |
| `payment_type`      | `b2b`                                                       |
| `config.rule.klass` | `omnishop.payments.rules.B2BPaymentRule`                    |
| `is_active`         | `true`                                                      |

```json
{
  "name": "b2b",
  "slug": "b2b",
  "payment_type": "b2b",
  "is_active": true,
  "config": {
    "rule": {
      "klass": "omnishop.payments.rules.B2BPaymentRule",
      "params": {}
    }
  }
}
```

### <mark style="color:red;">Delivery Option</mark> <a href="#delivery-option" id="delivery-option"></a>

If the checkout has a delivery option selection step, B2B selects the active delivery option of type `customer` (delivery to an address). At least one such option must exist; otherwise, order creation fails with `Something went wrong`. B2B orders are delivered to the address of the ordering division.

## <mark style="color:red;">Omnitron</mark> <a href="#omnitron" id="omnitron"></a>

### <mark style="color:red;">Shipping Company</mark> <a href="#shipping-company" id="shipping-company"></a>

A shipping company for B2B orders, created in **Settings > Shipping Companies** in Omnitron. For the steps, see **Tutorials > Omnitron > Settings > How to Add and Configure a Shipping Company in Omnitron?**

| Field              | Value   |
| ------------------ | ------- |
| `name`             | `b2b`   |
| `erp_code`         | `b2b`   |
| `shipping_company` | `other` |

### <mark style="color:red;">Omnitron Token</mark> <a href="#omnitron-token" id="omnitron-token"></a>

B2B calls Omnitron with the token saved in `OMNITRON_API` to look up, activate and deactivate users, issue user tokens, and read products, stock and segments of the sales channel. The Omnitron user that owns the token must keep access to the sales channel.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.akinon.com/technical-guides/b2b/b2b-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
