Samsara Developer Portal

Integrate your data with the Samsara API, customize the Samsara experience, and join a community of developers building with Samsara.

Get Started

External IDs

Reference objects using a custom identifier that you provide

External IDs allow you to reference Samsara objects using a custom ID field set by you. Additionally, you can identify objects by their unique fields, such as vin or name (see Automatic External IDs).

Creating External IDs

External IDs consist of key-value pairs, where the key is the name of the ID and the value is the unique identifier for that object. For example, you could have a payroll ID and a maintenance ID, allowing you to retrieve that object by either of those IDs. External IDs are represented as dictionaries for their respective objects:

{
  "externalIDs" : {
    "payroll": "ABCD",
    "maintenance": "1234"
  }
}

Currently, you can only set external IDs through the API. To set an external ID, use either the POST or PATCH method for the given object and include a dictionary of external ID key-value pairs. For example:

curl --request POST 'https://api.samsara.com/fleet/drivers' \
--header 'Authorization: Bearer <<token>>' \
--data-raw '{
    "name": "Tyler Freckmann",
    "username": "tyler.freckmann",
    "password": "password",
    "externalIds": {
        "payrollSys1": "[email protected]",
        "maintenanceSys1": "Ty_Frec-%01+27+94%"
    }
}'

The above example will create a driver with two external IDs:

External ID KeyValue
payrollSys1[email protected]
maintenanceSys1Ty_Frec-%01+27+94%

๐Ÿ“˜

External ID Types

Both external ID keys and values are strings. Samsara will convert external ID values to strings if a different type is submitted in the request.

Uniqueness

External ID values must be unique across all entities. This means that if one object has the external ID maintenance:1234, no other objects can use the value 1234 for the maintenance ID, even if the objects are of different classes.

For example, if a driver has the external ID maintenance:1234, no other drivers or vehicles or addresses or any other object may use the value 1234 for the maintenance external ID.

Characters Limits

Both the external ID keys and values are strings.

External ID keys can only contain alphanumeric characters and cannot contain any special or punctuation characters. Keys must be 32 characters or less.

External ID values can only contain alphanumeric characters and the following special characters: @, ., _, %, +, -.

Number of Keys

There can be at most 20 unique external ID keys for the organization.

For example, payroll and maintenance would count as two external ID keys for my organization - even if I was using them on two different classes of objects (drivers vs vehicles, for example).

Using External IDs

To retrieve or update an object by its external ID, include it in the path of the request using the following syntax: key:value. For example, the following URL would reference the driver above.

https://api.samsara.com/fleet/drivers/payrollSys1:[email protected]

Deleting External IDs

To delete an external ID from an object, set its value to null or the empty string (""). For example, the following request would delete the payrollSys1 and maintenanceSys1 IDs from the driver with the Samsara ID 123456789:

curl --request PATCH 'https://api.samsara.com/fleet/drivers/123456789' \
--header 'Authorization: Bearer <<token>>' \
--data-raw '{
    "externalIds": {
        "payrollSys1": null,
        "maintenanceSys1": null
    }
}'

Automatic External IDs

Samsara will automatically populate external IDs on certain types of objects. The external ID keys will be prefixed with samsara. and will be read-only.

Current automatically populated external IDs:

Object TypeExternal ID KeyExternal ID Value
Vehiclesamsara.vinThe VIN of the vehicle. If a VIN is not available, this external ID will not exist.
Vehiclesamsara.serialThe serial number of the Samsara Vehicle Gateway.
Tagsamsara.nameThe name of the Tag.

Updated a day ago


External IDs


Reference objects using a custom identifier that you provide

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.