Malformed Tracking Number in Order API

Tracking numbers longer than 12 characters are returned in decimal (scientific) notation.

For example, when retrieving a tracking number using the Order REST or GraphQL APIs:

  • A value such as 123456789012 is returned correctly.

  • However, a longer value such as 1234567890123456789012 is returned as 1.23456789012345e+21.

I’m referring to this API endpoint:
https://shopify.dev/docs/api/admin-graphql/latest/objects/Order#field-Order.fields.fulfillments

Can someone from the API share any comments or feedback on that?

Thanks,

1 Like

Hi, This looks like a floating-point precision issue.

When a long numeric tracking number gets parsed as a JSON number (instead of a string), it converts to scientific notation — that’s why 1234567890123456789012 becomes 1.23456789012345e+21.

Tracking numbers should always be strings, not numbers.

You’re correct — the issue is that this value is returned by the API.

Could someone from the API team please confirm and address it?

Shopify API team? Any comments on that behavior?

You can check the raw API response first—if it’s already in scientific notation, then it’s coming that way from the API. Otherwise, it might be getting converted during parsing, so try handling it as a string.