What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to get checkoutId like "gid://shopify/Checkout/35072706281695qwerty"

How to get checkoutId like "gid://shopify/Checkout/35072706281695qwerty"

Khac_Son
Shopify Partner
3 0 0

There are many api of checkout with required checkoutId but no document about how to get checkoutId.

Replies 2 (2)

Liam
Community Manager
3108 344 895

Hi Sodoo,

 

When you use the API to create a new checkout, the response typically includes a checkout ID. For example, in Shopify, when you create a new checkout using the Storefront API, the returned Checkout object includes an id field which is your checkout ID.

Here is a mutation example using GraphQL:

mutation {
  checkoutCreate(input: { 
    lineItems: [{ variantId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMzY5NTA=", quantity: 1 }] 
  }) {
    checkout {
      id
    }
  }
}

In the response, you'll get something like:

{
  "data": {
    "checkoutCreate": {
      "checkout": {
        "id": "Z2lkOi8vc2hvcGlmeS9DaGVja291dC9kMTZmM2EzMDM4YjMzNzFlOWZjMWE3MmNjNGQ5ZDk3Mz9rZXk9YjdlMmZmMjg1YzgwZDdlNmE1ZDc4YWM5ZGY3YmE4MTE="
      }
    }
  }
}

The value of id is the checkout ID you need.

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Temur1
Shopify Partner
7 0 0

Hello Liam is it possible to get numeric checkout id wichh we can see in admin orders at the end of the page #37947591590172 like this