---
title: "Get swatch image from a legend"
method: GET
path: "/v1/spatial/maps/{mapName}/swatch"
tags: ["Mapping Service: Miscellaneous"]
---

# Get swatch image from a legend

`GET /v1/spatial/maps/{mapName}/swatch`

## Request

- Base URL: `https://api.cloud.precisely.com`
- URL: `https://api.cloud.precisely.com/v1/spatial/maps/{mapName}/swatch`
- Auth: API key in header `Authorization` and HTTP bearer

Returns a specific swatch image from a named map's legend.
The swatch is identified by the map name, legend index, and row index.
The image is returned in the specified format (png, jpeg, jpg, gif, bmp, or tiff).

If the swatch is not already cached, the legend will be rendered first to generate the swatch images.

**Authorization:** Requires EXECUTE permission on the named map (checked when the legend is rendered to produce the swatch).

## Path parameters

- `mapName` string, required

## Query parameters

- `legendIndex` integer, required
- `rowIndex` integer, required
- `width` integer, required
- `height` integer, required
- `format` 'png' | 'jpeg' | 'jpg' | 'gif' | 'bmp' | 'tiff', required
- `dpi` integer

## Response `200`

Swatch image retrieved successfully

## Other responses

- `400`: Invalid request parameters
- `403`: Caller does not have EXECUTE permission on the named map
- `404`: Map, legend, or swatch not found

---

[API](https://skmtc.dev/precisely/apis/mapping-api.md) · [All operations](https://skmtc.dev/precisely/apis/mapping-api/llms.txt) · [OpenAPI document](https://skmtc.dev/precisely/apis/mapping-api/revisions/cea0ad9440c5?raw)
