> For the complete documentation index, see [llms.txt](https://support.gamoshi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.gamoshi.com/gamoshi-wiki/how-to-guides/how-to-map-schain-in-a-mapping-rule.md).

# How to map SCHAIN in a mapping rule

**Availability:** PE Enterprise accounts

## Overview

This article explains how to create a Mapping Rule to add or update the SCHAIN property in an RTB request.

Mapping Rules can be configured for an Advertiser or an Inventory.

***

## Requirements

To send an SCHAIN value to an Advertiser, make sure that the **Send Supply Chain** switch is enabled in the Advertiser’s **General Details** tab.

{% hint style="info" %}
**Important:** When a Mapping Rule is used to map an SCHAIN value, the mapped value overrides any SCHAIN value received from the Inventory partner.
{% endhint %}

***

## Configuring the SCHAIN Mapping Rule

The SCHAIN value entered in the Mapping Rule’s **To** field must be a serialized string enclosed in quotation marks (" ").

When uploading Mapping Rules using a CSV file, quotation marks are not required.

The value must contain:

* Your sellers.json domain.
* The publisher ID you want to send.

### Publisher ID Format

In the Gamoshi platform, the publisher ID is created from the customer number and Business Partner ID using the following format:

```
<customer number>-b<business partner ID>
```

For example, if the customer number is 200 and the Business Partner ID is 1122, the Inventory publisher ID is:

```
200-b1122
```

***

## SCHAIN Value Examples

### Standard Gamoshi Publisher ID

If the sellers.json domain is test.io and the publisher ID is 200-b1122, enter:

```
"1.0,1!test.io,200-b1122,1"
```

### Legacy Seller ID

If you use legacy seller IDs instead of Gamoshi Business Partner IDs, enter the legacy seller ID in the SCHAIN value.

For example, for the sellers.json domain test.io and legacy seller ID 12345, enter:

```
"1.0,1!test.io,12345,1"
```

### Short Format

You can also enter a shorter value containing only the sellers.json domain and seller ID.

For a standard Gamoshi publisher ID:

```
"test.io,200-b1122"
```

For a legacy seller ID:

```
"test.io,12345"
```

***

## Understanding SCHAIN Serialization

The serialized SCHAIN value contains two components:

1. SupplyChainObject properties.
2. A SupplyChainNode array.

The components are separated by a bang (!) character:

```
{SupplyChainObject}!{SupplyChainNode array}
```

### SupplyChainObject Properties

The SupplyChainObject contains two properties:

* ver
* complete

These values appear at the beginning of the serialized string and are separated by a comma:

```
ver,complete
```

### SupplyChainNode Properties

Each SupplyChain node contains properties in the following order:

```
asi,sid,hp,rid,name,domain,ext
```

Properties within a node are separated by commas. When the SCHAIN contains multiple nodes, each node is separated by a bang (!) character.

The contents of the ext property are exchange-specific. This article does not define how values within this object should be serialized.

Optional SupplyChainNode values can be omitted. Trailing separators can also be excluded.

For example, both of the following values are valid:

```
exampleexchange.com,12345,1,,,
```

```
exampleexchange.com,12345,1
```

### URL Encoding

If a property value contains a comma, a bang character, or another value that requires URL encoding, encode the property value according to RFC 3986.

Do not encode the commas used to separate SCHAIN properties.

For example:

```
exampleexchange.com,123%2CB,1,,,
```

In this example, the seller ID is 123,B, and exampleexchange.com is the entity responsible for payment.

***

## Complete Serialization Example

The following SupplyChain object:

```json
{
  "ver": "1.0",
  "nodes": [
    {
      "asi": "exchange1.com",
      "domain": "publisher.com",
      "name": "publisher",
      "hp": 1,
      "rid": "bid-request-1",
      "sid": "1234"
    },
    {
      "asi": "exchange2.com",
      "hp": 1,
      "sid": "abcd"
    },
    {
      "asi": "example.com",
      "hp": 1,
      "sid": "091381"
    },
    {
      "asi": "lastexchange.com",
      "hp": 1,
      "sid": "22"
    }
  ],
  "complete": 1
}
```

Is serialized in the supply tag URL as:

```
schain=1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com!exchange2.com,abcd,1,,,!example.com,091381,1,,,!lastexchange.com,22,1,,,
```

***

## Related articles

* [Mapping rules](/gamoshi-wiki/general-information/mapping-rules.md)
* [Inventory Incoming Request Workflow Overview](/gamoshi-wiki/general-information/inventory-incoming-request-workflow-overview.md)
* [Business Partners](/gamoshi-wiki/core-entities/business-partners.md)
