An identifier should come back from the browser with the same digits it had when it left the server. That is a fairly modest requirement, but a large database integer sent as a JSON number can make it surprisingly easy to break. The value can be valid in storage and valid JSON while a client represents it imprecisely.
The JSON specification’s number guidance identifies the integer range from -9,007,199,254,740,991 to 9,007,199,254,740,991 as exactly interoperable for implementations using common binary64 number handling. JavaScript’s ordinary number representation has that safe-integer boundary. A backend using 64-bit integers can therefore accept identifiers outside the range a typical browser client safely handles as numbers.
For an opaque ID that might exceed that boundary, I prefer a string in the API contract. The client needs to keep it, compare it and send it back; arithmetic is usually irrelevant. Make that decision before the large values arrive and carry it through schemas, generated clients, URLs and stored frontend state. Converting the parsed number into a string afterwards cannot recover digits that have already been lost. A special parser may preserve them, but every consumer then needs to understand that arrangement.
I would test one identifier above the safe-integer boundary through the actual serializer and client parser, then check the value sent on a subsequent request. Small fixture IDs will never show this problem. If an existing API needs changing, treat the move from number to string as a contract change and plan for its consumers. It is an annoying detail to discover late, especially when the screen still displays something that looks perfectly reasonable.

