Create a Subscription

This guide is for developers looking to enable subscription creation via our Subscriptions API.

📰

Overview

This guide covers subscription creation including, prerequisites, setting up a reusable plan, optionally creating a coupon for discounts, and linking a customer with a stored payment method to the subscription. By following these steps, developers can automate billing.

Prerequisites

Before you begin, make sure you have:

Having these in place ensures you can successfully create subscriptions without encountering authentication or missing data errors.

Before You Start: Prepare a Customer with a Payment Method

Step 1: Create a Customer

Subscriptions must be linked to an existing customer.

  • If you do not have a customer: Follow the Create Customer guide to create one. Be sure to note the returned customer_id, as it will be required to associate the subscription with this customer.
  • If you already have a customer: Retrieve the customer_id for the customer you want to attach the subscription to.

Step 2: Attach a Payment Method to a Customer

Before creating a subscription, the customer must have a payment method attached. There are two options for storing a payment method:

  • Option 1: Tokenize a Card

    Use our Create a Token - Card endpoint to generate a token representing a card and then attach that token to the customer.
  • Option 2: Add a bank account

    Create and store a bank account for the customer using the Create Bank Account endpoint.
📘

For complete instructions on tokenizing a card and attaching it to a customer, or storing a bank account for a customer, refer to our Storing Payment Methods guide.


Step 1: Create a Plan


Before creating a subscription, you need a plan. A plan defines a billing structure (amount, frequency, and cadence) that can be reused across multiple subscriptions.

If you already have a plan configured, you can skip this step and use your existing plan_id. To see all your available plans, use List All Plans.

  • To create a plan, see the API Reference here.
  • What you get back: The API response will include a plan_id, which uniquely identifies your plan and is required in the next step.

You can either provide your own plan_id when creating the plan, or let Payarc generate one automatically (e.g., plan_de2c4146).


Step 2 (optional): Create a Coupon


If you wish to offer either a percent off subscriptions, or an amount off, you can create a coupon, and at the next step, apply it to a subscription. The same coupon can be applied to multiple subscriptions.

If you have already created a coupon, grab its ID and skip to the next step.

  • To create a coupon, see the API Reference: here
  • What you get back: The response includes a discount_id (e.g., dc_c7cc1e9c), which you can apply when creating a subscription.
💡

Tip: If you want to offer high-value discounts, or discounts personalized to certain groups of users, you should use a discount code name that is hard to guess or randomly generated, instead.


Step 3: Create a Subscription


Once you have a plan (and optionally a coupon), you can create a subscription for a specific customer. This links the customer to the plan and defines how billing will occur.

  • To create a subscription, see the API Reference: here
  • What you get back: The response includes a subscription_id, representing the active subscription for the customer. This ID is used for tracking, updates, or cancellations.
💡

Tip: Set billing_type=1 to automatically charge the customer’s card on file.