Create an Order

The first step to using our e-commerce experience is to create an order using our createOrder mutation.
createOrder has an input of type NewOrder and returns a CreateOrderResponse.

  • If you are creating an order in the Approval First flow, then you should not include any items in the input when you create an order. This represents a customer applying without any items in their cart

  • If you are creating an order in the Shop First flow, then you should include items when you create the order as this represents the actual items in a customer's cart when they checkout.

  • Our system uses the presence of items in the cart to interpret the flow and tailors the experience based on the flow

You can create a new order through Postman or our sandbox playground by copying our mutation below updating the input data for your use case. As it is written, the mutation below will create a new order, return the orderID and the type name of any orders encountered. If the mutation returns an error of type FatalError or type BadRequest, then it will also return the message for the respective error.

If this is your first time using GraphQL then we recommend using our playground as it will give you more information on the schemas. You must include your public-dealer-id in any request even if it is sent through the playground. You can add this on the bottom left of the screen under the section HTTP Headers

460460
{
"public-dealer-id":<your public-dealer-ID>
}

*At the time of this writing, the NewOrder input looks like the below, however our API schemas can change over time so be sure to check out our API Schema for the most up to date changes. Our schema will also denote which fields are required for a new order and which fields are optional.

mutation CreateOrder() {
  createOrder(input: {
    details:{
      customer:{
        firstName:"John", 
        lastName:"Flannery", 
        emailAddress:"[email protected]" 
        cellPhone:"123456789"
      },
      dealerConfig:{
        checkoutFlowType: modal
      },
       items:[
        {
          displayName:"Ejection Seat", 
          sku:"1776484", 
          quantity:2, 
          price:"400",
            itemImageUrl: "http://local.magento/pub/static/frontend/Magento/luma/en_US/Magento_Catalog/images/product/placeholder/thumbnail.jpg",
          itemUrl: "http://local.magento/index.php/coffee.html"
        }
      ],
      shippingAmnt: "3.99"
      taxAmnt: "5.00"

    },
  }){
    order{
      id
    }
    orderErrors{
      __typename
      ... on FatalError{
        message
      }
      ... on BadRequest{
        message
      }
    }
  }
}