• Carts/
    Cart Management/
    Get a Cart

    Get a Cart

    The default cart name is Cart. However, you can update the cart name as required. Ensure that the string length of the name is greater than or equal to one. Follow the safe character guidelines for name and description naming. For more information about cart ID naming requirements, see the Safe Characters section.

    GET Get a Cart by reference

    https://api.moltin.com/v2/carts/:reference
    

    Parameters

    Path parameters

    NameRequiredTypeDescription
    referenceRequiredstringA custom reference for this cart created by you.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Query parameters

    NameRequiredTypeDescription
    includeOptionalstringComma-delimited string of entities that can be included - valid options: items.

    Request Examples

    Curl

    curl -X GET https://api.moltin.com/v2/carts/:reference \
         -H "Authorization: Bearer XXXX"
    

    JavaScript SDK

    const reference = "XXXX";
    
    
    // Where `EPCC` is an authenticated client
    await EPCC.Cart(reference).Get();
    

    Response Example

    200 OK

    {
        "data": {
            "id": "616bea5c-507b-4ed4-b4a3-e1f17b314f86",
            "name": "Cart",
            "description": "",
            "type": "cart",
            "discounts_settings": {
                "custom_discounts_enabled" : false
            },
            "links": {
                "self": "https://api.moltin.com/carts/616bea5c-507b-4ed4-b4a3-e1f17b314f86"
            },
            "meta": {
                "display_price": {
                    "with_tax": {
                        "amount": 0,
                        "currency": "",
                        "formatted": "0"
                    },
                    "without_tax": {
                        "amount": 0,
                        "currency": "",
                        "formatted": "0"
                    },
                    "tax": {
                        "amount": 0,
                        "currency": "",
                        "formatted": "0"
                    },
                    "discount": {
                        "amount": 0,
                        "currency": "",
                        "formatted": "0"
                    },
                    "without_discount": {
                        "amount": 0,
                        "currency": "",
                        "formatted": "0"
                    }
                },
                "timestamps": {
                    "created_at": "2023-01-12T16:38:40Z",
                    "updated_at": "2023-01-12T16:38:40Z",
                    "expires_at": "2023-01-12T16:38:40Z"
                }
            },
            "relationships": {
                "items": {
                    "data": null
                }
            }
        }
    }
    

    You can easily get a new or existing cart by providing the unique cart reference in the request.

    An empty cart is returned for any carts that don’t currently exist. For more information about the cart items object, see Get Cart Items.

    Outside of the JS-SDK, we don’t handle creating cart references. You need to create your own.

    Was this helpful?

    Previous
    Carts