Vatly
Php

Subscriptions

Vatly PHP SDK - Subscriptions

Subscriptions are created automatically when a customer completes a checkout for a subscription plan. You can then manage the subscription lifecycle through the API.

The Subscription Resource

Below you'll find all properties for the Vatly Subscription resource.

Properties

NameTypeDescription
idstringUnique identifier for the subscription (subscription_...).
resourcestringResource type, always subscription.
customerIdstringID of the customer who owns this subscription.
subscriptionPlanIdstringID of the subscription plan this subscription is based on.
testmodeboolWhether this subscription is in test mode.
namestringName of the subscription (from the plan).
descriptionstringDescription of the subscription.
billingAddressAddressCustomer's billing address for this subscription.
basePriceMoneyPrice per billing cycle before taxes.
quantityintNumber of subscription units (e.g. seats).
intervalstringBilling interval unit: day, week, month, or year.
intervalCountintNumber of interval units between billing cycles.
statusstringThe subscription status (see Subscription statuses).
startedAtstringWhen the subscription started (ISO 8601).
endedAtstring | nullWhen the subscription ended (ISO 8601).
canceledAtstring | nullWhen the subscription was canceled (ISO 8601).
renewedAtstring | nullWhen the subscription was last renewed (ISO 8601).
renewedUntilstring | nullCurrent billing period end date (ISO 8601).
nextRenewalAtstring | nullWhen the next renewal will be attempted (ISO 8601). Null if canceled or ended.
trialUntilstring | nullWhen the trial period ends (ISO 8601). Null if not in trial or trial has ended.
mandateMandate | nullPayment method on file (method, maskedIdentifier). Null when the subscription has no mandate yet.
linksSubscriptionLinksHATEOAS links to related resources (self, customer).

Retrieve a subscription

GET /v1/subscriptions/:id

Retrieve a subscription by its ID.

$subscription = $vatly->subscriptions->get('subscription_abc123');

echo $subscription->status;
echo $subscription->subscriptionPlanId;

if ($subscription->isActive()) {
    echo 'Subscription is active';
}

List all subscriptions

GET /v1/subscriptions

Retrieve a paginated list of all subscriptions.

Optional attributes

NameTypeDescription
limitintegerThe number of subscriptions to return (default: 10, max: 100).
startingAfterstringA cursor for pagination.
customerIdstringFilter by customer ID.
$subscriptions = $vatly->subscriptions->list();

foreach ($subscriptions as $subscription) {
    echo $subscription->id . ': ' . $subscription->status;
}

// Filter by customer
$subscriptions = $vatly->subscriptions->list([
    'customerId' => 'customer_abc123',
]);

Update a subscription

PATCH /v1/subscriptions/:id

Update mutable subscription fields such as quantity.

$subscription = $vatly->subscriptions->update('subscription_123', [
    'quantity' => 2,
], [
    'idempotencyKey' => 'subscription-update-123',
]);

If you already have a Subscription resource instance, set the key on the client before calling the resource method:

$vatly->setIdempotencyKey('subscription-update-123');

$subscription->update([
    'quantity' => 2,
]);

If you do not provide a custom key, the SDK generates one automatically for the PATCH request.


Cancel a subscription

DELETE /v1/subscriptions/:id

Cancel a subscription. The subscription will remain active until the end of the current billing period.

$subscription = $vatly->subscriptions->cancel('subscription_abc123');

// Subscription is now on grace period until current period ends
echo $subscription->status;        // 'on_grace_period'
echo $subscription->renewedUntil;  // Current billing period end

Resume a subscription

POST /v1/subscriptions/:id/resume

Reverse a pending cancellation while the subscription is still on its grace period. Once a subscription has fully ended it cannot be resumed.

$subscription = $vatly->subscriptions->resume('subscription_abc123');

echo $subscription->status; // 'active'

If you already have a Subscription resource instance:

$subscription->resume();

Subscription statuses

StatusDescription
activeSubscription is active and will renew
createdSubscription has been created but not yet started
trialSubscription is in trial period
on_grace_periodSubscription is canceled but still active until the period ends
pausedSubscription is temporarily paused
canceledSubscription has been canceled

Helper methods

The Subscription object provides convenient helper methods.

$subscription->isActive();         // true if status is 'active'
$subscription->isTrial();          // true if status is 'trial'
$subscription->isOnGracePeriod();  // true if status is 'on_grace_period'
$subscription->isCanceled();       // true if status is 'canceled'
Copyright © 2026