Skip to main content
POST
Cancel Subscription

Overview

Stops the renewals of an active or past_due subscription. By default the subscription ends at the end of the period the customer already paid for; pass at_period_end: false to end it immediately — this also works on a subscription already scheduled to end.
Customers can cancel by themselves (at period end only) from the management_url of their subscription — you don’t need to build a cancellation flow. See Let customers manage their subscription.

Authentication

This endpoint requires your Secret API Key (server-side only). See Authentication for details.

Path Parameters

string
required
The Payviox subscription ID (psub_...).

Body Parameters

boolean
default:"true"
true to end the subscription at current_period_end, false to end it now. Omitted, null or "" mean true; any other non-boolean value returns 400.

Response

The updated Subscription object. Calling it again with at_period_end: true on a subscription already scheduled to end returns 200 without changing anything (and keeps its cancel_requested_by). You can still end immediately a subscription the customer scheduled to cancel.

Example Requests

Example Response

Error Responses

at_period_end is neither a boolean nor empty (for example "maybe"). Omitted, null or "" mean true.
The API key is missing or invalid. This endpoint only accepts your Secret API Key.
No subscription with this ID belongs to your business (subscription_not_found).
The subscription has already ended — nothing to do. A 409 with The subscription changed meanwhile. Try again. means it was modified during your request: retry.
Stripe refused the change. Nothing was changed on Payviox’s side: contact support@payviox.com.
Stripe couldn’t be reached, or Stripe isn’t configured on your account anymore. Nothing was changed: retry later.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

subscription_id
string
required

Payviox subscription ID (psub_...)

Body

application/json
at_period_end
boolean
default:true

true (default, also when omitted, null or empty): the subscription ends at current_period_end, the customer keeps the period already paid, and you can undo it with resume. false: ends now and voids its unpaid Stripe invoices, so no retry can charge the customer; no automatic refund.

Response

Subscription updated (or already scheduled to cancel); returns the subscription

id
string
required

Payviox subscription ID (psub_ prefix)

status
enum<string>
required

active: paid up, renews automatically (also while a cancellation is scheduled, see cancel_at_period_end). past_due: the last renewal charge failed and Stripe is retrying it. canceled: ended, no further charges.

Available options:
active,
past_due,
canceled
amount
integer
required

Your price per period in cents — the amount of the signup session

unit_amount
integer
required

Amount charged to the customer at each renewal, in cents. Includes the fees added for the customer at checkout, but not one-time add-on fees (such as fraud screening) charged on the first payment only, so it can be lower than the first charge.

currency
string
required

Always USD

interval
enum<string>
required
Available options:
day,
week,
month,
year
interval_count
integer
required
interval_label
string
required

Human-readable period, e.g. every month, every 3 months

order_id
string
required

order_id of the signup session. Renewals use {order_id}-{cycle}

cycles_count
integer
required

Billing cycles started so far, signup included (1 = signup only). A renewal whose charge failed counts too.

cancel_at_period_end
boolean
required

true when the subscription is scheduled to end at current_period_end

initial_session_id
string
required

Session ID of the signup payment

created_at
string<date-time>
required
customer
string | null

Customer identifier from the signup session

customer_email
string | null

Customer email, from the signup session or entered at checkout

items
object[]

Items of the signup session (one period)

metadata
object

Metadata of the signup session

payment_method
enum<string>

Method the customer subscribed with (read with provider)

Available options:
credit,
apple_pay,
google_pay
provider
string

Provider that charges the renewals (stripe)

provider_subscription_id
string | null

ID of the subscription on your Stripe account (sub_...). null until Payviox has created it, usually within a minute of the first payment.

current_period_end
string<date-time> | null

End of the current billing period: date of the next renewal charge, or the date a scheduled cancellation takes effect

canceled_at
string<date-time> | null

When the subscription ended (null while not canceled)

canceled_by
enum<string> | null

Who ended it: api (your backend), manager (your dashboard), admin (Payviox support), payer (the customer, from the management link), provider (on Stripe, e.g. after failed retries or a cancellation in the Stripe dashboard), system (Payviox, e.g. signup payment refunded or setup_failed). null until the subscription is canceled.

Available options:
api,
manager,
admin,
payer,
provider,
system,
null
cancel_requested_by
enum<string> | null

Who scheduled the end-of-period cancellation: payer (the customer), api, manager (your dashboard), admin (Payviox support) or system. null when no cancellation is scheduled, or when it was scheduled from your Stripe dashboard. Only the same side can resume it: you (api, manager, null), the customer (payer) or Payviox (admin, system).

Available options:
payer,
api,
manager,
admin,
system,
null
cancellation_reason
string | null

Set as soon as a cancellation is requested or scheduled: requested_by_merchant, requested_by_customer, initial_payment_refunded, admin (canceled by Payviox support), setup_failed:<code>, or a Stripe reason such as payment_failed, cancellation_requested, provider or provider_deleted. Treat unknown values as informational.

management_url
string | null

Customer self-service page (view, cancel at period end, undo). Share it with your customer, e.g. in your confirmation email.