# Mapping routes: update, delete

URL: /code/api/mapping/records-update · Id: `page:code/api/mapping/records-update`

> The Mapping Verbs update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Mapping](/business/nouns/mapping), one group of [Mapping routes](/code/api/mapping).

### Mapping.update
Changes the given properties of a Mapping. [Verb page](/business/nouns/mapping/update?interface=api).

```text
PATCH /{namespace}/mappings/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Mapping.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Mapping. |
| `verb` | `string` | No | The Verb it serves, such as `Meeting.book`; a Verb has many Mappings, ranked. |
| `fields` | `json` | No | Each outside field or event and the Noun property or Event it maps to. |
| `direction` | `string` | No | `both` still keeps db.sb the record; the outside tool never becomes a second one. |
| `convert` | `text` | No | How a value changes on the way, such as cents to money or a picklist to closed values. |
| `rank` | `integer` | No | Order tried when the preferred Mapping fails or finds nothing; the Policy orders it by cost per accepted result. |
| `preferred` | `boolean` | No | True for the Mapping a Verb tries first. |
| `door` | `string` | No | How the outside endpoint is classed; an unclassed write is one-way and waits its delay window. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `mapping` | [Mapping](/business/nouns/mapping) | Yes | The Mapping. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X PATCH https://api.sb/ratebook.dev/mappings/mapping_WOromrQi6J \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"verb":"Meeting.book"}'
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "mapping": {
    "$id": "https://api.sb/ratebook.dev/mappings/mapping_WOromrQi6J",
    "$type": "Mapping",
    "verb": "Meeting.book",
    "fields": {}
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Mapping.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```

### Mapping.delete
Deletes a Mapping: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/mapping/delete?interface=api).

```text
DELETE /{namespace}/mappings/{id}
```

Path: `id`. Emits `Mapping.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Mapping. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `mapping` | [Mapping](/business/nouns/mapping) | Yes | The Mapping. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X DELETE https://api.sb/ratebook.dev/mappings/mapping_WOromrQi6J \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "mapping": {
    "$id": "https://api.sb/ratebook.dev/mappings/mapping_WOromrQi6J",
    "$type": "Mapping",
    "verb": "Meeting.book",
    "fields": {}
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Mapping.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```