# Get a cart

URL: https://docs.sparklayer.io/developers/api/ordering/get-cart
Operation: `GET /api/v1/carts/{id}` (operationId `getCart`)
OpenAPI spec: https://docs.sparklayer.io/openapi/ordering.yaml

Returns the cart's line items, addresses, totals and any `validation_errors` (such as minimum order or stock rules) that you need to resolve or ignore before completing it. Returns `404` if the cart doesn't exist, for example because it has already been completed.

`GET /api/v1/carts/{id}`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl "https://app.sparklayer.io/api/v1/carts/9151f21f-43ae-43b4-92f3-f4af67cdf544" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID"
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | The cart's ID: the `cart_id` returned by **Create a cart**. Example: `9151f21f-43ae-43b4-92f3-f4af67cdf544` |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Responses

#### 200: The cart, including its line items, totals and any `validation_errors`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | | |
| `intent` | "ORDER" \| "QUOTE" | | |
| `customer_id` | string (uuid) | | |
| `shipping_address_id` | string (uuid) \| null | | |
| `billing_address_id` | string (uuid) \| null | | |
| `items` | object[] | | |
| `items[].sku` | string | | |
| `items[].quantity` | integer | | |
| `items[].line_total` | object | | |
| `items[].line_total.net` | string | | |
| `items[].line_total.gross` | string | | |
| `items[].line_total.tax_rate` | number (float) \| null | | |
| `items[].line_total.currency_code` | string | | |
| `items[].line_total.tax_inclusive_display` | boolean | | Whether the storefront should show the gross amount and label it tax inclusive. Not derivable from tax_rate, since a zero-rated SKU on a tax-inclusive price list has a rate of 0 but must still be labelled. Display only - it says nothing about what is charged. Default: `false`. |
| `items[].unit_total` | object \| null | | |
| `items[].unit_total.net` | string | | |
| `items[].unit_total.gross` | string | | |
| `items[].unit_total.tax_rate` | number (float) \| null | | |
| `items[].unit_total.currency_code` | string | | |
| `items[].unit_total.tax_inclusive_display` | boolean | | Whether the storefront should show the gross amount and label it tax inclusive. Not derivable from tax_rate, since a zero-rated SKU on a tax-inclusive price list has a rate of 0 but must still be labelled. Display only - it says nothing about what is charged. Default: `false`. |
| `totals` | object | | |
| `totals.total` | object | | |
| `totals.total.pre_discount` | object | | |
| `totals.total.pre_discount.net` | object | | |
| `totals.total.pre_discount.net.amount` | string | | |
| `totals.total.pre_discount.net.currency_code` | string | | |
| `totals.total.pre_discount.gross` | object | | |
| `totals.total.pre_discount.gross.amount` | string | | |
| `totals.total.pre_discount.gross.currency_code` | string | | |
| `totals.total.pre_discount.tax` | object | | |
| `totals.total.pre_discount.tax.amount` | string | | |
| `totals.total.pre_discount.tax.currency_code` | string | | |
| `totals.total.pre_discount.apportioned_tax_rate` | number (float) | | |
| `totals.total.pre_discount.currency` | string | | |
| `totals.total.discount` | object \| null | | |
| `totals.total.discount.net` | object | | |
| `totals.total.discount.net.amount` | string | | |
| `totals.total.discount.net.currency_code` | string | | |
| `totals.total.discount.gross` | object | | |
| `totals.total.discount.gross.amount` | string | | |
| `totals.total.discount.gross.currency_code` | string | | |
| `totals.total.discount.tax` | object | | |
| `totals.total.discount.tax.amount` | string | | |
| `totals.total.discount.tax.currency_code` | string | | |
| `totals.total.discount.apportioned_tax_rate` | number (float) | | |
| `totals.total.discount.currency` | string | | |
| `totals.total.charge` | object | | |
| `totals.total.charge.net` | object | | |
| `totals.total.charge.net.amount` | string | | |
| `totals.total.charge.net.currency_code` | string | | |
| `totals.total.charge.gross` | object | | |
| `totals.total.charge.gross.amount` | string | | |
| `totals.total.charge.gross.currency_code` | string | | |
| `totals.total.charge.tax` | object | | |
| `totals.total.charge.tax.amount` | string | | |
| `totals.total.charge.tax.currency_code` | string | | |
| `totals.total.charge.apportioned_tax_rate` | number (float) | | |
| `totals.total.charge.currency` | string | | |
| `totals.shipping` | object | | |
| `totals.shipping.pre_discount` | object | | |
| `totals.shipping.pre_discount.net` | object | | |
| `totals.shipping.pre_discount.net.amount` | string | | |
| `totals.shipping.pre_discount.net.currency_code` | string | | |
| `totals.shipping.pre_discount.gross` | object | | |
| `totals.shipping.pre_discount.gross.amount` | string | | |
| `totals.shipping.pre_discount.gross.currency_code` | string | | |
| `totals.shipping.pre_discount.tax` | object | | |
| `totals.shipping.pre_discount.tax.amount` | string | | |
| `totals.shipping.pre_discount.tax.currency_code` | string | | |
| `totals.shipping.pre_discount.apportioned_tax_rate` | number (float) | | |
| `totals.shipping.pre_discount.currency` | string | | |
| `totals.shipping.discount` | object \| null | | |
| `totals.shipping.discount.net` | object | | |
| `totals.shipping.discount.net.amount` | string | | |
| `totals.shipping.discount.net.currency_code` | string | | |
| `totals.shipping.discount.gross` | object | | |
| `totals.shipping.discount.gross.amount` | string | | |
| `totals.shipping.discount.gross.currency_code` | string | | |
| `totals.shipping.discount.tax` | object | | |
| `totals.shipping.discount.tax.amount` | string | | |
| `totals.shipping.discount.tax.currency_code` | string | | |
| `totals.shipping.discount.apportioned_tax_rate` | number (float) | | |
| `totals.shipping.discount.currency` | string | | |
| `totals.shipping.charge` | object | | |
| `totals.shipping.charge.net` | object | | |
| `totals.shipping.charge.net.amount` | string | | |
| `totals.shipping.charge.net.currency_code` | string | | |
| `totals.shipping.charge.gross` | object | | |
| `totals.shipping.charge.gross.amount` | string | | |
| `totals.shipping.charge.gross.currency_code` | string | | |
| `totals.shipping.charge.tax` | object | | |
| `totals.shipping.charge.tax.amount` | string | | |
| `totals.shipping.charge.tax.currency_code` | string | | |
| `totals.shipping.charge.apportioned_tax_rate` | number (float) | | |
| `totals.shipping.charge.currency` | string | | |
| `totals.sub_total` | object | | |
| `totals.sub_total.pre_discount` | object | | |
| `totals.sub_total.pre_discount.net` | object | | |
| `totals.sub_total.pre_discount.net.amount` | string | | |
| `totals.sub_total.pre_discount.net.currency_code` | string | | |
| `totals.sub_total.pre_discount.gross` | object | | |
| `totals.sub_total.pre_discount.gross.amount` | string | | |
| `totals.sub_total.pre_discount.gross.currency_code` | string | | |
| `totals.sub_total.pre_discount.tax` | object | | |
| `totals.sub_total.pre_discount.tax.amount` | string | | |
| `totals.sub_total.pre_discount.tax.currency_code` | string | | |
| `totals.sub_total.pre_discount.apportioned_tax_rate` | number (float) | | |
| `totals.sub_total.pre_discount.currency` | string | | |
| `totals.sub_total.discount` | object \| null | | |
| `totals.sub_total.discount.net` | object | | |
| `totals.sub_total.discount.net.amount` | string | | |
| `totals.sub_total.discount.net.currency_code` | string | | |
| `totals.sub_total.discount.gross` | object | | |
| `totals.sub_total.discount.gross.amount` | string | | |
| `totals.sub_total.discount.gross.currency_code` | string | | |
| `totals.sub_total.discount.tax` | object | | |
| `totals.sub_total.discount.tax.amount` | string | | |
| `totals.sub_total.discount.tax.currency_code` | string | | |
| `totals.sub_total.discount.apportioned_tax_rate` | number (float) | | |
| `totals.sub_total.discount.currency` | string | | |
| `totals.sub_total.charge` | object | | |
| `totals.sub_total.charge.net` | object | | |
| `totals.sub_total.charge.net.amount` | string | | |
| `totals.sub_total.charge.net.currency_code` | string | | |
| `totals.sub_total.charge.gross` | object | | |
| `totals.sub_total.charge.gross.amount` | string | | |
| `totals.sub_total.charge.gross.currency_code` | string | | |
| `totals.sub_total.charge.tax` | object | | |
| `totals.sub_total.charge.tax.amount` | string | | |
| `totals.sub_total.charge.tax.currency_code` | string | | |
| `totals.sub_total.charge.apportioned_tax_rate` | number (float) | | |
| `totals.sub_total.charge.currency` | string | | |
| `customer_addresses` | object[] | | |
| `customer_addresses[].id` | string | | |
| `customer_addresses[].uuid` | string | | |
| `customer_addresses[].first_name` | string | | |
| `customer_addresses[].last_name` | string | | |
| `customer_addresses[].company` | string | | |
| `customer_addresses[].description` | string | | |
| `customer_addresses[].address_line_1` | string | | |
| `customer_addresses[].address_line_2` | string | | |
| `customer_addresses[].city` | string | | |
| `customer_addresses[].postal_code` | string \| null | | |
| `customer_addresses[].country_code` | string | | |
| `customer_addresses[].region_code` | string \| null | | |
| `customer_addresses[].phone` | string | | |
| `customer_addresses[].external_id` | string \| null | | |
| `shipping_rate_handle` | string \| null | | |
| `payment_method` | string \| null | | |
| `validation_errors` | (CartValidationErrorMaximumOrderItemQuantity \| CartValidationErrorMaximumOrderTotals \| CartValidationErrorMaximumParentQuantity \| CartValidationErrorMaximumVariantQuantity \| CartValidationErrorMinimumOrderItemQuantity \| CartValidationErrorMinimumOrderTotals \| CartValidationErrorMinimumParentQuantity \| CartValidationErrorMinimumVariantQuantity \| CartValidationErrorPackSize \| CartValidationErrorPricingUnavailable \| CartValidationErrorPricingUnavailableForSelectedQty \| CartValidationErrorQuantityUnavailable)[] | | |
| `validation_errors[].type` | "maximum-order-item-quantity" | | |
| `validation_errors[].overridden` | boolean | | |
| `validation_errors[].maximum` | integer | | |
| `validation_errors[].amount` | number (float) | | |
| `validation_errors[].parent_sku` | string | | |
| `validation_errors[].product_name` | string | | |
| `validation_errors[].minimum` | integer | | |
| `validation_errors[].pack_size` | integer | | |
| `validation_errors[].variant_sku` | string | | |
| `validation_errors[].available_quantity` | integer | | |
| `customer_reference` | string \| null | | |
| `po_number` | string \| null | | |
| `shipping_requested_date` | string \| null | | |
| `custom_fields` | object[] | | The cart's current custom fields. |
| `custom_fields[].name` | string | Yes | |
| `custom_fields[].value` | string | Yes | |

