Skip to main content

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.

FieldValuesMeaning
providerClientIdPrefixunset, none, organizationWhether new device ids get the prefix. Unset inherits from the parent organization.
assetIdPrefixunset, none, organizationWhether new asset ids get the prefix. Unset inherits from the parent organization.
idPrefixa word, or unsetThe prefix. Unset means the first 8 hex characters of the organization's id.
idPrefixLockedtrue, falseThe 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 none unless the tenant sets it; a shared tenant usually sets organization for both. GET /organizations/id-prefix-defaults returns it.
  • The prefix is not inherited. Each organization uses its own idPrefix, or its own hex prefix.
  • An idPrefix has 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 modeAsset modeidPrefixDevice idAsset id
1nonenoneunsetM-100M-100
2nonenoneacmeM-100M-100
3organizationnoneunset5f0c2b7a_M-100M-100
4organizationnoneacmeacme_M-100M-100
5noneorganizationunsetM-1005f0c2b7a_M-100
6noneorganizationacmeM-100acme_M-100
7organizationorganizationunset5f0c2b7a_M-1005f0c2b7a_M-100
8organizationorganizationacmeacme_M-100acme_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}/clients returns the device id in id.
  • POST /assets returns the asset id in id. When the asset already exists and belongs to your organization, the answer is 409 with the existing id.
  • 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 in POST /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, in effectiveIdPrefixes, the values that apply to it.
Device onboarding

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​

SituationSetting
One customer per tenant, ids must match the devices or other systemsLeave everything unset (none).
Several customers on a shared tenant or a shared providerThe 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 assetsassetIdPrefix: organization on that customer's organization.
A customer with its own provider whose device names are fixedproviderClientIdPrefix: none on that customer's organization.
A customer that wants readable idsidPrefix 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 treeidPrefix and idPrefixLocked: true on its top organization.