> ## Documentation Index
> Fetch the complete documentation index at: https://guides.affiliate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert product barcodes to merchant-specific SKUs

> Look up the SKU a specific merchant uses for each barcode you provide. Requires a merchant name or URL in config. Returns null for unmatched barcodes.

The `POST /tools/convert/barcode-to-sku` endpoint converts barcodes to the internal SKUs used by a specific merchant. Because SKUs are merchant-specific, you must identify the merchant in the `config` object with every request.

## Endpoint

```
POST /v1/tools/convert/barcode-to-sku
```

## Request body

<ParamField body="data" type="array of strings" required>
  The barcodes to convert. Each element must be a valid numeric barcode string.
</ParamField>

<ParamField body="config" type="object" required>
  Configuration for the conversion. You must specify the target merchant.

  <Expandable title="config fields">
    <ParamField body="config.merchant.name" type="string">
      The merchant name (e.g. `"walmart"`). If you provide both `name` and `url`, only `name` is used.
    </ParamField>

    <ParamField body="config.merchant.url" type="string">
      The merchant domain (e.g. `"walmart.com"`). Used only when `name` is not provided.
    </ParamField>
  </Expandable>
</ParamField>

**Using merchant name:**

```json theme={null}
{
  "data": [
    "9349520733755",
    "648093563899",
    "1234567890123",
    "648093561147",
    "648093562182"
  ],
  "config": {
    "merchant": {
      "name": "walmart"
    }
  }
}
```

**Using merchant URL:**

```json theme={null}
{
  "data": ["9349520733755"],
  "config": {
    "merchant": {
      "url": "walmart.com"
    }
  }
}
```

## Example request

```bash theme={null}
curl --request POST \
  --url 'https://api.affiliate.com/v1/tools/convert/barcode-to-sku' \
  --header 'Authorization: Bearer {your_api_key}' \
  --header 'Content-Type: application/json' \
  --data '{
    "data": [
      "9349520733755",
      "648093563899",
      "1234567890123",
      "648093561147",
      "648093562182"
    ],
    "config": {
      "merchant": {
        "name": "walmart"
      }
    }
  }'
```

## Example response

```json theme={null}
{
  "meta": {
    "from": "barcode",
    "to": "sku",
    "from_total": 5,
    "to_total": 4,
    "config": {
      "merchant": {
        "name": "walmart"
      }
    },
    "trace_id": "0192e7de-ee66-72ad-9a8c-95f8055238da"
  },
  "data": {
    "9349520733755": "12987717129",
    "648093563899": "9853123116",
    "1234567890123": null,
    "648093561147": "9885868036",
    "648093562182": "9899956927"
  }
}
```

In this example, barcode `1234567890123` returns `null` because the merchant does not carry a product with that barcode.

## Response fields

### `meta` object

| Field        | Type    | Description                                          |
| ------------ | ------- | ---------------------------------------------------- |
| `from`       | string  | Always `"barcode"` for this endpoint.                |
| `to`         | string  | Always `"sku"` for this endpoint.                    |
| `from_total` | integer | Number of barcodes you submitted.                    |
| `to_total`   | integer | Number of barcodes that matched a SKU.               |
| `config`     | object  | The merchant config used in the request.             |
| `trace_id`   | string  | Unique request identifier for debugging and support. |

### `data` object

Each key is a barcode from your request. Each value is the merchant SKU string, or `null` if the merchant does not carry that product.

<ResponseField name="data" type="object">
  Key-value pairs where each barcode maps to a SKU string or `null`.
</ResponseField>
