Agent Wranglers

API-9Recommended

Send IDs as strings

Type every ID as a string, even when it looks like a number today.

How to do it

JavaScript loses precision on whole numbers above 2 to the power of 53, minus 1. A string also lets you change the ID format later. A short prefix, such as ord_, tells people and agents what kind of ID it is. Keep the ID itself from changing as Give every row a stable key says.

How to check

The OpenAPI file declares every id and ...Id field as type: string.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/requests-and-responses/string-ids">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.