UUIDs in OTM

Using UUIDs

In OTM, all entities (including actions and events) have a universally unique identifier (or UUID for short). As the name suggests this identifier is unique and should ideally be used in all systems to identify that same entity.

Before OTM5.2 it was mandatory to provide this UUID for every entity. However, from OTM5.2 onward you can leave it out and one will be created for you. See also this change request.

What if I already have an ID?

Some systems already have a unique ID to identify an entity. You can also use this ID in the external attributes. Note that entities that use such an ID still need a UUID, you can deterministically generate one using the V3 and V5 versions of the UUID generation method.

What does it look like?

  1. The preferred way is to simply use UUIDs, this is the standard to communicate unique IDs spanning multiple systems.
    Copy
    Copied
    {
       "id": "32dbdc0d-ccc7-4da9-96d3-284d5f472ea1"
       "entityType": "consignment"
    }
  2. You can also use the externalAttributes:
    Copy
    Copied
    {
       "id": "693307fe-81ae-3831-9a88-2a79d4873c2b"
       "entityType": "consignment",
       "externalAttributes": {
           "consignmentId": "unique-consignment-id-12345"
       }
    }

    Note that the UUID and string match using this code in Java:

    Copy
    Copied
    UUID.nameUUIDFromBytes("unique-consignment-id-12345".getBytes())
  3. Since OTM5.2 onward you can omit the UUID, it will then be generated by the the receiving party:
    Copy
    Copied
    {
       "entityType": "consignment",
       "externalAttributes": {
           "consignmentId": "unique-consignment-id-12345"
       }
    }