OpenMeter Entitlements

Create customer entitlement grant

Changed on

Pre-release Endpoint This endpoint is currently in beta and is subject to change.

Issue a grant for a metered entitlement of the customer. Boolean and static entitlements cannot have grants, so the request is rejected for them.

Grants are immutable. The amount is added to the balance from effective_at, which cannot be earlier than the start of the current usage period.

post/v3/openmeter/customers/{customerId}/entitlements/{entitlementId}/grants

Request

  • Base URL
    https://global.api.konghq.com
  • Auth
    • HTTP bearer
    • or HTTP bearer
    • or HTTP bearer
    • or HTTP bearer

Path parameters

customerId, string required

ULID (Universally Unique Lexicographically Sortable Identifier).

Example:01G65Z755AFWAKHE12NY0CQ9FH
entitlementId, string required

ULID (Universally Unique Lexicographically Sortable Identifier).

Example:01G65Z755AFWAKHE12NY0CQ9FH

Request body

BillingEntitlementGrantCreateRequest required

A grant to issue for a metered entitlement.

amount, string required

The amount to grant, in the feature's unit. Must be positive.

priority, integer

The priority of the grant. Lower values have higher priority. Grants are consumed in priority order, then by closest expiration, then by earliest creation.

effective_at, string date-time required

The time the grant becomes effective and the anchor for recurring grants. The value is truncated to the start of the minute.

expires_after, string ISO8601

The duration after which the grant expires, counted from effective_at. Only single-unit durations are accepted, such as PT12H, P7D, P2W, P3M, or P1Y. If omitted, the grant never expires.

max_rollover_amount, string

The maximum balance carried over at reset. The balance after a reset is MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount)). Defaults to amount.

min_rollover_amount, string

The minimum balance carried over at reset. The balance after a reset is MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount)). Defaults to 0.

labels, object

Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

recurrence, object

The recurrence of the grant. When set, the amount is issued again every interval. The anchor defaults to effective_at.

Example request

{
  "amount": "100",
  "priority": 1,
  "effective_at": "2023-01-01T01:01:01.001Z",
  "expires_after": "P1M",
  "max_rollover_amount": "100",
  "min_rollover_amount": "0",
  "labels": {
    "env": "test"
  },
  "recurrence": {
    "interval": "P1M",
    "anchor": "2023-01-01T01:01:01.001Z"
  }
}

Response

EntitlementGrant created response.

BillingEntitlementGrant required

A grant issued for a metered entitlement. Each grant adds its amount to the entitlement's balance from its effective time until it expires, and usage is deducted from the grants in priority order.

Grants are immutable, so the balance is deterministic regardless of when it is queried. Deleting a grant ends it at the time of the deletion.

id, string required

ULID (Universally Unique Lexicographically Sortable Identifier).

entitlement_id, string required

The ID of the entitlement the grant belongs to.

customer_id, string

The ID of the customer the grant belongs to.

amount, string required

The granted amount, in the feature's unit.

priority, integer required

The priority of the grant. Lower values are consumed first: a grant with priority 1 is consumed before one with priority 2. Among equal priorities, the grant closest to expiration is consumed first, then the earliest created.

effective_at, string date-time required

The time the grant takes effect.

expires_after, string ISO8601

The duration after which the grant expires, counted from effective_at. Always a single-unit duration (for example PT12H, P7D, P2W, P3M, P1Y). Absent when the grant never expires.

expires_at, string date-time

The time the grant expires, calculated from effective_at and expires_after. The grant is no longer in effect from this time. Absent when the grant never expires.

max_rollover_amount, string required

The maximum balance the grant carries over at reset. The balance after a reset is MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount)).

min_rollover_amount, string required

The minimum balance the grant carries over at reset. The balance after a reset is MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount)).

recurrence, object

The recurrence of the grant. When set, the grant amount is re-issued every interval from the anchor, which defaults to effective_at. Absent for non-recurring grants.

next_recurrence, string date-time

The next time the grant recurs. Absent for non-recurring grants.

voided_at, string date-time

The time the grant was voided. A voided grant is no longer in effect from this time.

labels, object

Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

created_at, string date-time required

An ISO-8601 timestamp representation of entity creation date.

updated_at, string date-time required

An ISO-8601 timestamp representation of entity last update date.

deleted_at, string date-time

An ISO-8601 timestamp representation of entity deletion date.

Example response

{
  "id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "entitlement_id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "customer_id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "amount": "100",
  "priority": 1,
  "effective_at": "2023-01-01T01:01:01.001Z",
  "expires_after": "P1M",
  "expires_at": "2023-02-01T01:01:01.001Z",
  "max_rollover_amount": "100",
  "min_rollover_amount": "0",
  "recurrence": {
    "anchor": "2023-01-01T01:01:01.001Z",
    "interval": "P1M"
  },
  "next_recurrence": "2023-02-01T01:01:01.001Z",
  "voided_at": "2023-01-15T01:01:01.001Z",
  "labels": {
    "env": "test"
  },
  "created_at": "2023-01-01T01:01:01.001Z",
  "updated_at": "2023-01-01T01:01:01.001Z",
  "deleted_at": "2023-01-01T01:01:01.001Z"
}

Changes

    • breaking

      added to the invalid_parameters/items response property oneOf list for the response status

    • warning

      added the new key_invalid enum value to the invalid_parameters/items/oneOf[#/components/schemas/InvalidParameterStandard]/rule response property for the response status

    • warning

      added the new unique enum value to the invalid_parameters/items/oneOf[#/components/schemas/InvalidParameterStandard]/rule response property for the response status