curl --request POST \
--url https://avraapi.com/api/v1/utilities/barcode/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SECRET: <api-key>' \
--data '
{
"data": "ORDER-2026-001"
}
'const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-SECRET': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({data: 'ORDER-2026-001'})
};
fetch('https://avraapi.com/api/v1/utilities/barcode/generate', 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://avraapi.com/api/v1/utilities/barcode/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => 'ORDER-2026-001'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SECRET: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}"<string>"Generate a barcode
Create a PNG or SVG barcode through your configured AvraAPI Barcode Generator.
curl --request POST \
--url https://avraapi.com/api/v1/utilities/barcode/generate \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SECRET: <api-key>' \
--data '
{
"data": "ORDER-2026-001"
}
'const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-SECRET': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({data: 'ORDER-2026-001'})
};
fetch('https://avraapi.com/api/v1/utilities/barcode/generate', 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://avraapi.com/api/v1/utilities/barcode/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => 'ORDER-2026-001'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SECRET: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}"<string>"API endpoint
https://avraapi.com/api/v1/utilities/barcode/generate
Request fields
| Field | Required | Rules |
|---|---|---|
data | Yes | Value to encode; 1–80 characters. The selected barcode type can impose additional character or length rules. |
type | No | C128 (default), C128A, C128B, C128C, EAN13, EAN8, UPCA, UPCE, C39, C39+, I25, ITF14, MSI, or POSTNET. |
format | No | png (default) or svg. |
width_factor | No | Number from 1 to 4; default 2. The generator converts the value to an integer, so use whole numbers when you need predictable bar width. |
height | No | Height from 20 to 300 pixels; default 80. |
color | No | Six-digit hex colour, with or without #; default black (000000). |
privacy_mode | No | Boolean request-level privacy setting. Use X-Privacy-Mode: 1 for the shared privacy control. |
C128 is the default general-purpose type. Select a retail, postal, numeric, or constrained variant only when your downstream scanner or standard requires it. AvraAPI validates the public type name, while the barcode renderer enforces any type-specific encoding constraint.
Request example
curl --request POST "https://avraapi.com/api/v1/utilities/barcode/generate" \
--header "X-API-KEY: YOUR_PROJECT_CLIENT_ID" \
--header "X-API-SECRET: YOUR_PROJECT_CLIENT_SECRET" \
--header "X-ENV: development" \
--header "Accept: image/png" \
--header "Content-Type: application/json" \
--data '{
"data": "ORDER-2026-001",
"type": "C128",
"format": "png",
"width_factor": 2,
"height": 80,
"color": "0450ff"
}' \
--output order-barcode.png
Media response
Forpng, the success body is the barcode image with Content-Type: image/png. For svg, it is SVG media with Content-Type: image/svg+xml. Both return Content-Length, Cache-Control: no-store, Content-Disposition: inline, and X-APIX-Request-ID headers.
The response body is not JSON. Save the media response or send it into your own image workflow. If you need a Base64 string, convert the returned media in your backend rather than expecting a separate API response mode.
Error codes
| HTTP | error.code | When it happens | What to do |
|---|---|---|---|
400 | http_error | The barcode renderer rejected the supplied data for the selected barcode type. | Use data compatible with the chosen type, or select a different type. |
401 | unauthorized | Credentials are missing, invalid, inactive, or do not match X-ENV. | Check your backend credential configuration. |
402 | insufficient_funds | The selected Barcode Generator integration requires credits that are unavailable. | Check the project balance and service configuration. |
422 | validation_failed | A field is missing or outside its documented input rules. | Correct the body using the field details in the response. |
422 | provider_selection_failed | No active Barcode Generator integration can be selected for the project environment. | Enable or configure the Barcode Generator integration. |
429 | rate_limit_exceeded | The configured request limit was reached. | Respect Retry-After when present. |
500 | internal_error | The generator could not complete unexpectedly. | Retain the request ID and retry only when appropriate. |
503 | project_paused | The project is paused. | Reactivate the project before retrying. |
Playground resources
The generated reference below lists this endpoint’s API standard details: request fields, authorizations, and response schema. The complete integration guide, request and response examples, and endpoint-specific error handling are above.Authorizations
Your Development project's Client ID. Enter your own value in the Documentation Playground.
Your Development project's Client Secret. Mintlify does not proxy these requests; the browser sends them directly to AvraAPI. Never enter a Production secret in the Documentation Playground.
Headers
Selects the Development credential environment. The Documentation Playground exposes Development values only; normal backend integrations may use their documented Production credentials outside this tool.
dev, development Requests a JSON response where the selected operation supports JSON.
"application/json"
Optional privacy override. Turn this on to request that AvraAPI suppress request-payload storage in observability logs for this request.
true
Body
Value to encode. The selected barcode type can impose additional content rules.
1 - 80C128, C128A, C128B, C128C, EAN13, EAN8, UPCA, UPCE, C39, C39+, I25, ITF14, MSI, POSTNET png, svg Bar-width multiplier. The implementation converts this value to an integer.
1 <= x <= 4Barcode height in pixels.
20 <= x <= 300^#?[0-9a-fA-F]{6}$Optional request-level privacy setting. X-Privacy-Mode is the universal header override.
Response
Barcode image in the requested format.
The response is of type file.
Was this page helpful?