```json
{
  "id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
  "intent": "ORDER",
  "customer_id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
  "shipping_address_id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
  "billing_address_id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
  "items": [
    {
      "sku": "<sku>",
      "quantity": 0,
      "line_total": {
        "net": "<net>",
        "gross": "<gross>",
        "tax_rate": 0,
        "currency_code": "<currency_code>",
        "tax_inclusive_display": false
      },
      "unit_total": {
        "net": "<net>",
        "gross": "<gross>",
        "tax_rate": 0,
        "currency_code": "<currency_code>",
        "tax_inclusive_display": false
      }
    }
  ],
  "totals": {
    "total": {
      "pre_discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "charge": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      }
    },
    "shipping": {
      "pre_discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "charge": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      }
    },
    "sub_total": {
      "pre_discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "discount": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      },
      "charge": {
        "net": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "gross": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "tax": {
          "amount": "<amount>",
          "currency_code": "<currency_code>"
        },
        "apportioned_tax_rate": 0,
        "currency": "<currency>"
      }
    }
  },
  "customer_addresses": [
    {
      "id": "<id>",
      "uuid": "<uuid>",
      "first_name": "<first_name>",
      "last_name": "<last_name>",
      "company": "<company>",
      "description": "<description>",
      "address_line_1": "<address_line_1>",
      "address_line_2": "<address_line_2>",
      "city": "<city>",
      "postal_code": "<postal_code>",
      "country_code": "<country_code>",
      "region_code": "<region_code>",
      "phone": "<phone>",
      "external_id": "<external_id>"
    }
  ],
  "shipping_rate_handle": "<shipping_rate_handle>",
  "payment_method": "<payment_method>",
  "validation_errors": [
    {
      "type": "maximum-order-item-quantity",
      "overridden": true,
      "maximum": 0
    }
  ],
  "customer_reference": "<customer_reference>",
  "po_number": "<po_number>",
  "shipping_requested_date": "<shipping_requested_date>",
  "custom_fields": [
    {
      "name": "<name>",
      "value": "<value>"
    }
  ]
}
```

#### 404: Cart not found

#### 422: Unprocessable Entity

One of these:

**CartErrorResponse**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | 422 | | HTTP Status code returned from API |
| `title` | "cart-error" | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | "cart-shipping-rate-handle-unavailable" \| "cart-customer-not-found" \| "cart-impersonator-user-not-found" \| "cart-payment-method-unavailable" | | Machine-readable error code |

- **Error**: the standard error body (below).

```json
{
  "detail": "Cart error occurred",
  "status": 422,
  "title": "cart-error",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "cart-shipping-rate-handle-unavailable"
    }
  ]
}
```

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | string | | Machine-readable error code |
| `errors[].property` | string | | The property the error relates to |
| `errors[].message` | string | | Human readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "resource-not-found",
      "property": "stock_location_id",
      "message": "stock_location_id not found"
    }
  ]
}
```
