---
id: "mongodbid"
kind: "datatype"
status: "stable"
is_pii: false
categories: ["identifiers", "common"]
langs: ["common"]
quality: 90
url: "http://registry.apicrafter.io/datatype/mongodbid"
---

# MongoDB unique Object ID (`mongodbid`)

MongoDB ObjectId, the unique id that MongoDB assigns to each document of a collection as the field _id. It is a 12-byte value written as 24 hexadecimal characters. The first 4 bytes are the creation time in seconds since the Unix epoch, then come a 5-byte random value per process and a 3-byte counter, so ObjectIds sort roughly by creation time. The MongoDB manual writes the hexadecimal digits in lowercase. The xid format encodes the same 12 bytes in Base32 (xid). It is not the ArcGIS OBJECTID (objectid).

- Personal data (PII): no
- Categories: Universal unique identifiers (identifiers), Common (common)
- Countries: global
- Languages: Common to most languages (common)
- Classification: identifier

## Detection

Regular expression (Python `re`):

```
^[0-9a-fA-F]{24}$
```

## Examples

- `507f1f77bcf86cd799439011` — Unique MongoDB ObjectID
- `507f191e810c19729de860ea` — Unique MongoDB ObjectID
- `00000020f51bb4362eee2a4d` — ObjectId(32) from the MongoDB manual, 32 seconds after the Unix epoch
- `507f1f77bcf86cd79943901` (invalid example) — 23 characters instead of 24

## Metacrafter rules

2 rules: 1 match the field name, 1 match values.

- `mongodbidfield` (field, `basic/identifiers.yaml`)
- `mongodbidvalue` (data, `basic/identifiers.yaml`)

## Supported by tools

- `csvdetective`
- `metacrafter`

## Translations

- ru: Идентификатор объекта MongoDB (ObjectId)

## Sources

- doc: <https://www.mongodb.com/docs/manual/reference/method/ObjectId/>

## Quality

Score 90/100. Missing: mapping (Wikidata, Schema.org, ...).

JSON: <http://registry.apicrafter.io/api/v1/datatypes/mongodbid.json> · Edit: <https://github.com/apicrafter/metacrafter-registry/edit/main/data/datatypes/any/identifiers/mongodbid.yaml>
