# Subscription creatpayment link issue

**URL:** <https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881>\
**Category:** Questions\
**Tags:** payments-api\
**Created:** [October 2, 2023, 9:35am UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881 "2023-10-02T09:35:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayminpatel.promenna](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jayminpatel.promenna](https://developer.squareup.com/forums/u/jayminpatel.promenna)\
**Post date:** [October 2, 2023, 9:35am UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/1 "2023-10-02T09:35:18Z")

</div>

I have created plan and got plan id from response but when i passing that planid in createpaymentlink request that time it is showing something like below.

{  
“errors”: [  
{  
“category”: “INVALID\_REQUEST\_ERROR”,  
“code”: “INVALID\_VALUE”,  
“detail”: “Invalid object `OI6R2HGECR5ETQNXAMI62UHL`: incorrect object type `SUBSCRIPTION_PLAN`.”,  
“field”: “subscription\_plan\_id”  
}  
]  
}

**Create Plan request as below**

curl [https://connect.squareupsandbox.com/v2/catalog/object](https://connect.squareupsandbox.com/v2/catalog/object)   
-X POST   
-H ‘Square-Version: 2023-09-25’   
-H ‘Authorization: Bearer ACCESS\_TOKEN’   
-H ‘Content-Type: application/json’   
-d ‘{  
“idempotency\_key”: “f9ab22ee-5046-4e39-9963-59a02ba875e3”,  
“object”: {  
“type”: “SUBSCRIPTION\_PLAN”,  
“id”: “#1990”,  
“subscription\_plan\_data”: {  
“name”: “testetstet”,  
“phases”: [  
{  
“cadence”: “MONTHLY”,  
“recurring\_price\_money”: {  
“amount”: 1500,  
“currency”: “USD”  
}  
},  
{  
“cadence”: “MONTHLY”,  
“recurring\_price\_money”: {  
“amount”: 1500,  
“currency”: “USD”  
}  
}  
],  
“all\_items”: true  
}  
}  
}’

**Create Plan response as below**

{  
“catalog\_object”: {  
“type”: “SUBSCRIPTION\_PLAN”,  
“id”: “OI6R2HGECR5ETQNXAMI62UHL”,  
“updated\_at”: “2023-10-02T09:29:42.987Z”,  
“created\_at”: “2023-10-02T09:29:42.987Z”,  
“version”: 1696238982987,  
“is\_deleted”: false,  
“present\_at\_all\_locations”: true,  
“subscription\_plan\_data”: {  
“name”: “testetstet”,  
“all\_items”: true  
}  
},  
“id\_mappings”: [  
{  
“client\_object\_id”: “#189”,  
“object\_id”: “OI6R2HGECR5ETQNXAMI62UHL”  
}  
]  
}

**Createpayment link request as below**

curl [https://connect.squareupsandbox.com/v2/online-checkout/payment-links](https://connect.squareupsandbox.com/v2/online-checkout/payment-links)   
-X POST   
-H ‘Square-Version: 2023-09-25’   
-H ‘Authorization: Bearer ACCESS\_TOKEN’   
-H ‘Content-Type: application/json’   
-d ‘{  
“idempotency\_key”: “57291bd7-dce4-4617-ba9a-944ae4d7cd08”,  
“quick\_pay”: {  
“name”: “Gym membership fees”,  
“price\_money”: {  
“amount”: 1500,  
“currency”: “USD”  
},  
“location\_id”: “LTBWC2JWZ5WV6”  
},  
“checkout\_options”: {  
“subscription\_plan\_id”: “OI6R2HGECR5ETQNXAMI62UHL”  
}  
}’

**Createpaymentlink response as below**

{  
“errors”: [  
{  
“category”: “INVALID\_REQUEST\_ERROR”,  
“code”: “INVALID\_VALUE”,  
“detail”: “Invalid object `OI6R2HGECR5ETQNXAMI62UHL`: incorrect object type `SUBSCRIPTION_PLAN`.”,  
“field”: “subscription\_plan\_id”  
}  
]  
}

**Api log request as below**

{  
“idempotency\_key”: “57291bd7-dce4-4617-ba9a-944ae4d7cd08”,  
“quick\_pay”: {  
“name”: “Gym membership fees”,  
“price\_money”: {  
“amount”: 1500,  
“currency”: “USD”  
},  
“location\_id”: “LTBWC2JWZ5WV6”  
},  
“checkout\_options”: {  
“subscription\_plan\_id”: “OI6R2HGECR5ETQNXAMI62UHL”  
}  
}

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [October 2, 2023, 4:53pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/2 "2023-10-02T16:53:14Z")

</div>

Your getting this error because of your Square API version. The subscription object shape has changed and any version newer then `2023-06-08` takes the new model. If you set the version of one older then `2023-06-08` it will work as expected. 🙂

---

<div class="post-metadata">

**Author:** ![jayminpatel.promenna](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jayminpatel.promenna](https://developer.squareup.com/forums/u/jayminpatel.promenna)\
**Post date:** [October 2, 2023, 5:07pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/3 "2023-10-02T17:07:08Z")

</div>

So if i want to proceed with the latest version then where/what is should change?

---

<div class="post-metadata">

**Author:** ![jayminpatel.promenna](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@jayminpatel.promenna](https://developer.squareup.com/forums/u/jayminpatel.promenna)\
**Post date:** [October 3, 2023, 2:36am UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/4 "2023-10-03T02:36:31Z")

</div>

![image](https://global.discourse-cdn.com/square/original/2X/2/280d220a8e6af217ecf2903bc12eaecd06d0982d.png)

Still not working. Same response getting(invalid object type).

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [October 3, 2023, 4:15pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/5 "2023-10-03T16:15:39Z")

</div>

I took a look at the [API Logs](https://developer.squareup.com/apps/sq0idp-U33tMvzlL9ChanwteUutGw/log) and the API version is being passed in the header which is overriding the API version set in the application.

 ![Screenshot 2023-10-03 at 09.14.42](https://global.discourse-cdn.com/square/original/2X/c/c8893482177af705377ac05ed439e219fe38ab00.png)  
🙂

---

<div class="post-metadata">

**Author:** ![jdecourselle](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jdecourselle](https://developer.squareup.com/forums/u/jdecourselle)\
**Post date:** [November 15, 2023, 3:49pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/6 "2023-11-15T15:49:19Z")

</div>

Hi @Bryan-Square .

I got the same problem in the API Explorer.  
I create a subscription plan using Catalog → upsertCatalogObject → SUBSCRIPTION\_PLAN (And i fill all needed information). The subscription plan is well created and i can retreive it.

But when I try to create a Payment link using Checkout → Create Payment Link and I add the subscription\_plan\_id, i got the same error :

```auto
 "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "Invalid object `X55Q3YURTQVDVWCLZM6S3CXF`: incorrect object type `SUBSCRIPTION_PLAN`.",
      "field": "subscription_plan_id"

```

I use the latest version in teh API Explorer.

How to solve it ?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [November 15, 2023, 5:56pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/7 "2023-11-15T17:56:39Z")

</div>

You’ll want to pass in the `subscription_plan_variation_id` when creating the link for the subscription. 🙂

---

<div class="post-metadata">

**Author:** ![grant-oscillo](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@grant-oscillo](https://developer.squareup.com/forums/u/grant-oscillo)\
**Post date:** [December 12, 2023, 5:28am UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/8 "2023-12-12T05:28:22Z")

</div>

Hi @Bryan-Square, I’m experiencing the same issues using both the API explorer online in addition to sending requests locally using the latest Python SDK (30.0.0.20231115) to create the catalog objects using the POST request to create payment links. I tried searching for the `subscription_plan_variation_id` you mentioned but can’t find it, are you able to point me in the right direction at all?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 12, 2023, 4:54pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/9 "2023-12-12T16:54:08Z")

</div>

When you retrieve the subscription with the Catalog API the `subscription_variation_id` will be included in the response. 🙂

---

<div class="post-metadata">

**Author:** ![grant-oscillo](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@grant-oscillo](https://developer.squareup.com/forums/u/grant-oscillo)\
**Post date:** [December 12, 2023, 10:06pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/10 "2023-12-12T22:06:29Z")

</div>

Thanks for the quick response! I’m currently following the guide here [Subscription Plan Checkout](https://developer.squareup.com/docs/checkout-api/subscription-plan-checkout). Using the API explorer, I send this POST request:

```auto
curl https://connect.squareupsandbox.com/v2/catalog/object \
  -X POST \
  -H 'Square-Version: 2023-11-15' \
  -H 'Authorization: Bearer access_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "8219e81b-bc43-4cd6-a826-72fe2552699e",
    "object": {
      "type": "SUBSCRIPTION_PLAN",
      "id": "#test-plan-1",
      "subscription_plan_data": {
        "phases": [
          {
            "cadence": "WEEKLY",
            "recurring_price_money": {
              "amount": 1500,
              "currency": "AUD"
            }
          }
        ],
        "name": "Test Sub for Variation ID"
      }
    }
  }'

```

And this is the response I get back:

```auto
cache-control: max-age=0, private, must-revalidate
content-encoding: gzip
content-type: application/json
date: Tue, 12 Dec 2023 21:51:56 GMT
square-version: 2023-11-15

{
  "catalog_object": {
    "type": "SUBSCRIPTION_PLAN",
    "id": "KVP6GDEADUAJRHC2QLZMM3JW",
    "updated_at": "2023-12-12T21:51:56.359Z",
    "created_at": "2023-12-12T21:51:56.359Z",
    "version": 1702417916359,
    "is_deleted": false,
    "present_at_all_locations": true,
    "subscription_plan_data": {
      "name": "Test Sub for Variation ID"
    }
  },
  "id_mappings": [
    {
      "client_object_id": "#test-plan-1",
      "object_id": "KVP6GDEADUAJRHC2QLZMM3JW"
    }
  ]
}

```

Running a `GET` on the list catalog gives me (only a subset posted here for brevity):

```auto
{
      "type": "SUBSCRIPTION_PLAN",
      "id": "KVP6GDEADUAJRHC2QLZMM3JW",
      "updated_at": "2023-12-12T21:51:56.359Z",
      "created_at": "2023-12-12T21:51:56.359Z",
      "version": 1702417916359,
      "is_deleted": false,
      "present_at_all_locations": true,
      "subscription_plan_data": {
        "name": "Test Sub for Variation ID"
      }

```

So far I haven’t seen anything for `subscription_variation_id`, and when I do a POST for creating the payment link using:

```auto
curl https://connect.squareupsandbox.com/v2/online-checkout/payment-links \
  -X POST \
  -H 'Square-Version: 2023-11-15' \
  -H 'Authorization: Bearer access_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "c2e30f52-047c-48f5-9f9c-5c7907d288ac",
    "quick_pay": {
      "name": "Gym membership fees",
      "price_money": {
        "amount": 1500,
        "currency": "AUD"
      },
      "location_id": "LFXJE6JW7MHEX"
    },
    "checkout_options": {
      "subscription_plan_id": "KVP6GDEADUAJRHC2QLZMM3JW"
    }
  }'

```

I get:

```auto
cache-control: no-cache
content-length: 200
content-type: application/json
date: Tue, 12 Dec 2023 22:00:27 GMT
square-version: 2023-11-15

{
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "INVALID_VALUE",
      "detail": "Invalid object `KVP6GDEADUAJRHC2QLZMM3JW`: incorrect object type `SUBSCRIPTION_PLAN`.",
      "field": "subscription_plan_id"
    }
  ]
}

```

Is there a step that I’m missing before running the upsert catalog object request?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 12, 2023, 10:44pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/11 "2023-12-12T22:44:37Z")

</div>

When you create a subscription you’ll want to create it according to this [guide](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations). The guide for the Checkout API is in the process of being updated to support the new subscription model that was released in June of this last year.

Also when sharing examples please be sure to redact your access token. The are essentially the password for the account. 🙂

---

<div class="post-metadata">

**Author:** ![grant-oscillo](https://avatars.discourse-cdn.com/v4/letter/g/59ef9b/32.png) [@grant-oscillo](https://developer.squareup.com/forums/u/grant-oscillo)\
**Post date:** [December 12, 2023, 10:51pm UTC](https://developer.squareup.com/forums/t/subscription-creatpayment-link-issue/10881/12 "2023-12-12T22:51:00Z")

</div>

Thanks again for the speedy response! I’ll use the other guide and go from there, and good pickup re: token, I didn’t realise it got captured in plain text when I copied the request over! I’ve changed it within my sandbox as a precaution as well.
