Skip to content

Meter routes: update, delete

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

Reference for Meter, one group of Meter routes.

Meter.update

Changes the given properties of a Meter. Verb page.

Text
PATCH /{namespace}/meters/{id}

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

Inputs

InputTypeRequiredDescription
idstringrequiredThe id of the Meter.
unitstringWhat it counts, such as calls or tokens.
ofstringThe declared Event the Meter counts.
aggregationstringHow counted Events combine over the window: a sum of a value, a count, or the last value.
windowstringThe period usage accrues over before it bills, such as a month.

Returns

OutputTypeRequiredDescription
meterMeterrequiredThe Meter.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
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.

Text
DELETE /{namespace}/meters/{id}

Path: id. Emits Meter.deleted.

Inputs

InputTypeRequiredDescription
idstringrequiredThe id of the Meter.

Returns

OutputTypeRequiredDescription
meterMeterrequiredThe Meter.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
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"
  }
}