> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/flows/remote-attribute-based-shipping-flows.md). Agents can also search and read this documentation through its [MCP server](https://apidocs.akinon.com/~gitbook/mcp).

# Remote Attribute Based Shipping Flows

This part of the document describes the remote service that powers **Remote Attribute Based Shipping Options**. During checkout, Commerce calls this service to learn how the quantities of each basket line should be **split into delivery groups** (for example `express`, `standart`, `global`). The number of groups is **not fixed** — Commerce uses exactly the groups the service returns.

The basket is **never mutated**: the split returned here is ephemeral and is materialized into separate shipping groups only when the order is created.

2 configuration parameters will be shared during integration:

| username | Username for basic authentication |
| -------- | --------------------------------- |
| password | Password for basic authentication |

These credentials, together with the service base URL, are configured on the Commerce side through the `REMOTE_ATTRIBUTE_BASED_SHIPPING_OPTION_PROVIDER` dynamic setting.

### attribute-based-shipping-groups (POST)

This service returns the delivery-group allocation for the current basket. It is called after the shipping address is selected and before the shipping options are presented to the customer.

**URL**

```
^^/attribute-based-shipping-groups
```

**Request Headers**

| x-akinon-request-id  | Unique ID for problem solving & tracing.    | Mandatory |
| -------------------- | ------------------------------------------- | --------- |
| x-akinon-api-version | Akinon Customer API version.                | Mandatory |
| Authorization        | Basic \[BASE64\_encoded(username:password)] | Mandatory |

**Request Body raw (json)**

```json
{
  "basket": {
    "pk": 12345,
    "version": "3",
    "currency": "try",
    "totalAmount": "749.70",
    "basketItems": [
      {
        "pk": 30928,
        "version": "1",
        "quantity": 7,
        "price": "107.10",
        "totalAmount": "749.70",
        "product": {
          "pk": 30928,
          "name": "Decorative Object",
          "sku": "8KKST6560XSTDSTD",
          "price": "107.10",
          "attributes": { "is_global": "false", "brand": "Acme" },
          "stock": { "extra_field": { "warehouse_stock": 3, "store_stock": 4 } }
        }
      }
    ],
    "discounts": []
  },
  "shippingAddress": {
    "shipmentId": "9876",
    "locale": "tr_TR",
    "deliveryNote": "",
    "type": "customer",
    "destination": {
      "name": "",
      "surname": "",
      "tel": "",
      "country": { "id": 1, "code": "tr", "name": "Türkiye" },
      "city": { "id": 34, "name": "İstanbul" },
      "district": { "id": 456, "name": "Kadıköy" },
      "township": { "id": 789, "name": "Moda" },
      "zipcode": "34710",
      "addressLine": ""
    }
  },
  "segment": {
    "name": "B2B",
    "price_list_id": 7,
    "stock_list_id": 9
  }
}
```

| basket.basketItems\[].pk                         | Akinon basket item id. Use this id when returning the allocation.                                                                                                                                                                                                |
| ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| basket.basketItems\[].sku                        | Product SKU; use it to look up stock locations / global products.                                                                                                                                                                                                |
| basket.basketItems\[].quantity                   | Total quantity of the line in the basket.                                                                                                                                                                                                                        |
| basket.basketItems\[].product.attributes         | Product attributes (key/value), e.g. to detect global products.                                                                                                                                                                                                  |
| basket.basketItems\[].product.stock.extra\_field | `extra_field` of the stock record the line resolves to — the per-stock-list `ExtraProductStock` when the checkout uses a stock list, otherwise the default `ProductStock`. Use it to split the line across stock locations. `{}` when the stock record has none. |
| shippingAddress.destination                      | Full shipping address for location-aware allocation.                                                                                                                                                                                                             |
| segment.name                                     | Name of the active customer segment (`null` if none).                                                                                                                                                                                                            |
| segment.price\_list\_id                          | Price list id used for this checkout (segment or default inventory strategy).                                                                                                                                                                                    |
| segment.stock\_list\_id                          | Stock list id used for this checkout — use it to resolve per-location stock.                                                                                                                                                                                     |

**Response Body raw (json)**

The service returns a list of `groups`. Each group has a `attributeValue` (the group label, e.g. `express`) and an `allocation` that lists, per basket item, how many units belong to that group. The sum of a basket item's quantities across all groups must equal that item's `quantity`.

```json
{
  "groups": [
    {
      "attributeValue": "express",
      "allocation": [
        { "basketItemPk": 30928, "quantity": 4 }
      ]
    },
    {
      "attributeValue": "standart",
      "allocation": [
        { "basketItemPk": 30928, "quantity": 3 }
      ]
    }
  ]
}
```

| groups\[].attributeValue             | Group label. Commerce maps it to the shipping options configured for that group (see the guide). |
| ------------------------------------ | ------------------------------------------------------------------------------------------------ |
| groups\[].allocation\[].basketItemPk | The `pk` of a basket item from the request.                                                      |
| groups\[].allocation\[].quantity     | Number of units of that basket item that belong to this group. Must be `>= 1`.                   |

**Notes**

* **Global products** (separated by SKU / product attribute) can be placed wholly into a dedicated group (for example `global`); their import fee is handled separately by Commerce through the extra-fee configuration.
* **Express / Standard** typically split the same SKU by stock location (store vs. warehouse), so a single line can appear in more than one group (e.g. 4 units `express` + 3 units `standart`).
* **Consistency:** for every basket item, `sum(allocation.quantity) == quantity`. If a line's allocation is inconsistent (or the line is a bundle / mergeable line that must not be split), Commerce keeps it whole in a single group.
* **Availability:** if the service is unreachable, times out, or returns an invalid body, Commerce falls back to a single group so checkout is not interrupted.
* **Caching:** Commerce caches a successful response for \~15 minutes while the basket (its version) and shipping address are unchanged; any basket change (add/remove/quantity) invalidates it. Empty/failed responses are not cached.


---

# 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://apidocs.akinon.com/flows/remote-attribute-based-shipping-flows.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.
