Knox Docs Sign in

API reference

Test mode. Use your secret key on your server; live processing is currently disabled.

https://api.knoxapi.com

Send form-encoded requests with Authorization: Bearer sk_test_....

Complete OpenAPI specification · Integration guide

Operations and schemas are based on the pinned Stripe OpenAPI specification (MIT). Nested object definitions and enums are available in the complete specification.

GET /v1/subscription_items

List all subscription items

Returns a list of your subscription items for a given subscription.

Request parameters

ParameterLocationTypeDescription
ending_beforequerystringA cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
expandqueryarray of stringSpecifies which fields in the response should be expanded.
limitqueryintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
starting_afterquerystringA cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
subscriptionquerystringThe ID of the subscription whose items will be retrieved.

object. See the OpenAPI specification for the complete schema.

Responses

HTTP 200: Successful response.
FieldTypeDescription
data requiredarray of subscription_item
has_more requiredbooleanTrue if this list has another page of items after this one that can be fetched.
object requiredstringString representing the object's type. Objects of the same type share the same value. Always has the value `list`.
url requiredstringThe URL where this list can be accessed.
HTTP default: Error response.
FieldTypeDescription
error requiredapi_errors
POST /v1/subscription_items

Create a subscription item

Adds a new item to an existing subscription. No existing items will be changed or replaced.

Request parameters

