Home /  Mappings /  How to / 

Send compressed payloads

To send a gzip compressed payload to the Mappings API, set the Content-Encoding header to the value of gzip. Mappings API currently only supports gzip compression.

Note that the maximum document size limit is applied after decompressing the content of the payload. If the decompressed payload of a given request is larger than the maximum document size limit, the Mappings API will reject the request.

The following is an example written in TypeScript of creating mapping and sending a gzip compressed payload to the /map endpoint.

import axios from "axios";
import { gzipSync } from "zlib";

const rootURL = "https://mappings.us.stedi.com/2021-06-01/mappings";
const headers = { Authorization: `Key ${API_KEY}` };

async function doRequest() {
  const mapping = {
    name: "GzipPayloadMapping",
    mapping: `{"Hello": keyFromSource}`,
    type: "only_mapped_keys",

  const createMappingResponse = await axios.post(rootURL, mapping, { headers });

  const payload = gzipSync(JSON.stringify({ keyFromSource: "World!" }));
  const mapResponse = await axios.post(`${rootURL}/${createMappingResponse.data.id}/map`, payload, {
    headers: {
      "Content-Encoding": "gzip",


async function main() {
  try {
    await doRequest();
  } catch (e) {