# Meter routes: update, delete

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

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

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

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

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

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

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Meter. |
| `unit` | `string` | No | What it counts, such as calls or tokens. |
| `of` | `string` | No | The declared Event the Meter counts. |
| `aggregation` | `string` | No | How counted Events combine over the window: a sum of a value, a count, or the last value. |
| `window` | `string` | No | The period usage accrues over before it bills, such as a month. |

**Returns**

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

**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/meters/mtr_z08Ufi8LwY \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"unit":"call"}'
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "meter": {
    "$id": "https://api.sb/ratebook.dev/meters/mtr_z08Ufi8LwY",
    "$type": "Meter",
    "unit": "call",
    "of": "Reminder.sent",
    "aggregation": "sum",
    "window": "month"
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Meter.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```

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

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

Path: `id`. Emits `Meter.deleted`.

**Inputs**

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

**Returns**

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

**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/meters/mtr_z08Ufi8LwY \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/ratebook.dev",
  "meter": {
    "$id": "https://api.sb/ratebook.dev/meters/mtr_z08Ufi8LwY",
    "$type": "Meter",
    "unit": "call",
    "of": "Reminder.sent",
    "aggregation": "sum",
    "window": "month"
  },
  "action": {
    "$id": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq",
    "operation": "Meter.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ratebook.dev/actions/act_M5LgINdysq"
  }
}
```