HomeGuidesSamplesAPI
API

IDs

Different types of IDs returned by SafetyCulture APIs

New IDs (UUIDs)

For the new SafetyCulture APIs, IDs must be provided in the format of a UUID f3245d39-ea77-11e1-aff1-0800200c9a66, to convert an old ID to this format use this sample code and convert it to your programming language.

const id = 'audit_f3245d39ea7711e1aff10800200c9a66';

function toUUID(str) {
  const uuid = str.split('_')[1];

  return `${uuid.substr(0, 8)}-${uuid.substr(8, 4)}-${uuid.substr(12, 4)}-${uuid.substr(16, 4)}-${uuid.substr(20)}`
}

toUUID(id) // f3245d39-ea77-11e1-aff1-0800200c9a66

Old IDs (SafetyCulture IDs)

For our older SafetyCulture APIs, IDs must be provided in our prefixed ID format audit_f3245d39ea7711e1aff10800200c9a66, to convert a new UUID to this format use this sample code and convert it to your programming language.

const uuid = 'f3245d39-ea77-11e1-aff1-0800200c9a66';

function toSafetyCultureID(prefix, id) {
  return `${prefix}_${id.replace(/-/g, '')}`;
}

toSafetyCultureID('audit', uuid) // audit_f3245d39ea7711e1aff10800200c9a66