Skip to main content

Assigning External ID in JSON Format

How do I assign an external ID in JSON format to a record?

Written by Petr Pech

An external identifier can also be added to a record in JSON. Since it is added alongside the existing identifier, the id field is written as an array of values.


Writing

{
"winstrom": {
"@version": "1.0",
"faktura-vydana": [{
"id": [ "code:VF1-0035/2026", "ext:SHOP:123" ],
"popis": "popis"
}]
}
}

The record is found using the first identifier, and the second one is added to it. A record can have multiple existing external identifiers — adding another one won't remove the existing ones.

⚠️ The id field within a single object represents one record described by several identifiers, not several records. All listed identifiers that already exist must point to the same record — otherwise the request will fail with a Identifikátory … označují různé objekty error.


Removing identifiers

A group of external identifiers is removed using the removeExternalIds attribute, whose value is their prefix:

{
"winstrom": {
"@version": "1.0",
"cenik": [{
"id": [ "123", "ext:SHOP:123" ],
"@removeExternalIds": "ext:SYSTEM"
}]
}
}

ℹ️ An empty removeExternalIds value removes all external identifiers. The ext: prefix does not need to be included in the value.


Related

Did this answer your question?