Skip to content

Create an Order

Overview

This guide will step you through the process of creating an order with the Veeqo API.

Prerequisites

To create an Order you must have the following set up on your Veeqo account:

  • A valid product and product variant(s). You can create/retrieve these on the /products endpoint.
  • A direct store to make the order on. You can create/retrieve these on the /channels endpoint.
  • A delivery method. You can create/retrieve these on the /delivery_methods endpoint.
  • A customer to add the order to. You can create/retrieve these on the /customers endpoint.

Walkthrough

We need to gather some required ID's before we can make our POST request to the /orders endpoint. The table below shows you all the required parameters to create an order. For some of them (/customers and /delivery_methods endpoints) you can instead pass objects in the request to create new ones instead of passing through the ID.

Parameter Endpoint
channel_id /channels
customer_id /customers
deliver_to_id /customers
delivery_method_id /delivery_methods
sellable_id /products

In this example, we will be using ID's only and we will obtain them step by step all through the API.

Store

We made the following request:

GET https://api.veeqo.com/channels?type_code=direct

Response:

[
  {
    "id": 121212,
    "type_code": "direct",
    "created_by_id": 123456,
    "name": "Phone",
    "short_name": "US",
    "currency_code": "GBP",
    ...
  },
  ...
]

From this response, we will save:

  • "id": 121212, which will be used as channel_id later.

Customer

We made the following request:

GET https://api.veeqo.com/customers

Response:

[
 {
  "id": 123,
  "email": "Phil+API@veeqo.com",
  "phone": "01792 720740",
  "mobile": "07329023903",
  "notes": "This person buys things",
  "created_by_id": 12005,
  ...
  "shipping_addresses": [
    {
      "id": 12345678,
      "first_name": "Phil",
      "last_name": "Reynolds",
      "company": "Veeqo Ltd",
      "address1": "Tech Hub",
      "address2": "221 High Street",
      "city": "Swansea",
      "country": "GB",
      "state": "",
      "zip": "SA1 1NW",
      "phone": ""
    }
  ],
  ...
 },
 ...
]

In this response, we are saving two pieces of data.

  • "id": 123, from the first customer object, which we are using for customer_id.
  • "id": 12345678, from the "shipping_addresses" array within the first customer, which we are using for deliver_to_id.

Delivery Method

We made the following request:

GET https://api.veeqo.com/delivery_methods

Response:

[
  {
    "id": 123456,
    "cost": "0.0",
    "name": "Default delivery method",
    "user_id": 23005,
    "created_at": "2017-07-04T09:40:37.535Z",
    "updated_at": "2017-07-04T09:40:37.535Z"
  },
  ...
]

In this response, we will save:

  • "id": 123456, from the delivery method we want to use for delivery_method_id.

Product Variant

We made the following request:

GET https://api.veeqo.com/products

Response:

[
  {
    "id": 8636420,
    "title": "Golden Retriever Dog - Title",
    "created_by_id": 23005,
    "created_at": "2017-10-13T09:08:13.707Z",
    "weight": 0,
    ...
    "sellables": [
      {
        "total_quantity_sold": 0,
        "allocated_stock_level_at_all_warehouses": 0,
        "id": 14144703,
        "type": "ProductVariant",
        "title": "Puppy - ProdVariantTitle",
        "sku_code": "g-dog-2",
        "upc_code": "",
        ...
      },
      ...
    ],
    "channel_products": [],
    "active_channels": [],
    "tags": [],
    "image": "https://thumbnails.veeqo.com/example-image",
    "description": "",
    "on_hand_value": 0,
    "main_image_src": "https://thumbnails.veeqo.com/example-image",
    "total_allocated_stock_level": 5,
    "total_available_stock_level": 5,
    "total_stock_level": 10,
    "inventory": {
      "infinite": false
    }
  }
]

From this response, we will save:

  • Inside the "sellables" object of the product we want to add to the order, we will take "id": 14144703, to use for our sellable_id.

Order

Finally, we can make our POST request in order to create the order on Veeqo:

POST https://api.veeqo.com/orders

Payload:

{
  "order": {
    "channel_id": 121212,
    "customer_id": 123,
    "deliver_to_id": 12345678,
    "delivery_method_id": 123456,
    "line_items_attributes": [
      {
        "sellable_id": 14144703,
        "price_per_unit": "10.000",
        "quantity": "1"
      }
    ],
    "payment_attributes": {
      "payment_type": "paypal"
    }
  }
}