TGViewer
Programming & AI Tips πŸ’‘ Programming & AI Tips πŸ’‘ @programmingtip Β· 46.4K subscribers
Post #736 25.2K
Designing APIs for humans: Object IDs πŸ§‘πŸ»β€πŸ’»

Ever wondered why Stripe uses foloowing format to generate unique IDs? Let’s dive in and break down how and why Stripe IDs are structured the way they are:

pi_3LKQhvGUcADgqoEM3bh6pslE
β””β”˜β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
└─ Prefix └─ Randomly generated characters


You might have noticed that all Stripe Objects have a prefix at the beginning of the ID. The reason for this is quite simple: adding a prefix makes the ID human readable. βœ”οΈ

Without knowing anything else about the ID we can immediately confirm that we’re talking about a PaymentIntent object here, thanks to the pi_ prefix. This helps Stripe employees internally just as much as it helps developers integrating with Stripe.

$pi = $stripe->paymentIntents->retrieve(
$id,
[],
['stripe_account' => 'cus_1KrJdMGUcADgqoEM']
);


The above snippet is trying to retrieve a PaymentIntent from a connected account, however without even looking at the code you can immediately spot the error: a Customer ID (cus_) is being used instead of an Account ID (acct_). πŸ”–

Without prefixes this would be much harder to debug; if Stripe used UUIDs instead then we’d have to look up the ID to find out what kind of object it is and if it’s even valid. πŸ‘¨β€πŸ’»


[ Read More ] : https://dev.to/stripe/designing-apis-for-humans-object-ids-3o5a

〰️〰️〰️〰️〰️〰️
#UUID #Stripe
@ProgrammingTip
Telegram Programming Tips Resources
More from @programmingtip
  1. Oct 5, 2026AI is changing the developer career ladder πŸš€ GitHub's latest developer career advice is r…
  2. Oct 2, 2026GPT-6 Astra gets an Ultrafast API tier πŸš€ OpenAI added an Ultrafast speed tier for GPT-6 A…
  3. Oct 1, 2026Cloudflare shipped an agentic CLI for its API ⚑️ Cloudflare launched cf, an agentic CLI fo…
  4. Sep 30, 2026OpenAI introduced Dots, always-on agents πŸš€ OpenAI introduced Dots, its take on always-on…
  5. Sep 29, 2026Claude Sonnet 5.5 is built for coding agents πŸš€ Anthropic released Claude Sonnet 5.5 for t…
  6. Sep 26, 2026Claude Opus 5.5 is available in the API πŸš€ Anthropic released Claude Opus 5.5, and it is a…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’