IDv1 documentation
Which shape for what you build
Pick the shape by what the thing is, not by what an app calls it, so the same kind of thing has the same shape everywhere and a code is easy to place on sight.
| What it is | Shape | Called in apps | Example |
|---|---|---|---|
| A person | account | user, member, owner | Jo4712 |
| Something that holds things | list | list, category, board, collection, folder, project | 12ABCD |
| One thing kept | item | item, clip, listing, note | Ab12Cd |
| A thing in the world with a code printed on it | product | product, tag, sticker | AbCd12 |
| Something that happens, many times a day | event | event, visit, session, trace | k3Rw9Q |
The first four are the standard version. An event is the expanded version, under Advanced.
The shapes
- Account,
LLnnnn: two letters from the person’s name, a capital and a small one (Leo isLe0125), then four digits drawn until the code is free. A name without two Latin letters takes them from the email address, and failing that at random. - Product,
LLLLnn: four letters and two digits. It is printed and scanned, never typed. Whoever signs up with a product’s code may keep it as their account’s code, so it is an account’s shape too. - List,
nnLLLL: two digits and four letters. New lists draw capitals; older lists may hold small letters, and every check reads both. - Item,
LLnnXX: two letters, two digits, then two letters or digits that are not both digits, or it would be an account.
No code can have two shapes, so codeKind always gives one answer.
How many
| Kind | Count | Exactly |
|---|---|---|
| Accounts | 52² × 10⁴ | 27,040,000 |
| Products | 52⁴ × 10², before the blocked words | 731,161,600 |
| Lists, drawn with capitals | 10² × 26⁴ | 45,697,600 |
| Items | 52² × 10² × (62² − 10²) | 1,012,377,600 |
| Events, expanded version | 62⁶ less the four shapes as read | 54,298,494,784 |
| Every six-character code | 62⁶ | 56,800,235,584 |
ID_SPACE holds the standard counts, and idUsage(kind, used) says how much of a kind is used and how much is left:
import { ID_SPACE, idUsage } from '@0001-labs/idv1'
ID_SPACE.lists // 45_697_600
idUsage('accounts', 1352) // { used: 1352, space: 27040000, left: 27038648, percent: 0.005 }
Codes that are never drawn
- Blocked words. A product’s letters, and an event’s, are drawn again when they spell a rude or awkward word in any language the apps speak, capitals aside (
BLOCKED_CODE_WORDS), and a product’s digits when they are awkward (BLOCKED_CODE_DIGITS). - Kept codes. A few account codes are kept for one person or role in every app and never drawn for anyone else (
RESERVED_ACCOUNT_CODES);reservedAccountCode(email)gives the kept code before an app draws one. - A code does not change by itself. An app may give an account a chosen code, as when it should match the code its owner has elsewhere.