Skip to content

Cart

A Cart holds what a shopper intends to buy: lines of an Offer and a quantity (cartItem), the shop (seller) and, when known, the shopper (customer). A read of one cart adds each line's current Offer price and priceCurrency, and totalPrice per currency; prices are never stored. POST /carts/{id}/checkout turns it into an Order whose id is the cart's; see Carts and checkout. A cart expires 30 days after its last change unless expires says otherwise. ObjectsGrid's own type: Schema.org has no cart, so it has no at_context and no JSON-LD document.

JSON Schema ยท ABAC object type Cart

Example

Create one with POST /carts:

{
  "seller": {
    "at_id": "https://apis.objectsgrid.com/organizations/6a7b8c9d-0e1f-4a2b-8c3d-4e5f6a7b8c9d"
  },
  "customer": {
    "at_id": "https://apis.objectsgrid.com/persons/8e9f0a1b-2c3d-4e5f-8a6b-7c8d9e0f1a2b"
  },
  "cartItem": [
    {
      "offer": {
        "at_id": "https://apis.objectsgrid.com/offers/1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
      },
      "quantity": 2
    }
  ],
  "discountCode": "WINTER10"
}

Fields

Required: cartItem.

Field Type Required Description
at_type Cart JSON-LD @type, the object's type name.
at_id URL The object's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>, its JSON-LD @id: what References to it hold. Assigned by ObjectsGrid.
id string The object's id. Assigned by ObjectsGrid when the object is created.
identifier string The object's id, as Schema.org identifier. Assigned by ObjectsGrid.
url URL The object's own URL, https://apis.objectsgrid.com/<path>/<id>. Assigned by ObjectsGrid.
seller Reference to Organization The shop the cart is with
customer Reference to Organization or Person The shopper, when known; none for a guest. Checkout uses it as the Order's customer
cartItem list of object Yes The lines: an Offer and how many of it
cartItem[].offer Reference to Offer Yes The Offer the shopper intends to buy
cartItem[].quantity number How many; 1 when not given
cartItem[].price number The Offer's current price for one. Computed on a read of the cart, never stored.
cartItem[].priceCurrency string The Offer's currency. Computed on a read of the cart, never stored.
discountCode string A DiscountCode the shopper entered, in any case. A read shows its discount in totalPrice and discount, or why it doesn't apply in discountRefused; checkout checks it again, counts the use and passes the code and the discount to the Order. A code no DiscountCode has is passed to the Order unapplied, for codes an app runs itself.
expires date-time When the cart expires: 30 days after its last change when not given. After it, reads answer 404
totalPrice list of MonetaryAmount The sum of the lines' prices, per currency, less the discount. Computed on a read of the cart, never stored.
checkedOut boolean Whether the cart was checked out; it can't change after. Set by the service.
order Reference to Order The Order the checkout created. Set by the service.
tags list of Tag Tags your ABAC policy decides on. Created empty when not sent, kept by a PUT that leaves them out, cleared by null or [].
meta ObjectMeta Read-only metadata: version, type, creation and last update.
discount list of MonetaryAmount What the discountCode takes off, per currency. Computed on a read of the cart, never stored.
discountRefused string Why the discountCode doesn't apply, e.g. expired or used up. Computed on a read of the cart, never stored.

REST API

Base URL https://apis.objectsgrid.com. Every request sends the X-ObjectsGrid-AccessPoint and Authorization: Bearer <access token> headers; see the REST API guide.

Operation Request
Create POST /carts
List and search GET /carts
Create up to 100 at once POST /carts/batch
Retrieve GET /carts/{id}
Replace PUT /carts/{id}
Update some fields PATCH /carts/{id}
Delete DELETE /carts/{id}

Cart objects have no JSON-LD document: asked for one (Accept: application/ld+json), GET answers 406.

The OpenAPI contract, with every parameter and response: Carts (JSON).

GraphQL

Endpoint POST https://apis.objectsgrid.com/graphql; see the GraphQL guide.

Operation Field
Query cart(id: ID!, version: String): Cart
Query carts(where: CartWhereInput, orderBy: [CartOrderByInput!], first: Int, after: String): CartConnection!
Query cartsGroupBy(by: [CartGroupByField!]!, where: CartWhereInput, having: CartHavingInput, orderBy: [CartGroupByOrderByInput!], first: Int, after: String): CartGroupByConnection!
Mutation createCart(input: CreateCartInput!): Cart!
Mutation updateCart(input: UpdateCartInput!, expectedVersion: String): Cart!
Mutation deleteCart(id: ID!, expectedVersion: String): Boolean!

Webhook events

Subscribe to these events in your webhook configuration to be called when a Cart changes:

CartCreated, CartUpdated, CartPatched, CartDeleted.