# Is specifying the "period" mandatory when creating a subscription with the Catalog API?

**URL:** <https://developer.squareup.com/forums/t/is-specifying-the-period-mandatory-when-creating-a-subscription-with-the-catalog-api/19089>\
**Category:** Questions\
**Tags:** payments-api\
**Created:** [October 9, 2024, 10:56am UTC](https://developer.squareup.com/forums/t/is-specifying-the-period-mandatory-when-creating-a-subscription-with-the-catalog-api/19089 "2024-10-09T10:56:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![funwarioisii](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@funwarioisii](https://developer.squareup.com/forums/u/funwarioisii)\
**Post date:** [October 9, 2024, 10:56am UTC](https://developer.squareup.com/forums/t/is-specifying-the-period-mandatory-when-creating-a-subscription-with-the-catalog-api/19089/1 "2024-10-09T10:56:08Z")

</div>

When creating a subscription with the Catalog API, is specifying the period mandatory?

Hello. I am developing a membership platform service using Square. I am creating a subscription plan with the following code.

```ruby
client.catalog.upsert_catalog_object(
        body: {
          idempotency_key: generate_idempotency_key,
          object: {
            id: item_id,
            type: 'SUBSCRIPTION_PLAN',
            subscription_plan_data: {
              name:,
              phases: [
                {
                  cadence: 'MONTHLY',
                  recurring_price_money: {
                    amount: price,
                    currency: 'JPY',
                  },
                },
              ],
            },
          },
        },
      )

```

When I retrieve this subscription plan, I receive an object like the following. I would like to point out that `data[:subscription_plan_data][:subscription_plan_variations][0][:subscription_plan_variation_data][:phases][0][:periods]` is set to 1.

```ruby
{:type=>"SUBSCRIPTION_PLAN",
 :id=>"xxx",
 :updated_at=>"2024-09-16T04:39:24.755Z",
 :created_at=>"2024-09-16T04:39:24.789Z",
 :version=>1726461564755,
 :is_deleted=>false,
 :present_at_all_locations=>true,
 :subscription_plan_data=>
  {:name=>"xxx",
   :subscription_plan_variations=>
    [{:type=>"SUBSCRIPTION_PLAN_VARIATION",
      :id=>"xxx",
      :updated_at=>"2024-09-16T04:39:24.995Z",
      :created_at=>"2024-09-16T04:39:25.035Z",
      :version=>1726461564995,
      :is_deleted=>false,
      :present_at_all_locations=>true,
      :subscription_plan_variation_data=>
       {:name=>"xxx", :phases=>[{:uid=>"xxx", :cadence=>"MONTHLY", :periods=>1, :ordinal=>0, :pricing=>{:type=>"STATIC", :price=>{:amount=>300, :currency=>"JPY"}, :price_money=>{:amount=>300, :currency=>"JPY"}}}], :subscription_plan_id=>"xxx"}}]}}

```

According to the documentation at [Subscription Plans and Variations](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations), it states:

> If no periods are provided, the phase never ends and the subscription plan has no end date.

I would like users to continue subscribing until the subscription plan is stopped, but in reality, only the first month is being charged. What should I specify for the period?

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [October 9, 2024, 10:56am UTC](https://developer.squareup.com/forums/t/is-specifying-the-period-mandatory-when-creating-a-subscription-with-the-catalog-api/19089/2 "2024-10-09T10:56:27Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:  
[https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api](https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api)

> **[Subscription Plan Checkout](https://developer.squareup.com/docs/checkout-api/subscription-plan-checkout)**
>
> Learn how to create a quick pay checkout link for a subscription plan.

> **Additional Documentation**
>
> [Common Square API Patterns](https://developer.squareup.com/docs/sdks/ruby/common-square-api-patterns)  
> [Update Catalog Objects](https://developer.squareup.com/docs/catalog-api/update-catalog-objects)  
> [Catalog API](https://developer.squareup.com/docs/catalog-api/what-it-does)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [October 9, 2024, 4:26pm UTC](https://developer.squareup.com/forums/t/is-specifying-the-period-mandatory-when-creating-a-subscription-with-the-catalog-api/19089/3 "2024-10-09T16:26:01Z")

</div>

When creating a subscription plan, if you want the subscription to continue indefinitely until it’s manually stopped, you should not specify the `periods` field in the `phases` array. By omitting the `periods` field, the phase will continue indefinitely and the subscription plan will have no end date.

In your case, it seems like the `periods` field is automatically being set to 1, which is why the subscription is only being charged for the first month. To have the subscription continue until it’s manually stopped, you should omit the `periods` field when creating the subscription plan.

_This answer was reviewed by @Bryan-Square._
