OpenMeter Subscriptions

Create subscription

Changed on
post/v3/openmeter/subscriptions

Request

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

Request body

BillingSubscriptionCreate required
labels, Labels

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 "_".

settlement_mode, 'credit_then_invoice' | 'credit_only'

Settlement mode for billing.

Values:

  • credit_then_invoice: Credits are applied first, then any remainder is invoiced.
  • credit_only: Usage is settled exclusively against credits.
customer, object required

The customer to create the subscription for.

plan, object

A reference to a published plan the subscription is created from.

Exactly one of plan or custom_plan must be provided. Use plan to base the subscription on an existing published plan; use custom_plan to define the plan inline.

custom_plan, object

An inline plan definition to create the subscription from, without referencing a published plan.

Exactly one of plan or custom_plan must be provided. The subscription is not linked to a persisted plan, so the response omits the plan reference.

starting_phase, string

The key of the phase to start the subscription in. If not provided, the subscription starts in the first phase of the plan.

Only applies when creating from a published plan; custom plans define their own phases inline.

timing, union

When the subscription should start. If not provided, the subscription starts immediately. Provide a future timestamp to schedule the subscription to start later — this creates a not-yet-active, scheduled subscription. A timestamp in the past is rejected.

billing_anchor, string date-time

A billing anchor is the fixed point in time that determines the subscription's recurring billing cycle. It affects when charges occur and how prorations are calculated. Common anchors:

  • Calendar month (1st of each month): 2025-01-01T00:00:00Z
  • Subscription anniversary (day customer signed up)
  • Custom date (customer-specified day)

If not provided, the subscription will be created with the subscription's creation time as the billing anchor.

cost_basis_mode, 'dynamic' | 'pinned'

Controls how custom-currency cost bases are selected for the subscription.

Example request

{
  "labels": {
    "env": "test"
  },
  "customer": {
    "id": "01G65Z755AFWAKHE12NY0CQ9FH",
    "key": "019ae40f-4258-7f15-9491-842f42a7d6ac"
  },
  "plan": {
    "id": "01G65Z755AFWAKHE12NY0CQ9FH",
    "key": "resource_key"
  },
  "custom_plan": {
    "labels": {
      "env": "test"
    },
    "currency": "USD",
    "billing_cadence": "P1Y",
    "phases": [
      {
        "labels": {
          "env": "test"
        },
        "key": "resource_key",
        "duration": "P1Y",
        "rate_cards": [
          {
            "labels": {
              "env": "test"
            },
            "key": "resource_key",
            "feature": {
              "id": "01G65Z755AFWAKHE12NY0CQ9FH"
            },
            "currency": "USD",
            "billing_cadence": "P1Y",
            "tax_config": {
              "code": {
                "id": "01G65Z755AFWAKHE12NY0CQ9FH"
              }
            },
            "entitlement": {
              "usage_period": "P1Y"
            }
          }
        ]
      }
    ]
  },
  "timing": "2023-01-01T01:01:01.001Z",
  "billing_anchor": "2023-01-01T01:01:01.001Z"
}

Response

Subscription created response.

BillingSubscription required

Subscription.

id, string required

ULID (Universally Unique Lexicographically Sortable Identifier).

labels, Labels

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.

name, string required

Display name of the subscription. Defaults to the plan name when the subscription is created from a plan.

description, string

Optional description of the subscription.

active_from, string date-time required

An ISO-8601 timestamp representation of when the subscription became (or will become) active.

active_to, string date-time

An ISO-8601 timestamp representation of when the subscription stops being active. Open-ended when not set.

customer_id, string required

The customer ID of the subscription.

plan_id, string

The plan ID of the subscription. Set if subscription is created from a plan.

plan, object

The plan the subscription was created from, if any. Includes the plan key and version so clients can resolve the exact plan revision.

invoice_currency, string required

The fiat currency in which the subscription is invoiced.

cost_basis_mode, 'dynamic' | 'pinned' required

Controls whether custom-currency cost bases are resolved dynamically or pinned when their currency pair is introduced to the subscription.

cost_basis_pins, BillingSubscriptionCostBasisPin[] required

Cost bases pinned to custom-currency pairs for this subscription.

billing_cadence, string ISO8601 required

The billing cadence of the subscription in ISO-8601 duration format. Defines how often the customer is billed. Examples: P1M (monthly), P3M (quarterly), P1Y (annually).

pro_rating_config, object

The pro-rating configuration of the subscription.

billing_anchor, string date-time required

A billing anchor is the fixed point in time that determines the subscription's recurring billing cycle. It affects when charges occur and how prorations are calculated. Common anchors:

  • Calendar month (1st of each month): 2025-01-01T00:00:00Z
  • Subscription anniversary (day customer signed up)
  • Custom date (customer-specified day)
status, 'active' | 'inactive' | 'canceled' | 'scheduled' required

The status of the subscription.

settlement_mode, 'credit_then_invoice' | 'credit_only'

Settlement mode for billing.

Values:

  • credit_then_invoice: Credits are applied first, then any remainder is invoiced.
  • credit_only: Usage is settled exclusively against credits.
current_period, object

The current aligned billing period. Present only when the subscription is active and aligned.

phases, BillingSubscriptionPhase[] required

The phases of the subscription in chronological order. A phase groups the rate cards that are in effect for a segment of the subscription's lifetime.

Example response

{
  "id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "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",
  "active_from": "2023-01-01T01:01:01.001Z",
  "active_to": "2023-01-01T01:01:01.001Z",
  "customer_id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "plan_id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "plan": {
    "id": "01G65Z755AFWAKHE12NY0CQ9FH",
    "key": "resource_key"
  },
  "invoice_currency": "USD",
  "cost_basis_pins": [
    {
      "custom_currency_id": "01G65Z755AFWAKHE12NY0CQ9FH",
      "invoice_currency": "USD",
      "cost_basis_id": "01G65Z755AFWAKHE12NY0CQ9FH"
    }
  ],
  "billing_cadence": "P1Y",
  "billing_anchor": "2023-01-01T01:01:01.001Z",
  "current_period": {
    "from": "2023-01-01T01:01:01.001Z",
    "to": "2023-01-01T01:01:01.001Z"
  },
  "phases": [
    {
      "id": "01G65Z755AFWAKHE12NY0CQ9FH",
      "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",
      "key": "resource_key",
      "active_from": "2023-01-01T01:01:01.001Z",
      "active_to": "2023-01-01T01:01:01.001Z",
      "items": [
        {
          "id": "01G65Z755AFWAKHE12NY0CQ9FH",
          "active_from": "2023-01-01T01:01:01.001Z",
          "active_to": "2023-01-01T01:01:01.001Z",
          "rate_card": {
            "labels": {
              "env": "test"
            },
            "key": "resource_key",
            "feature": {
              "id": "01G65Z755AFWAKHE12NY0CQ9FH"
            },
            "currency": "USD",
            "billing_cadence": "P1Y",
            "tax_config": {
              "code": {
                "id": "01G65Z755AFWAKHE12NY0CQ9FH"
              }
            },
            "entitlement": {
              "usage_period": "P1Y"
            }
          }
        }
      ]
    }
  ]
}

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