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

# Generate Barcode

> Generate a unique barcode for a product variant

<Note>
  **V2 Preview** — This endpoint is part of the V2 API preview. Breaking changes may occur.
</Note>

## Overview

Generate a unique barcode using the shop's barcode configuration (type, prefix, and length). The barcode is validated for uniqueness against Shopify before being returned, so you can safely assign it to a variant without collisions.

This endpoint requires the barcode feature to be enabled by the merchant in shop settings.

### Use Cases

* Auto-generate barcodes when creating new product variants
* Replace missing barcodes on existing variants
* Generate barcodes in bulk for inventory labeling

### Required Scope

`products:write`

## Request Body

No request body is required. The barcode format (type, prefix, length) is determined by the shop's barcode configuration.

## Response

```json 200 theme={null}
{
  "success": true,
  "data": {
    "barcode": "PV10038472"
  }
}
```

```json 400 theme={null}
{
  "success": false,
  "error": {
    "message": "Barcode generation is not enabled for this shop",
    "code": "FEATURE_DISABLED"
  }
}
```

```json 409 theme={null}
{
  "success": false,
  "error": {
    "message": "Unable to generate a unique barcode after maximum retries",
    "code": "BARCODE_EXHAUSTED"
  }
}
```

## Example

```bash theme={null}
curl -X POST "https://staging-api.puppetvendors.com/products/barcode" \
  -H "x-access-token: YOUR_VENDOR_JWT"
```
