Skip to content

Subscription methods: resume, switch, unsubscribe

The Subscription Verbs resume, switch, unsubscribe as typed SDK methods, with inputs, result, refusals and an example.

Reference for Subscription, one group of Subscription methods.

Subscription.resume

Resume restarts billing and Entitlements on a paused Subscription before its pause ends. Verb page.

TypeScript
interface SubscriptionVerbs {
  resume(input: SubscriptionResumeInput, options?: SB.CallOptions): SB.Call<Subscription>
}

Emits Subscription.resumed.

Inputs

InputTypeRequiredDescription
subscriptionSubscriptionrequiredThe paused Subscription.

Returns

OutputTypeRequiredDescription
subscriptionSubscriptionrequiredThe active Subscription.

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

TypeScript
import { $ } from 'startup-builder'

const subscription = await $.Subscription.resume({ subscription: 'sub_0Ij6oxjf6k' })

Subscription.switch

Switch moves a Subscription to another Offer and prorates the current period. Verb page.

TypeScript
interface SubscriptionVerbs {
  switch(input: SubscriptionSwitchInput, options?: SB.CallOptions): SB.Call<Subscription>
}

Emits Subscription.switched.

Inputs

InputTypeRequiredDescription
subscriptionSubscriptionrequiredThe Subscription to move.
offerOfferrequiredThe Offer to move to.
effectiveAtdatetimeWhen the move takes effect; moving existing Customers to a higher Price waits at least the notice period.

Returns

OutputTypeRequiredDescription
subscriptionSubscriptionrequiredThe Subscription on its new Offer.

Refuses when

CheckErrorFixThen call
The input does not match the schema of the operation.invalid-inputRead the schema of the operation, then send every required field with the right type.None.
The operation is part of an Offer the caller has not accepted or paid for.payment-requiredAccept the Offer named in the response, then retry the call.Offer.accept
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.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

TypeScript
import { $ } from 'startup-builder'

const subscription = await $.Subscription.switch({ subscription: 'sub_whVFaHKWIV', offer: 'offer_2hzYe1ERo0' })

Subscription.unsubscribe

Unsubscribe ends a Subscription at the close of its current period, and the Customer keeps access until then. Verb page.

TypeScript
interface SubscriptionVerbs {
  unsubscribe(input: SubscriptionUnsubscribeInput, options?: SB.CallOptions): SB.Call<Subscription>
}

Emits Subscription.unsubscribed.

Inputs

InputTypeRequiredDescription
subscriptionSubscriptionrequiredThe Subscription to end.
reasontextWhy the Customer leaves.
commenttextThe Customer’s own words, kept verbatim as the Evidence quote.

Returns

OutputTypeRequiredDescription
subscriptionSubscriptionrequiredThe Subscription, ending.

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.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

TypeScript
import { $ } from 'startup-builder'

const subscription = await $.Subscription.unsubscribe({ subscription: 'sub_whVFaHKWIV' })