Developer Resources > Examples

Examples

 

In this section, we will explore some examples of the different queries & mutations available on the API.

Note: For better readability, all of the available fields are not included in our example queries. To navigate through the Schema and see all of the fields available, please check our Documentation section.

Queries:

uuid:

When using the old webhooks you might receive resource ids as numeric ids. If you need any of those ids in one of our new queries or mutations, you can use this query to retrieve the uuid corresponding to that resource/entity numeric id as:

 query { 
    uuid(legacy_id:100579698, entity: Order) { 
        data { 
            legacy_id 
            id
        }
    }
}

and the response should look something like this:

{
  "data": {
    "uuid": {
      "data": {
        "legacy_id": 100579698,
        "id": "T3JkZXI6MTAwNTc5Njk4"
      }
    }
  }
}

Order:

This feature of the API allows to access a order’s details. To make it you should specify the order_id:

query {
  order(id: "T3JkZXI6MTAwNTc0MjM1") {
    request_id
    complexity
    data {
      id
      legacy_id
      order_number
      shop_name
      fulfillment_status
      order_date
      profile
      required_ship_date
      shipping_lines {
        carrier
        method
        price
      }
      shipping_address {
        first_name
        last_name
        address1
        address2
        city
        state
        state_code
        zip
        country
      }
      tags
      line_items(first: 2) {
        edges {
          node {
            id
            sku
            quantity
            product_name
            fulfillment_status
            quantity_allocated
            backorder_quantity
            barcode
          }
          cursor
        }
      }
      shipments {
        id
        order_id
        user_id
        warehouse_id
        address {
          name
          address1
          address2
          city
          state
          country
          zip
        }
        shipped_off_shiphero
        dropshipment
      }
      returns {
        id
        reason
        status
      }
    }
  }
}

Response:

{
  "data": {
    "order": {
      "request_id": "5d5454dd47de2ba3e95322c5",
      "complexity": 3,
      "data": {
        "id": "T3JkZXI6MTAwNTc0MjM1",
        "legacy_id": 100574235,
        "order_number": "MO519",
        "shop_name": "Manual Order",
        "fulfillment_status": "pending",
        "order_date": "2019-07-16T14:46:03+00:00",
        "profile": "default",
        "required_ship_date": "2019-07-18T00:00:00+00:00",
        "shipping_lines": {
          "carrier": "amazon",
          "method": "99",
          "price": null
        },
        "shipping_address": {
          "first_name": null,
          "last_name": null,
          "address1": "55 W RAILROAD AVE BLDG 4",
          "address2": null,
          "city": "GARNERVILLE",
          "state": "NY",
          "state_code": null,
          "zip": "10923-1261",
          "country": "US"
        },
        "tags": null,
        "line_items": {
          "edges": [
            {
              "node": {
                "id": "TGluZUl0ZW06Mjk0MDc2OTEw",
                "sku": "leandro-build-kit",
                "quantity": 1,
                "product_name": "Leandro Build Kit",
                "fulfillment_status": "broken_in_sets",
                "quantity_allocated": 0,
                "backorder_quantity": 0,
                "barcode": null
              },
              "cursor": "YXJyYXljb25uZWN0aW9uOjA="
            },
            {
              "node": {
                "id": "TGluZUl0ZW06Mjk0MDc2OTI0",
                "sku": "regular-kit-item-1",
                "quantity": 1,
                "product_name": "Regular Kit Item 1",
                "fulfillment_status": "pending",
                "quantity_allocated": 1,
                "backorder_quantity": 0,
                "barcode": null
              },
              "cursor": "YXJyYXljb25uZWN0aW9uOjE="
            }
          ]
        },
        "shipments": [],
        "returns": []
      }
    }
  }
}

Note: If your query includes line_items, it is recommended to use first or last so that the complexity of the query does not become too big.

Returns:

We now have a more robust and complete way of accessing returns by using both the returns and return queries.
For example, if we needed to get information about a specific return, we will use the return Query, specifying the id.
The query should look something like this:

query {
  return(id: "UmV0dXJuOjc1MzYyNA==") {
    request_id
    complexity
    data {
      id
      legacy_id
      account_id
      order_id
      reason
      status
      label_type
      label_cost
      cost_to_customer
      shipping_carrier
      shipping_method
      address {
        address1
        address2
        city
        state
        country
        zip
      }
      line_items {
        id
        line_item_id
        warehouse_id
        product_id
        return_id
        quantity
        condition
      }
    }
  }
}

