Organization Id Prefixes
An organization can put a prefix in front of the device ids and asset ids it creates, so that several organizations can use the same requested id without clashing.
Why
A device id is unique per provider, and an asset id is unique per tenant. When several organizations create devices on one shared provider, or assets in one tenant, two of them can request the same id, for example the serial number M-100. Without a prefix, the second create is refused. With a prefix, each organization gets its own id: acme_M-100 and 5f0c2b7a_M-100.
The fields
Four fields on the organization decide the prefix.
| Field | Values | Meaning |
|---|---|---|
providerClientIdPrefix | unset, none, organization | Whether new device ids get the prefix. Unset inherits from the parent organization. |
assetIdPrefix | unset, none, organization | Whether new asset ids get the prefix. Unset inherits from the parent organization. |
idPrefix | a word, or unset | The prefix. Unset means the first 8 hex characters of the organization's id. |
idPrefixLocked | true, false | The organizations below use this organization's modes and prefix. |
- The two modes are inherited down the organization tree. Where no organization up the tree has its own value, the tenant default applies. It is
noneunless the tenant sets it; a shared tenant usually setsorganizationfor both.GET /organizations/id-prefix-defaultsreturns it. - The prefix is not inherited. Each organization uses its own
idPrefix, or its own hex prefix. - An
idPrefixhas lower-case letters, digits and-, 2 to 16 characters, starts and ends with a letter or digit, and is unique in the tenant.
Every combination
An organization with id 5f0c2b7a-… requests M-100 for a device and for an asset. The modes are its effective modes; idPrefix is its own.
| # | Device mode | Asset mode | idPrefix | Device id | Asset id |
|---|---|---|---|---|---|
| 1 | none | none | unset | M-100 | M-100 |
| 2 | none | none | acme | M-100 | M-100 |
| 3 | organization | none | unset | 5f0c2b7a_M-100 | M-100 |
| 4 | organization | none | acme | acme_M-100 | M-100 |
| 5 | none | organization | unset | M-100 | 5f0c2b7a_M-100 |
| 6 | none | organization | acme | M-100 | acme_M-100 |
| 7 | organization | organization | unset | 5f0c2b7a_M-100 | 5f0c2b7a_M-100 |
| 8 | organization | organization | acme | acme_M-100 | acme_M-100 |
Locking a subtree
An organization can set idPrefixLocked: true. Every organization below it, at any depth, then uses the locking organization's modes and prefix, and cannot change its own four fields. With several locked organizations above, the highest one decides.
Example: organization Acme has providerClientIdPrefix: organization, assetIdPrefix: organization, idPrefix: acme and idPrefixLocked: true. Every device and asset created by Acme or by any organization below it gets acme_ in front of its id.
What the API returns
The create returns the id that was stored. Always use that id, not the id you requested:
POST /providers/{providerId}/clientsreturns the device id inid.POST /assetsreturns the asset id inid. When the asset already exists and belongs to your organization, the answer is 409 with the existingid.- A device create also needs View on the provider for the organization named in the request; without it the answer is 404.
- When the platform cannot read the organization's fields, the create is refused with 503 and nothing is created. It never falls back to an id without a prefix.
A device id or an asset id is assigned once. A later change of the fields affects only ids created after it; existing ids are never renamed. The prefix gives no rights: who owns a device or an asset is decided by its relations, never by its id.
Setting the fields
- Web interface: the organization page and the new organization dialog show the fields to users who may manage the organization. An organization template can set the two modes and the lock, but not the prefix.
- API:
PATCH /organizations/{organizationId}with any of the four fields (204 on success), or the same fields inPOST /organizations. An empty string clears a field. A bad value is refused with 400, a prefix held by another organization with 409, and a change below a locked organization with 409. GET /organizations/{organizationId}returns the organization's own values and, ineffectiveIdPrefixes, the values that apply to it.
Device onboarding does not yet use the ids the creates return. On a tenant whose device mode is organization, create devices through the API or the web interface.
When to use it
| Situation | Setting |
|---|---|
| One customer per tenant, ids must match the devices or other systems | Leave everything unset (none). |
| Several customers on a shared tenant or a shared provider | The tenant default is organization for both modes. Set idPrefix on each customer's top organization so that its ids are readable (htf_M-100 instead of e502abde_M-100). A customer whose asset ids must stay exact sets its own assetIdPrefix: none. |
| A customer whose sub-organizations create their own assets | assetIdPrefix: organization on that customer's organization. |
| A customer with its own provider whose device names are fixed | providerClientIdPrefix: none on that customer's organization. |
| A customer that wants readable ids | idPrefix on its organization, for example htf. Its sub-organizations keep their own prefix (their hex prefix unless they set one). |
| A customer that wants one readable prefix for its whole tree | idPrefix and idPrefixLocked: true on its top organization. |