Skip to main content
POST
/
products
/
barcode
Generate Barcode
curl --request POST \
  --url https://staging-api.puppetvendors.com/products/barcode \
  --header 'x-access-token: <api-key>'
import requests

url = "https://staging-api.puppetvendors.com/products/barcode"

headers = {"x-access-token": "<api-key>"}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {'x-access-token': '<api-key>'}};

fetch('https://staging-api.puppetvendors.com/products/barcode', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://staging-api.puppetvendors.com/products/barcode",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-access-token: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://staging-api.puppetvendors.com/products/barcode"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("x-access-token", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://staging-api.puppetvendors.com/products/barcode")
.header("x-access-token", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://staging-api.puppetvendors.com/products/barcode")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'

response = http.request(request)
puts response.read_body
V2 Preview — This endpoint is part of the V2 API preview. Breaking changes may occur.

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

200
{
  "success": true,
  "data": {
    "barcode": "PV10038472"
  }
}
400
{
  "success": false,
  "error": {
    "message": "Barcode generation is not enabled for this shop",
    "code": "FEATURE_DISABLED"
  }
}
409
{
  "success": false,
  "error": {
    "message": "Unable to generate a unique barcode after maximum retries",
    "code": "BARCODE_EXHAUSTED"
  }
}

Example

curl -X POST "https://staging-api.puppetvendors.com/products/barcode" \
  -H "x-access-token: YOUR_VENDOR_JWT"