# Accept Header — Syntax, Values & Examples

> Lists the response media types the client can handle, in order of preference.

Accept drives content negotiation: the same URL can return HTML to a browser and JSON to an API client. Each type can carry a quality value `q` from 0 to 1; higher is preferred, and the default is 1.

- Type: Request header
- Category: Content
- Defined in: [RFC 9110 §12.5.1 — Accept](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.1)

## Syntax

```http
Accept: <type>/<subtype>[;q=<weight>], …
```

## Examples

```http
Accept: application/json
```

an API client

```http
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
```

what browsers send for page navigation

```http
Accept: image/avif,image/webp,*/*;q=0.8
```

browsers asking for images

## Good to know

- Most APIs ignore Accept and always return JSON. If yours negotiates, also send `Vary: Accept`.
- Servers that can't satisfy it may answer [406](https://www.devkult.com/http/406.md), but most just send their default type.

## How to set Accept

### fetch

```
await fetch("https://api.example.com/", {
  headers: { "Accept": "application/json" },
});
```

### curl

```
curl -H 'Accept: application/json' https://api.example.com/
```

## Check it

In the browser, open DevTools → Network, pick a request and look under Request Headers. From the command line, curl's verbose mode prints every header it sends, prefixed with `>`:

```sh
curl -sv https://example.com/ -o /dev/null 2>&1 | grep '^>'
```

## FAQ

### What does */* mean in Accept?

Any media type. Combined with a lower q-value, like */*;q=0.8, it means 'anything else is acceptable, but I prefer the types listed before it'.

## Status codes it appears with

- [406 Not Acceptable](https://www.devkult.com/http/406.md)

## Related headers

- [Content-Type](https://www.devkult.com/headers/content-type.md): States the media type of the body — HTML, JSON, form data, an image — and often its character encoding.
- [Accept-Encoding](https://www.devkult.com/headers/accept-encoding.md): Lists the compression formats the client can decompress, so the server can pick one.
- [Vary](https://www.devkult.com/headers/vary.md): Lists the request headers that change the response, so caches keep a separate copy for each variant.

Open the interactive page: https://www.devkult.com/headers/accept