FieldTypeDescription
billing_thresholdsone of multiple schemasDefine thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
discountsone of multiple schemasThe coupons to redeem into discounts for the subscription item.
expandarray of stringSpecifies which fields in the response should be expanded.
metadataobjectSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
payment_behaviorstringControls how Stripe handles payment when a subscription update requires payment and `collection_method=charge_automatically`.
pricestringThe ID of the price object.
price_dataobjectData used to generate a new [Price](https://docs.stripe.com/api/prices) object inline.
proration_behaviorstringDetermines how to handle [prorations](https://docs.stripe.com/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
proration_dateintegerIf set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply the same proration that was previewed with the [upcoming invoice](/api/invoices/create_preview) endpoint.
quantityintegerThe quantity you'd like to apply to the subscription item you're creating.
subscription requiredstringThe identifier of the subscription to modify.
tax_ratesone of multiple schemasA list of [Tax Rate](https://docs.stripe.com/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://docs.stripe.com/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.

Responses

HTTP 200: Successful response.
FieldTypeDescription
billed_untilintegerThe time period the subscription item has been billed for.
billing_thresholdsone of multiple schemasDefine thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
created requiredintegerTime at which the object was created. Measured in seconds since the Unix epoch.
current_period_end requiredintegerThe end time of this subscription item's current billing period.
current_period_start requiredintegerThe start time of this subscription item's current billing period.
discounts requiredarray of one of multiple schemasThe discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount.
id requiredstringUnique identifier for the object.
metadata requiredobjectSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
object requiredstringString representing the object's type. Objects of the same type share the same value.
price requiredprice
quantityintegerThe [quantity](https://docs.stripe.com/subscriptions/quantities) of the plan to which the customer should be subscribed.
subscription requiredstringThe `subscription` this `subscription_item` belongs to.
tax_ratesarray of tax_rateThe tax rates which apply to this `subscription_item`. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`.
HTTP default: Error response.
FieldTypeDescription
error requiredapi_errors
DELETE /v1/subscription_items/{item}

Delete a subscription item

Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.

Request parameters

ParameterLocationTypeDescription
itempathstring
FieldTypeDescription
clear_usagebooleanDelete all usage for the given subscription item. Allowed only when the current plan's `usage_type` is `metered`.
payment_behaviorstringControls how Stripe handles payment when a subscription update requires payment and `collection_method=charge_automatically`.
proration_behaviorstringDetermines how to handle [prorations](https://docs.stripe.com/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
proration_dateintegerIf set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply the same proration that was previewed with the [upcoming invoice](/api/invoices/create_preview) endpoint.

Responses

HTTP 200: Successful response.
FieldTypeDescription
deleted requiredbooleanAlways true for a deleted object
id requiredstringUnique identifier for the object.
object requiredstringString representing the object's type. Objects of the same type share the same value.
HTTP default: Error response.
FieldTypeDescription
error requiredapi_errors
GET /v1/subscription_items/{item}

Retrieve a subscription item

Retrieves the subscription item with the given ID.

Request parameters

ParameterLocationTypeDescription
expandqueryarray of stringSpecifies which fields in the response should be expanded.
itempathstring

object. See the OpenAPI specification for the complete schema.

Responses

HTTP 200: Successful response.
FieldTypeDescription
billed_untilintegerThe time period the subscription item has been billed for.
billing_thresholdsone of multiple schemasDefine thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
created requiredintegerTime at which the object was created. Measured in seconds since the Unix epoch.
current_period_end requiredintegerThe end time of this subscription item's current billing period.
current_period_start requiredintegerThe start time of this subscription item's current billing period.
discounts requiredarray of one of multiple schemasThe discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount.
id requiredstringUnique identifier for the object.
metadata requiredobjectSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
object requiredstringString representing the object's type. Objects of the same type share the same value.
price requiredprice
quantityintegerThe [quantity](https://docs.stripe.com/subscriptions/quantities) of the plan to which the customer should be subscribed.
subscription requiredstringThe `subscription` this `subscription_item` belongs to.
tax_ratesarray of tax_rateThe tax rates which apply to this `subscription_item`. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`.
HTTP default: Error response.
FieldTypeDescription
error requiredapi_errors
POST /v1/subscription_items/{item}

Update a subscription item

Updates the plan or quantity of an item on a current subscription.

Request parameters

ParameterLocationTypeDescription
itempathstring
FieldTypeDescription
billing_thresholdsone of multiple schemasDefine thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.
discountsone of multiple schemasThe coupons to redeem into discounts for the subscription item.
expandarray of stringSpecifies which fields in the response should be expanded.
metadataone of multiple schemasSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
off_sessionbooleanIndicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `false` (on-session).
payment_behaviorstringControls how Stripe handles payment when a subscription update requires payment and `collection_method=charge_automatically`.
pricestringThe ID of the price object. One of `price` or `price_data` is required. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided.
price_dataobjectData used to generate a new [Price](https://docs.stripe.com/api/prices) object inline. One of `price` or `price_data` is required.
proration_behaviorstringDetermines how to handle [prorations](https://docs.stripe.com/billing/subscriptions/prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. The default value is `create_prorations`.
proration_dateintegerIf set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply the same proration that was previewed with the [upcoming invoice](/api/invoices/create_preview) endpoint.
quantityintegerThe quantity you'd like to apply to the subscription item you're creating.
tax_ratesone of multiple schemasA list of [Tax Rate](https://docs.stripe.com/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://docs.stripe.com/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates.

Responses

HTTP 200: Successful response.
FieldTypeDescription
billed_untilintegerThe time period the subscription item has been billed for.
billing_thresholdsone of multiple schemasDefine thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
created requiredintegerTime at which the object was created. Measured in seconds since the Unix epoch.
current_period_end requiredintegerThe end time of this subscription item's current billing period.
current_period_start requiredintegerThe start time of this subscription item's current billing period.
discounts requiredarray of one of multiple schemasThe discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount.
id requiredstringUnique identifier for the object.
metadata requiredobjectSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
object requiredstringString representing the object's type. Objects of the same type share the same value.
price requiredprice
quantityintegerThe [quantity](https://docs.stripe.com/subscriptions/quantities) of the plan to which the customer should be subscribed.
subscription requiredstringThe `subscription` this `subscription_item` belongs to.
tax_ratesarray of tax_rateThe tax rates which apply to this `subscription_item`. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`.
HTTP default: Error response.
FieldTypeDescription
error requiredapi_errors