> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: "checkoutByCartID"
description: "Returns a Checkout object by cart ID. This query can be used to retrieve information about the checkout status for an already submitted cart as well as order details for all orders associated with the checkout"
---

<Note>When called for a not submitted cart, [`Checkout.status`](/api-reference/checkoutstatus) will always be `PENDING`. After cart submission [`Checkout.status`](/api-reference/checkoutstatus) will change according to the current checkout state.</Note>

Sometimes, when using the `checkoutByCartID` query, the returned status may be `ACTION_REQUIRED`. In this case, you should check the `requiredActions` field for each order with this status and perform the necessary actions. Currently, there is only one required action: `CompletePaymentChallenge`, also known as 3D-S Challenge. You can learn more about this use casse in the [3D-S Challenge](/3ds-challenge) guide.

***

### Arguments

<ParamField path="cartID" type="ID!" required>
  The ID of the [`Cart`](/api-reference/cart)
</ParamField>

### Returns

<ParamField path="Checkout.*" type={<a href="/api-reference/checkout">Checkout</a>}>
  Any requested field from the [`Checkout`](/api-reference/checkout) object.
</ParamField>

### Example - request

```json Query arguments

{
  "cartID": "{{cartId}}"
}
```

```GraphQL GraphQL
query Checkout($cartID: ID!){
  checkoutByCartID(cartID: $cartID) {
    status
    orders {
      id
      status
      events {
        __typename
        id
        createdAt
        ... on OrderFailedOrderEvent { reason }
      }
      requiredActions {
        ... on CompletePaymentChallenge {
          redirectURL
        }
      }
    }
    cart {
      id
      stores {
        ... on AmazonStore {
          store
          orderId
          cartLines {
            product {
              id
            }
            quantity
          }
          offer {
            shippingMethods {
              id
              total {
                displayValue
              }
            }
          }
          errors {
            message
          }
          isSubmitted
        }
        ... on ShopifyStore {
          store
          orderId
          cartLines {
            variant {
              id
            }
            quantity
          }
          offer {
            shippingMethods {
              id
              total {
                displayValue
              }
            }
          }
          errors {
            message
          }
          isSubmitted
        }
      }
      buyerIdentity {
        firstName
        lastName
      }
    }
  }
}
```

### Example - response

```json Response
{
  "data": {
    "checkoutByCartID": {
      "status": "PENDING",
      "orders": [
          {
            "id": "cf3edbe2-a4fb-48d8-a4bb-5a7f39929efa",
            "status": "PENDING",
            "events": [],
            "requiredActions": []
          },
          {
            "id": "e442d899-0812-48e7-b6d9-c659f3b034de",
            "status": "PENDING",
            "events": [],
            "requiredActions": []
          }
      ],
      "cart": {
        "id": "teWvPufPy8c2AcfkfBo9",
        "stores": [
          {
            "store": "test.myshopify.com",
            "orderId": "cf3edbe2-a4fb-48d8-a4bb-5a7f39929efa",
            "cartLines": [
              {
                "variant": {
                  "id": "44454219743530"
                },
                "quantity": 1
              }
            ],
            "offer": {
              "shippingMethods": [
                {
                  "id": "79da7f8d68e18f7616e6841112693fce",
                  "total": {
                    "displayValue": "$12.39"
                  }
                },
                {
                  "id": "ee768830e386b87e4f230f4292c237a3",
                  "total": {
                    "displayValue": "$14.39"
                  }
                }
              ]
            },
            "errors": [],
            "isSubmitted": false
          },
          {
            "store": "amazon",
            "orderId": "e442d899-0812-48e7-b6d9-c659f3b034de",
            "cartLines": [
              {
                "product": {
                  "id": "B00A2KD8NY"
                },
                "quantity": 1
              }
            ],
            "offer": {
              "shippingMethods": [
                {
                  "id": "3.99-Default shipping method",
                  "total": {
                    "displayValue": "$11.94"
                  }
                }
              ]
            },
            "errors": [],
            "isSubmitted": false
          }
        ],
        "buyerIdentity": {
          "firstName": "John",
          "lastName": "Doe"
        }
      }
    }
  }
}
```

***

### Errors

If the cart is not found then a corresponding error is returned

```JSON JSON
{
  "errors": [
    {
      "message": "Cart not found: someInvalidCartId",
      "path": [
        "checkoutByCartID"
      ],
      "extensions": {
        "code": "CART_NOT_FOUND_ERROR"
      }
    }
  ],
  "data": null
}
```

If the cart is expired (older than 10 days) then a corresponding error is returned

```JSON JSON
{
  "errors": [
    {
      "message": "Cart expired: someExpiredCartId",
      "path": [
        "checkoutByCartID"
      ],
      "extensions": {
        "code": "CART_EXPIRED_ERROR"
      }
    }
  ],
  "data": null
}
```

***

### Related queries

[`orderById`](/api-reference/orderbyid)


---

*Powered by [holocron.so](https://holocron.so)*