And the response should look something like this:

{
  "data": {
    "return": {
      "request_id": "5d544301831f49c86c79f2c1",
      "complexity": 1,
      "data": {
        "id": "UmV0dXJuOjc1MzYyNA==",
        "legacy_id": 753624,
        "account_id": "QWNjb3VudDozODAx",
        "order_id": "T3JkZXI6MTAwNDg5MDkz",
        "reason": null,
        "status": "pending",
        "label_type": "PAID",
        "label_cost": "0.00",
        "cost_to_customer": "0.00",
        "shipping_carrier": "genericlabel",
        "shipping_method": "genericlabel",
        "address": {
          "address1": "55 W RAILROAD AVE BLDG 4",
          "address2": "BLDG 4",
          "city": "GARNERVILLE",
          "state": "NY",
          "country": "US",
          "zip": "10923-1261"
        },
        "line_items": [
          {
            "id": "UmV0dXJuSXRlbToxMjExOTA0",
            "line_item_id": "TGluZUl0ZW06MjkzODA4NTI3",
            "warehouse_id": "V2FyZWhvdXNlOjY1NDU=",
            "product_id": null,
            "return_id": "UmV0dXJuOjc1MzYyNA==",
            "quantity": 1,
            "condition": "No longer wants"
          }
        ]
      }
    }

Browse order history:

This new feature of the API allows navigating through an order’s history. To make it you should specify the order_id:

query {
  order_history(order_id: "T3JkZXI6OTkxMzAxMjE=") {
    request_id
    complexity
    data(first: 2) {
      edges {
        node {
          id
          order_id
          account_id
          order_number
          information
          order {
            shop_name
            fulfillment_status
            order_date
            email
            profile
            packing_note
            required_ship_date
            shipping_address {
              first_name
              last_name
              company
              address1
              address2
              city
              state
              state_code
              zip
              country
              country_code
              email
              phone
            }
          }
        }
        cursor
      }
    }
  }
}

Response:

{
  "data": {
    "order_history": {
      "request_id": "5d3b5f77233bd12e389388dc",
      "complexity": 3,
      "data": {
        "edges": [
          {
            "node": {
              "id": "T3JkZXJIaXN0b3J5OjIxMDk4MzkzNQ==",
              "order_id": "T3JkZXI6OTkxMzAxMjE=",
              "account_id": "QWNjb3VudDozODAx",
              "order_number": "MO506",
              "information": "Order Created.",
              "order": {
                "shop_name": "Manual Order",
                "fulfillment_status": "pending",
                "order_date": "2019-06-25T13:46:21+00:00",
                "ready_to_ship": false,
                "email": null,
                "profile": "default",
                "packing_note": null,
                "required_ship_date": "2019-06-27T00:00:00+00:00",
                "shipping_address": {
                  "first_name": null,
                  "last_name": null,
                  "company": null,
                  "address1": "54 W RAILROAD AVE BLDG 4",
                  "address2": "BLDG 4",
                  "city": "GARNERVILLE",
                  "state": "NY",
                  "state_code": null,
                  "zip": "10923",
                  "country": "US",
                  "country_code": null,
                  "email": null,
                  "phone": "8556055222"
                }
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjA="
          },
          {
            "node": {
              "id": "T3JkZXJIaXN0b3J5OjIxMTAzNTcxNA==",
              "order_id": "T3JkZXI6OTkxMzAxMjE=",
              "account_id": "QWNjb3VudDozODAx",
              "order_number": null,
              "information": "Order lock was cleared manually by using the \"Remove Order Locks\" button for this user.",
              "order": {
                "shop_name": "Manual Order",
                "fulfillment_status": "pending",
                "order_date": "2019-06-25T13:46:21+00:00",
                "email": null,
                "profile": "default",
                "packing_note": null,
                "required_ship_date": "2019-06-27T00:00:00+00:00",
                "shipping_address": {
                  "first_name": null,
                  "last_name": null,
                  "company": null,
                  "address1": "54 W RAILROAD AVE BLDG 4",
                  "address2": "BLDG 4",
                  "city": "GARNERVILLE",
                  "state": "NY",
                  "state_code": null,
                  "zip": "10923",
                  "country": "US",
                  "country_code": null,
                  "email": null,
                  "phone": "8556055222"
                }
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjE="
          }
        ]
      }
    }
  }
}

Note: If your query includes line_items, it is recommended to use first or last so that the complexity of the query does not become too big.

Packs per day:

Gets the detail of each shipment’s package between the specified dates. Results are sorted by date, warehouse and user, but they can be filtered by warehouse_id if only interested in the packages from a particular warehouse.
The sorting can be overridden by specifying any other field or list of fields from the output type. In the following example, we want to retrieve certain info about what a user has packed on 2019-05-03. So the query for that would be something like:

query {
  packs_per_day(
    user_id: "VXNlcjo5MTIz"
    date_from: "2019-05-03"
    date_to: "2019-05-04"
  ) {
    request_id
    complexity
    data {
      edges {
        node {
          id
          shipment_id
          warehouse_id
          total_items
          unique_items
          barcodes_scanned
          created_at
          order {
            id
            order_number
          }
        }
        cursor
      }
    }
  }
}

And the response would look something like this:

{
  "data": {
    "packs_per_day": {
      "request_id": "5d3bd22669af712be6bacd54",
      "complexity": 101,
      "data": {
        "edges": [
          {
            "node": {
              "id": "UGFja1Jlc3VsdDoyOTkwNDc0Nw==",
              "shipment_id": "U2hpcG1lbnQ6NTA3OTI2ODI=",
              "warehouse_id": "V2FyZWhvdXNlOjY1NDU=",
              "total_items": 1,
              "unique_items": 1,
              "barcodes_scanned": 0,
              "created_at": "2019-05-03T20:11:05+00:00",
              "order": {
                "id": "T3JkZXI6OTYwMzI2NjU=",
                "order_number": "MO451"
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjA="
          },
          {
            "node": {
              "id": "UGFja1Jlc3VsdDoyOTkwNTgzOQ==",
              "shipment_id": "U2hpcG1lbnQ6NTA3OTQxNzg=",
              "warehouse_id": "V2FyZWhvdXNlOjY1NDU=",
              "total_items": 2,
              "unique_items": 2,
              "barcodes_scanned": 0,
              "created_at": "2019-05-03T20:32:12+00:00",
              "order": {
                "id": "T3JkZXI6OTE3MDM5MTg=",
                "order_number": "MO335"
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjE="
          },
          {
            "node": {
              "id": "UGFja1Jlc3VsdDoyOTkwNjI5Mg==",
              "shipment_id": "U2hpcG1lbnQ6NTA3OTQ3MDU=",
              "warehouse_id": "V2FyZWhvdXNlOjY1NDU=",
              "total_items": 1,
              "unique_items": 1,
              "barcodes_scanned": 0,
              "created_at": "2019-05-03T20:40:52+00:00",
              "order": {
                "id": "T3JkZXI6OTU2NzQ1MTQ=",
                "order_number": "MO420"
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjI="
          }
        ]
      }
    }
  }
}

Line items pick:

Gets the detail of each line item picked between the specified dates. Results are sorted by date, warehouse, and user, but they can be filtered by warehouse_id if only interested in the picks from a particular warehouse. The sorting can be overridden by specifying any other field or list of fields from the output type.

For example, if we wanted to retrieve certain info about what items had been picked on 2019-04-30.

query {
  picks_per_day(date_from: "2019-04-30", date_to: "2019-05-01") {
    request_id
    complexity
    data {
      edges {
        node {
          id
          user_id
          tote_id
          line_item_id
          location_id
          order_id
          order_number
          user_first_name
          user_last_name
          inventory_bin
          sku
          quantity
          picked_quantity
          pick_type
          barcode_scanned
          created_at
        }
        cursor
      }
    }
  }
}

And the response would look something like this:

{
  "data": {
    "picks_per_day": {
      "request_id": "5d3bd9ee370a8cb90b7a8013",
      "complexity": 101,
      "data": {
        "edges": [
          {
            "node": {
              "id": "UGlja1Jlc3VsdDoxOTg0MzQ5OQ==",
              "user_id": "VXNlcjo5MTIz",
              "tote_id": "VG90ZToxMTk3OTc=",
              "line_item_id": "TGluZUl0ZW06Mjc4NDI2MDUw",
              "location_id": "QmluOjA=",
              "order_id": "T3JkZXI6OTU3MjQyNzk=",
              "order_number": "MO425",
              "user_first_name": "Tom",
              "user_last_name": "Wingord",
              "inventory_bin": null,
              "sku": "12347944271944",
              "quantity": 1,
              "picked_quantity": 1,
              "pick_type": null,
              "barcode_scanned": "No",
              "created_at": "2019-04-30T06:48:29+00:00"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjA="
          },
          {
            "node": {
              "id": "UGlja1Jlc3VsdDoxOTg0MzUwMg==",
              "user_id": "VXNlcjo5MTIz",
              "tote_id": "VG90ZToxMTk3OTc=",
              "line_item_id": "TGluZUl0ZW06Mjc4NDI2MDQ5",
              "location_id": "QmluOjA=",
              "order_id": "T3JkZXI6OTU3MjQyNzk=",
              "order_number": "MO425",
              "user_first_name": "Tom",
              "user_last_name": "Wingord",
              "inventory_bin": null,
              "sku": "12280811454536",
              "quantity": 1,
              "picked_quantity": 1,
              "pick_type": null,
              "barcode_scanned": "No",
              "created_at": "2019-04-30T06:48:32+00:00"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjE="
          },
          {
            "node": {
              "id": "UGlja1Jlc3VsdDoxOTg0MzUwOA==",
              "user_id": "VXNlcjo5MTIz",
              "tote_id": "VG90ZToxMTk3OTc=",
              "line_item_id": "TGluZUl0ZW06Mjc4NDI2MDQ3",
              "location_id": "QmluOjA=",
              "order_id": "T3JkZXI6OTU3MjQyNzk=",
              "order_number": "MO425",
              "user_first_name": "Tom",
              "user_last_name": "Wingord",
              "inventory_bin": null,
              "sku": "12838025822280",
              "quantity": 1,
              "picked_quantity": 1,
              "pick_type": null,
              "barcode_scanned": "No",
              "created_at": "2019-04-30T06:48:35+00:00"
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjI="
          }          
        ]
      }
    }
  }
}

Warehouse products:

Using the warehouse_id you can retreive the products from that warehouse, for example:

query {
  warehouse_products(warehouse_id: "V2FyZWhvdXNlOjgwNzU=") {
    request_id
    complexity
    data(first: 2) {
      edges {
        node {
          id
          account_id
          on_hand
          inventory_bin
          reserve_inventory
          reorder_amount
          reorder_level
          custom
          warehouse {
            id
            dynamic_slotting
            profile
          }
          product {
            id
            name
            sku
          }
        }
        cursor
      }
    }
  }
}

And the response should look something like this:

{
  "data": {
    "warehouse_products": {
      "request_id": "5d3bdbbf69af712be6bacd5c",
      "complexity": 3,
      "data": {
        "edges": [
          {
            "node": {
              "id": "UHJvZHVjdDoyODkxOTYyNjY=",
              "account_id": "QWNjb3VudDozODAx",
              "on_hand": 0,
              "inventory_bin": null,
              "reserve_inventory": 0,
              "reorder_amount": 1,
              "reorder_level": 0,
              "custom": false,
              "warehouse": {
                "id": "V2FyZWhvdXNlOjgwNzU=",
                "dynamic_slotting": false,
                "profile": "default"
              },
              "product": {
                "id": "UHJvZHVjdEluZm86MjYyODc2NDA3",
                "name": "8th of LA Short Overalls- Ally Wash Large",
                "sku": "12258196226120"
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjA="
          },
          {
            "node": {
              "id": "UHJvZHVjdDoyODcxNTM4OTA=",
              "account_id": "QWNjb3VudDozODAx",
              "on_hand": 0,
              "inventory_bin": null,
              "reserve_inventory": 0,
              "reorder_amount": 1,
              "reorder_level": 0,
              "custom": false,
              "warehouse": {
                "id": "V2FyZWhvdXNlOjgwNzU=",
                "dynamic_slotting": false,
                "profile": "default"
              },
              "product": {
                "id": "UHJvZHVjdEluZm86MjYyODc5NTI5",
                "name": "Deep Mint Ombre Hoodie X-Small",
                "sku": "12266021355592"
              }
            },
            "cursor": "YXJyYXljb25uZWN0aW9uOjE="
          }
        ]
      }
    }
  }
}