# Mapping sets (legacy)

> The account-level mapping set endpoints of the Layerz REST API, kept for existing integrations. New integrations write rules per source instead.

> [!warning]
> Mapping sets are an account-level catalogue of mapping rules, kept for the integrations that use them. A model's rules belong to its sources: write them with [`PUT /models/:id/sources/:sourceId/rules`](/docs/api/sources-and-rules). Writing a model's own set through these routes returns `400`.

| Method and path                   | Does                                                    |
| --------------------------------- | ------------------------------------------------------- |
| `GET /mapping-sets`               | The sets you can read: system catalogues and your own   |
| `POST /mapping-sets`              | Create a set                                            |
| `GET /mapping-sets/:id`           | One set with its rules                                  |
| `DELETE /mapping-sets/:id`        | Delete one of your sets (system sets cannot be deleted) |
| `POST /mapping-sets/:id/mappings` | Add a rule to one of your catalogue sets                |

## Create a set

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes |  |
| `description` | `string` |  |  |

## Add a rule

| Field | Type | Required | Description |
|---|---|---|---|
| `account_pattern` | `string` | yes |  |
| `secondary_pattern` | `string` |  |  |
| `target_metric` | `string` | yes |  |
| `sign_convention` | `"natural" \| "negate" \| "absolute"` |  |  |
| `aggregation_mode` | `"sum" \| "last"` |  |  |

A set owned by someone else returns `404`.
