Mutations

The mutations will help you to create, update, or transform an order in a shipping order or a product return

CreateOrder

Create an order

Note: This mutation can be used only for companies that can create orders. Most companies have connected Stockpit with another application, and orders are automatically created from orders of this third party application.

Parameters

input
Data of the order

Example

mutation {
    CreateOrder (
        input: {
          label: "Order#1234"
          customer: {
            id: 100123
          }
          line_items: [
            {
              quantity:10
              variant: {
                id: 100751
              }
              location: {
                id:100020
              }
            },
            {
              quantity:20
              variant: {
                id: 100759
              }
              location: {
                id:100020
              }
              batch_numbers:[ 
                {
                  batch_number:{
                  	id:189000
                  }
                  quantity:12
                },
                {
                  batch_number:{
                  	id:189666
                  }
                  quantity:8
                }
              ]
            }
          ],
          update_on_hand: false,
        }
    ){
        id
    }
}

Returned data

{
  "data": {
    "CreateOrder": {
      "id": 101122
    }
  }
}

UpdateOrder

Update an order

Parameters

id
Id of the order
input
Data of the order

Example

mutation UpdateOrder($id: ID!, $input: OrderInput!) {
  UpdateOrder(id: $id, input: $input) {
    id
    status
  }
}
{
  "id": 100010,
  "input": {
    "notes": "pHsSMebxYQ",
    "shipping_at": "2023-01-14",
    "customer": {
      "id": 100012
    },
    "line_items": [
      {
        "id": 100213,
        "quantity": 7,
        "weight": 0,
        "location": {
          "id": 100010,
        },
        "variant": {
          "id": 100337
        }
      },
      {
        "id": 100214,
        "quantity": 41,
        "weight": 1,
        "location": {
          "id": 100010,
        },
        "variant": {
          "id": 100338
        },
        "batch_numbers":[ 
          {
            "batch_number":{
              "id":189000
            },
            "quantity":20
          },
          {
            "batch_number":{
              "id":189666
            },
            "quantity":21
          }
        ]
      }
    ]
  }
}

Returned data

{
  "data": {
    "UpdateOrder": {
      "id": 1011232,
      "status": "active"
    }
  }
}

TransformIntoShippingOrder

Create a shipping order document based on an order

Parameters

id
Id of the order

Example

mutation TransformIntoShippingOrder($id: ID!) {
  TransformIntoShippingOrder(id: $id) {
    id
    label
    status
    dated_at
  }
}
{
  "id": 100009
}

Returned data

{
  "data": {
    "TransformIntoShippingOrder": {
      "id": 100010,
      "label": "SHO00000011",
      "status": "unpublished",
      "dated_at": "1996-12-31"
    }
  }
}

TransformIntoProductReturn

Create a product return document based on an order

Parameters

id
Id of the order

Example

mutation TransformIntoProductReturn($id: ID!) {
  TransformIntoProductReturn(id: $id) {
    id
    label
    status
    dated_at
  }
}
{
  "id": 100009
}

Returned data

{
  "data": {
    "TransformIntoProductReturn": {
      "id": 100010,
      "label": "PRO00000011",
      "status": "unpublished",
      "dated_at": "2024-02-08"
    }
  }
}

OrderInput data type

label
Name of the order
notes
Notes of the order
total_units
Total units sold in the order
status
Status of the order : active, archived, cancelled, completed or unpublished
update_on_hand
Define if the order update the on hand stocks
customer
Customer of the order
line_items
  • Array of LineItemOrderInput
Line items of the order
dated_at
Date of the order
shipping_at
Shipping date of the order
shipping_address
Address the order will be shipped to