Create Stripe customer portal session

Create Stripe Customer Portal Session.

Useful to redirect the customer to the Stripe Customer Portal to manage their payment methods,
change their billing address and access their invoice history.
Only returns URL if the customer billing profile is linked to a stripe app and customer.

post

Path Parameters

customerIdstringrequired

ULID (Universally Unique Lexicographically Sortable Identifier).

Match pattern:^[0-7][0-9A-HJKMNP-TV-Z]{25}$

Example:01G65Z755AFWAKHE12NY0CQ9FH

Body

application/json

BillingCustomerStripeCreateCustomerPortalSessionRequest

Request to create a Stripe Customer Portal Session for the customer.

Useful to redirect the customer to the Stripe Customer Portal to manage their payment methods,
change their billing address and access their invoice history.
Only returns URL if the customer billing profile is linked to a stripe app and customer.

stripe_optionsobjectrequired

Options for configuring the Stripe Customer Portal Session.

Show Child Parameters

Response

application/json

CreateStripeCustomerPortalSessionResult created response.

BillingAppStripeCreateCustomerPortalSessionResult

Result of creating a Stripe Customer Portal Session.

Contains all the information needed to redirect the customer to the Stripe Customer Portal.

idstringrequired
stripe_customer_idstringrequired

The ID of the stripe customer.

configuration_idstringrequired
created_atstring(date-time)required

Example:2023-01-01T01:01:01.001Z

localestringrequired

The IETF language tag of the locale customer portal is displayed in.

See: https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-locale

urlstringrequired

The URL to redirect the customer to after they have completed
their requested actions.

post/openmeter/customers/{customerId}/billing/stripe/portal-sessions

Body

{ "stripe_options": {} }
 
application/json

Metering Events

Metering events are used to track usage of your product or service. Events are processed asynchronously by the meters, so they may not be immediately available for querying.

Ingest metering events

Ingests an event or batch of events following the CloudEvents specification.

post

Body

Metering Event

Metering event following the CloudEvents specification.

idstringrequired

Identifies the event.

>= 1 characters

Example:5c10fade-1c9e-4d6c-8275-c52c36731d3c

sourcestring(uri-reference)required

Identifies the context in which an event happened.

>= 1 characters

Example:service-name

specversionstringrequired

The version of the CloudEvents specification which the event uses.

Default:1.0

>= 1 characters

Example:1.0

typestringrequired

Contains a value describing the type of event related to the originating occurrence.

>= 1 characters

Example:com.example.someevent

datacontenttypestring | null

Content type of the CloudEvents data value. Only the value “application/json” is allowed over HTTP.

Allowed values:application/json

Example:application/json

dataschemastring | null(uri)

Identifies the schema that data adheres to.

>= 1 characters

subjectstringrequired

Describes the subject of the event in the context of the event producer (identified by source).

>= 1 characters

Example:customer-id

timestring | null(date-time)

Timestamp of when the occurrence happened. Must adhere to RFC 3339.

Example:2023-01-01T01:01:01.001Z

dataobject | null

The event payload.
Optional, if present it must be a JSON object.

Response

The events have been ingested and are being processed asynchronously.

post/openmeter/events

Body

{ "specversion": "1.0", "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c", "source": "service-name", "type": "prompt", "subject": "customer-id", "time": "2023-01-01T01:01:01.001Z", "data": { "prompt": "Hello, world!", "tokens": 100, "model": "gpt-4o", "type": "input" } }
 

Meters

Meters specify how to aggregate events for billing and analytics purposes. Meters can be configured with multiple aggregation methods and groupings. Multiple meters can be created for the same event type, enabling flexible metering scenarios.

Create meter

Create a meter.

post

Body

application/json

CreateMeterRequest

Meter create request.

namestringrequired

Display name of the resource.

Between 1 and 256 characters.

>= 1 characters<= 256 characters

descriptionstring

Optional description of the resource.

Maximum 1024 characters.

<= 1024 characters

labelsobject

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 “_”.

Example:{"env":"test"}

keystringrequired

A key is a unique string that is used to identify a resource.

Match pattern:^[a-z0-9]+(?:_[a-z0-9]+)*$

>= 1 characters<= 64 characters

Example:resource_key

aggregationstringrequired

The aggregation type to use for the meter.

Allowed values:sumcountunique_countavgminmaxlatest

event_typestringrequired

The event type to include in the aggregation.

>= 1 characters

Example:prompt

events_fromstring(date-time)

The date since the meter should include events.
Useful to skip old events.
If not specified, all historical events are included.

Example:2023-01-01T01:01:01.001Z

value_propertystring

JSONPath expression to extract the value from the ingested event’s data property.

The ingested value for sum, avg, min, and max aggregations is a number or a string that can be parsed to a number.

For unique_count aggregation, the ingested value must be a string. For count aggregation the value_property is ignored.

>= 1 characters

Example:$.tokens

dimensionsobject

Named JSONPath expressions to extract the group by values from the event data.

Keys must be unique and consist only alphanumeric and underscore characters.

Example:{"type":"$.type"}

Response

application/json

Meter created response.

Meter

A meter is a configuration that defines how to match and aggregate events.

idstringrequiredread-only

ULID (Universally Unique Lexicographically Sortable Identifier).

Match pattern:^[0-7][0-9A-HJKMNP-TV-Z]{25}$

Example:01G65Z755AFWAKHE12NY0CQ9FH

namestringrequired

Display name of the resource.

Between 1 and 256 characters.

>= 1 characters<= 256 characters

descriptionstring

Optional description of the resource.

Maximum 1024 characters.

<= 1024 characters

labelsobject

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 “_”.

Example:{"env":"test"}

created_atstring(date-time)read-only

An ISO-8601 timestamp representation of entity creation date.

Example:2023-01-01T01:01:01.001Z

updated_atstring(date-time)read-only

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

Example:2023-01-01T01:01:01.001Z

deleted_atstring(date-time)read-only

An ISO-8601 timestamp representation of entity deletion date.

Example:2023-01-01T01:01:01.001Z

keystringrequired

A key is a unique string that is used to identify a resource.

Match pattern:^[a-z0-9]+(?:_[a-z0-9]+)*$

>= 1 characters<= 64 characters

Example:resource_key

aggregationstringrequired

The aggregation type to use for the meter.

Allowed values:sumcountunique_countavgminmaxlatest

event_typestringrequired

The event type to include in the aggregation.

>= 1 characters

Example:prompt

events_fromstring(date-time)

The date since the meter should include events.
Useful to skip old events.
If not specified, all historical events are included.

Example:2023-01-01T01:01:01.001Z

value_propertystring

JSONPath expression to extract the value from the ingested event’s data property.

The ingested value for sum, avg, min, and max aggregations is a number or a string that can be parsed to a number.

For unique_count aggregation, the ingested value must be a string. For count aggregation the value_property is ignored.

>= 1 characters

Example:$.tokens

dimensionsobject

Named JSONPath expressions to extract the group by values from the event data.

Keys must be unique and consist only alphanumeric and underscore characters.

Example:{"type":"$.type"}

post/openmeter/meters

Body

{ "name": "name", "key": "resource_key", "aggregation": "sum", "event_type": "prompt" }
 
application/json