---
schema_version: "1"
id: 3a70fc0e1006acf60bdb1786e33541073a27afa1d887a25cf60e8ce0131d1fff
title: Compression Headers
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/intro/intro-rest-compression.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/intro-rest-compression.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3abba5b8070806e99df286d2784b426f8a1c2d5c264eb6ac28d42a1638ca82ca
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Compression Headers

Use a compression header to compress a REST API request or response. Compression reduces the bandwidth required for a request, although it requires more processing power at your client. In most cases, this tradeoff benefits the overall performance of your application.

REST API supports the gzip and deflate compression algorithms, as defined by the HTTP 1.1 specification. If you’re unsure about which one to use, gzip is more common than deflate.

**tip:** For better performance, we suggest that clients accept and support compression as defined by the HTTP 1.1 specification.

## Request Compression

Include a `Content-Encoding: gzip` or `Content-Encoding: deflate` header to compress a request. REST API decompresses any requests before processing.

This example request is compressed with gzip.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/ -H "Authorization: Bearer access-token" -H "Content-Type: application/json" -H "Content-Encoding: gzip" —data-binary @new-account.json -X POST
```

## Response Compression

Salesforce compresses a response only if the request contains an `Accept-Encoding: gzip`, `Accept-Encoding: deflate`, `Accept-Encoding: br`, or `Accept-Encoding: zstd` header. REST API isn’t required to compress the response even if you’ve specified Accept-Encoding, but it normally does. If compressed, the response contains a Content-Encoding header with the compression algorithm so that your client knows to decompress it.

This example request asks for a compressed response.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/0015e000009sS0DAAU -H "Authorization: Bearer access-token" -H "Content-Type: application/json" -H "Accept-Encoding: gzip" -X GET
```

