Generate codes
curl --request POST \
--url https://api.thingidentity.com/codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/vnd.thingidentity.public.v1+json' \
--data '
{
"codes": [
{
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"ais": [
{
"key": "01",
"value": "09521234543213"
}
],
"extensionParameters": [
{
"key": "01",
"value": "09521234543213"
}
],
"reference": "product-label",
"digitalLinkStem": "https://gtin.at",
"linkType": "gs1:pip",
"context": "<string>",
"language": "en-us"
}
]
}
'import requests
url = "https://api.thingidentity.com/codes"
payload = { "codes": [
{
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"ais": [
{
"key": "01",
"value": "09521234543213"
}
],
"extensionParameters": [
{
"key": "01",
"value": "09521234543213"
}
],
"reference": "product-label",
"digitalLinkStem": "https://gtin.at",
"linkType": "gs1:pip",
"context": "<string>",
"language": "en-us"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/vnd.thingidentity.public.v1+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/vnd.thingidentity.public.v1+json'
},
body: JSON.stringify({
codes: [
{
primaryKey: {key: '01', value: '09521234543213'},
ais: [{key: '01', value: '09521234543213'}],
extensionParameters: [{key: '01', value: '09521234543213'}],
reference: 'product-label',
digitalLinkStem: 'https://gtin.at',
linkType: 'gs1:pip',
context: '<string>',
language: 'en-us'
}
]
})
};
fetch('https://api.thingidentity.com/codes', 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://api.thingidentity.com/codes",
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([
'codes' => [
[
'primaryKey' => [
'key' => '01',
'value' => '09521234543213'
],
'ais' => [
[
'key' => '01',
'value' => '09521234543213'
]
],
'extensionParameters' => [
[
'key' => '01',
'value' => '09521234543213'
]
],
'reference' => 'product-label',
'digitalLinkStem' => 'https://gtin.at',
'linkType' => 'gs1:pip',
'context' => '<string>',
'language' => 'en-us'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/vnd.thingidentity.public.v1+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.thingidentity.com/codes"
payload := strings.NewReader("{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/vnd.thingidentity.public.v1+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.thingidentity.com/codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.thingidentity.public.v1+json")
.body("{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.thingidentity.com/codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/vnd.thingidentity.public.v1+json'
request.body = "{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"codes": [
{
"reference": "<string>",
"mode": "<string>",
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"barcodeText": "https://gtin.at/01/09521234543213?linkType=gs1%3Apip",
"hri": "(01)09521234543213"
}
],
"failures": [
{
"reference": "<string>",
"errors": [
{
"code": "Validation.Invalid.mode",
"args": [
"<string>"
],
"path": "mode"
}
]
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}Generate codes
Takes a batch of code definitions and returns, for each one, the payload to encode in a symbol plus its human readable interpretation. Nothing is rendered as an image: you get the text and feed it to your own 2D barcode renderer.
A definition that fails validation does not fail the request. The status is 200 OK even when every item was rejected and codes comes back empty, so check failures rather than the status code.
Requires the write:codes scope.
POST
/
codes
Generate codes
curl --request POST \
--url https://api.thingidentity.com/codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/vnd.thingidentity.public.v1+json' \
--data '
{
"codes": [
{
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"ais": [
{
"key": "01",
"value": "09521234543213"
}
],
"extensionParameters": [
{
"key": "01",
"value": "09521234543213"
}
],
"reference": "product-label",
"digitalLinkStem": "https://gtin.at",
"linkType": "gs1:pip",
"context": "<string>",
"language": "en-us"
}
]
}
'import requests
url = "https://api.thingidentity.com/codes"
payload = { "codes": [
{
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"ais": [
{
"key": "01",
"value": "09521234543213"
}
],
"extensionParameters": [
{
"key": "01",
"value": "09521234543213"
}
],
"reference": "product-label",
"digitalLinkStem": "https://gtin.at",
"linkType": "gs1:pip",
"context": "<string>",
"language": "en-us"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/vnd.thingidentity.public.v1+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/vnd.thingidentity.public.v1+json'
},
body: JSON.stringify({
codes: [
{
primaryKey: {key: '01', value: '09521234543213'},
ais: [{key: '01', value: '09521234543213'}],
extensionParameters: [{key: '01', value: '09521234543213'}],
reference: 'product-label',
digitalLinkStem: 'https://gtin.at',
linkType: 'gs1:pip',
context: '<string>',
language: 'en-us'
}
]
})
};
fetch('https://api.thingidentity.com/codes', 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://api.thingidentity.com/codes",
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([
'codes' => [
[
'primaryKey' => [
'key' => '01',
'value' => '09521234543213'
],
'ais' => [
[
'key' => '01',
'value' => '09521234543213'
]
],
'extensionParameters' => [
[
'key' => '01',
'value' => '09521234543213'
]
],
'reference' => 'product-label',
'digitalLinkStem' => 'https://gtin.at',
'linkType' => 'gs1:pip',
'context' => '<string>',
'language' => 'en-us'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/vnd.thingidentity.public.v1+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.thingidentity.com/codes"
payload := strings.NewReader("{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/vnd.thingidentity.public.v1+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.thingidentity.com/codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/vnd.thingidentity.public.v1+json")
.body("{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.thingidentity.com/codes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/vnd.thingidentity.public.v1+json'
request.body = "{\n \"codes\": [\n {\n \"primaryKey\": {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n },\n \"ais\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"extensionParameters\": [\n {\n \"key\": \"01\",\n \"value\": \"09521234543213\"\n }\n ],\n \"reference\": \"product-label\",\n \"digitalLinkStem\": \"https://gtin.at\",\n \"linkType\": \"gs1:pip\",\n \"context\": \"<string>\",\n \"language\": \"en-us\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"codes": [
{
"reference": "<string>",
"mode": "<string>",
"primaryKey": {
"key": "01",
"value": "09521234543213"
},
"barcodeText": "https://gtin.at/01/09521234543213?linkType=gs1%3Apip",
"hri": "(01)09521234543213"
}
],
"failures": [
{
"reference": "<string>",
"errors": [
{
"code": "Validation.Invalid.mode",
"args": [
"<string>"
],
"path": "mode"
}
]
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "Forbidden",
"path": "<string>",
"message": "<string>"
}
]
}Partial success
Every item of a batch is validated on its own, so a rejected item does not fail the request. The status stays200 OK even when every item was rejected and codes comes back empty, which means you
should check failures rather than the status code.
Each request item may include a string reference of your choice. The API echoes it unchanged
in either codes or failures. If omitted or null, the reference is the item’s zero-based position
in the original request, returned as a string: "0", "1", and so on. Empty strings are preserved.
Use distinct references and avoid collisions with generated references within a batch.
References do not provide deduplication or idempotency.
{
"codes": [],
"failures": [
{
"reference": "product-label",
"errors": [
{ "code": "Validation.Invalid.mode", "path": "mode", "args": [] }
]
}
]
}
Validation codes
path matches the part of the definition at fault, so ais.2 is the third entry of ais.
| Code | Meaning |
|---|---|
Validation.Invalid.mode | mode is not one of the four supported values. |
Validation.Invalid.primaryKey | Unknown AI, an AI this mode does not accept as a primary key, or a value that fails its format or check digit. |
Validation.Invalid.ais | Duplicate AI keys in ais. |
Validation.Invalid.ais.<index> | Unknown AI, a value that fails its format, or an AI repeating the primary key. |
Validation.Invalid.ais.qualifiers | The path qualifiers do not all come from one qualifier sequence of the chosen primary key. |
Validation.Invalid.ais.<index>.digitalLink | The AI is neither a qualifier of the primary key nor a permitted Digital Link data attribute. |
Validation.Invalid.relations.<ai>.requires | The AI requires another AI that is absent. |
Validation.Invalid.relations.<ai>.excludes.<other> | Two mutually exclusive AIs were sent together. |
Validation.Invalid.digitalLinkStem | Missing in a Digital Link mode, or not an acceptable origin. |
Validation.Invalid.linkType | Not an offered gs1: link type and not an absolute HTTP(S) URI. |
Validation.Invalid.extensionParameters | Sent in an element string mode, or duplicate keys. |
Validation.Invalid.extensionParameters.<index> | Reserved or malformed key, or a value outside the allowed characters. |
Validation.Invalid.context | Value outside the allowed characters. |
Authorizations
The access_token from POST /oauth/token.
Body
application/vnd.thingidentity.public.v1+jsonapplication/json
The definitions to generate. Items are processed in order and each one is validated on its own.
Show child attributes
Show child attributes