JSON API

JSON API: Endpoints

Current Cart

Returns the customer's cart.

GET /!/cargo/cart

Update the cart

Updates the customer's cart. You can post customer information, redeem a discount code, or pass any other order fields here.

POST /!/cargo/cart

  • customer

    array

    Customer information to persist on the cart.

    Hide customer
    Show customer
    • name

      string
    • first_name

      string
    • last_name

      string
    • email

      string
    • Any other fields defined in your user blueprint.

  • discount_code

    string
  • shipping_method

    string

    Required when shipping_option is provided.

  • shipping_option

    string

    Required when shipping_method is provided.

  • shipping_line_1

    string
  • shipping_line_2

    string
  • shipping_city

    string
  • shipping_postcode

    string
  • shipping_country

    string

    Must be in ISO3 format.

  • shipping_state

    string

    Must match one of the states in Cargo's states.json file.

  • billing_line_1

    string
  • billing_line_2

    string
  • billing_city

    string
  • billing_postcode

    string
  • billing_country

    string

    Must be in ISO3 format.

  • billing_state

    string

    Must match one of the states in Cargo's states.json file.

  • Any other fields defined in your order blueprint.

Delete the cart

Deletes the customer's cart.

DELETE /!/cargo/cart

Add a line item

Adds a line item to the customer's cart.

POST /!/cargo/cart/line-items

  • product

    string required
  • variant

    string

    Required when adding a variant product.

  • quantity

    integer

    Defaults to 1

  • customer

    array

    Customer information to persist on the cart.

    Hide customer
    Show customer
    • name

      string
    • first_name

      string
    • last_name

      string
    • email

      string
    • Any other fields defined in your user blueprint.

  • Any other data you'd like to persist on the line item.

Update a line item

Updates a line item on the customer's cart. The {lineItem} should be the ID of the line item you wish to update.

PATCH /!/cargo/cart/line-items/{lineItem}

  • variant

    string

    Required when the product is a variant product.

  • quantity

    integer
  • customer

    array

    Customer information to persist on the cart.

    Hide customer
    Show customer
    • name

      string
    • first_name

      string
    • last_name

      string
    • email

      string
    • Any other fields defined in your user blueprint.

  • Any other data you'd like to persist on the line item.

Remove a line item

Removes a line item from the customer's cart. The {lineItem} should be the ID of the line item you wish to remove.

DELETE /!/cargo/cart/line-items/{lineItem}

Available Shipping Methods

Returns the available shipping options for the customer's cart.

This endpoint will return a 422 status code when no shipping address is set on the cart.

GET /!/cargo/cart/shipping

Available Payment Gateways

Returns the available payment gateways for the customer's cart, including the array returned by the payment gateway's setup method.

Payment Gateways will be returned even when the cart total is £0. In this case, no setup data will be returned.

GET /!/cargo/cart/payment-gateways

Checkout: £0 order

When the cart total is equals to £0, you may use this endpoint to create an order without payment.

When successful, this endpoint will return a redirect response to the checkout confirmation page.

When the order requires payment, this endpoint will report a 404 status code.

GET POST /!/cargo/cart/checkout

  • discount_code

    string

Checkout: Paid Order

When the order requires payment, you may use this endpoint to create the order. The {gateway} should be the handle of the payment gateway you wish to check out using.

When successful, this endpoint will return a redirect response to the checkout confirmation page.

When the order does not require payment, this endpoint will return a 404 status code.

GET POST /!/cargo/cart/payments/{gateway}/checkout

  • discount_code

    string

States

Returns an array of states for a given country.

GET /!/cargo/states

  • country

    string required

    Must be in ISO3 format.