# Localized formatting (/docs/basic-concepts/localized-formatting)

Add `formatted=true` to a request and each object also carries a `formatted` child with its money amounts and dates written for people, in the shopper's language and format. You can show these values as they are, without formatting them yourself.

## Ask for formatted values [#ask-for-formatted-values]

```bash title="Request"
curl "https://api.comecero.com/api/v1/carts/0091307952465CafhFSTa1?formatted=true" \
  -H "Authorization: Bearer $COMECERO_TEST_TOKEN"
```

```json title="Response"
{
  "object": "cart",
  "cart_id": "0091307952465CafhFSTa1",
  "date_created": "2026-11-07T23:16:38Z",
  "currency": "USD",
  "subtotal": 119.9,
  "shipping": 5,
  "tax": 9.38,
  "total": 134.28,
  "formatted": {
    "subtotal": "$119.90",
    "shipping": "$5.00",
    "tax": "$9.38",
    "total": "$134.28",
    "date_created": "11/7/2026 11:16 PM"
  }
}
```

The raw values stay where they are. Use them for sums and logic, and the `formatted` ones for display:

```js
const cart = await response.json();
totalElement.textContent = cart.formatted.total; // "$134.28"
```

The default is `false`. A value other than `true` or `false` is a `400`. Each object's page in the [API reference](/api) lists what its `formatted` child holds.

## What is formatted [#what-is-formatted]

- **Money amounts**, with the currency's symbol and the locale's way of writing numbers. The same amount can read `$134.28` in English and `134,28 $` in French.
- **Dates and times**, as a short date and time in the locale, in the request's time zone (see [Dates and times](/docs/basic-concepts/dates-and-times)).
- Some other fields with a display form, such as a country name. The object's page says which.

`formatted` follows [`show` and `hide`](/docs/basic-concepts/customizing-output): with `show=total&formatted=true` it holds only `total`.

## Which locale is used [#which-locale-is-used]

The API picks the locale in this order and uses the first it finds:

1. The `user_locale` query parameter, if you send one.
2. For limited and trusted tokens, the browser's `Accept-Language` header.
3. The default locale of the shopper's country, found from their IP address.
4. Your account's default locale.

A request from a shopper's browser needs nothing extra: the browser's language is used. Send `user_locale` to override it.

### From your server [#from-your-server]

A server request with a secret token has no browser, so the `Accept-Language` header is not read. Pass the shopper's locale yourself as a language code, or a language and country:

```text
user_locale=fr
user_locale=fr-CA
user_locale=de-AT
user_locale=en-US
```

You can also pass the browser's whole `Accept-Language` value in `user_locale`, for example `fr-CA,fr;q=0.9,en;q=0.8`. The API picks the best language it supports.

```js
const locale = encodeURIComponent(request.headers['accept-language'] ?? 'en-US');
const response = await fetch(
  `https://api.comecero.com/api/v1/orders/6622-NXKHE-858?formatted=true&user_locale=${locale}`,
  { headers: { Authorization: `Bearer ${process.env.COMECERO_TEST_TOKEN}` } },
);
```

To format for the shopper's country too, a secret token can send the shopper's IP address in `user_ip_address`.

## Next steps [#next-steps]

<Cards>
  <Card title="Dates and times" href="/docs/basic-concepts/dates-and-times" />
  <Card title="Customizing output" href="/docs/basic-concepts/customizing-output" />
</Cards>
