Quick Start Guide

Get up and running with the QPilot API on a few steps with this guide

📘

Don't have a connected QPilot site yet?

QPilot is free to try, but you must have a registered QPilot Account and connected QPilot Site before you can make calls to the QPilot API. See our current integrations here or get in touch with us directly about developing new integrations.

Step 1: Getting authenticated to make API calls

Requests to the API require HTTP Bearer Token Authentication. Once you have received an Access Token, additional requests can be made by including the TokenBearerAuth value in the Authorization header.

Example:

GET /api/ScheduledOrders HTTP/1.1 Authorization: Bearer <TokenBearerAuth>

You must first get an Access Token to make calls to the API. An access token must specify Access Scope. There are two types of Access Scopes for an Access Token:

  • Merchant
  • Customer

Getting a Merchant Access Token

A Merchant Access Token grants access to all merchant features of the API. This access token can be used to access all merchant data, and the access token should be re-generated (refreshed) for each request.

Example:

POST /AccessTokens/Login HTTP/1.1

{
    "email": "<your account email address>",  
    "password": "<your account password>",  
    "accessScope": "Merchant"
}

Getting a Customer Access Token

Customer Access Token grants limited access to a customer. This type of access token is intended to be given directly to a customer in order to make changes to Scheduled Orders. The CustomerId must be provided when requesting Customer Access Scope, and the access token should be re-generated (refreshed) for each request.

Example:

POST /Sites/{siteId}/AccessTokens/CustomerLogin HTTP/1.1

{
    "email": "<your account email address>",  
    "password": "<your account password>",
    "customerId": "0001"
}

Step 2: Create a Customer

Customers are central to QPilot, and you will need one in order to create your first Scheduled Order.

Example request

POST /Sites/{your-site-id}/Customers HTTP/1.1

{
    "id": "29920",
    "email": "[email protected]",
    "firstName": "Chris",
    "lastName": "Wilking",
    "shippingFirstName": "Chris",
    "shippingLastName": "Wilkins",
    "shippingStreet1": "740 Evergreen Terrace",
    "shippingCity": "Springfield",
    "shippingState": "Washington",
    "shippingCountry": "US"      
}

📘

Note

To find out more about Customers fields and other examples, please see the Customers section

Step 3: Create a Payment Method for the Customer

One or more payment methods can be created and assigned to a Customer.

Example request: creating a payment method for a Customer

POST /Sites/{your-site-id}/PaymentMethods HTTP/1.1

{
    "customerId": "29920",
    "type": "Stripe",
    "gatewayCustomerId": "<a tokenized customer id>",
    "gatewayPaymentId": "<a tokenized payment id>"
}

You can also create a Payment Method during the creation of a Customer on a single call:

Example request: creating a Customer with a Payment Method:

{
   "id":"29920",
   "email":"[email protected]",
   "firstName":"Chris",
   "lastName":"Wilking",
   "shippingFirstName":"Chris",
   "shippingLastName":"Wilkins",
   "shippingStreet1":"740 Evergreen Terrace",
   "shippingCity":"Springfield",
   "shippingState":"Washington",
   "shippingCountry":"US",
   "paymentMethods":[
      {
         "type":"Stripe",
         "gatewayCustomerId":"<a tokenized customer id>",
         "gatewayPaymentId":"<a tokenized payment id>"
      }
   ]
}

📘

Note

To find out more about Payment Methods fields and other examples, please see the Payment Methods section

Step 4: Create a Product

A Scheduled Order can contain one or more Scheduled Order items. Items are connected to actual Products.

Example request: creating a Product:

POST /Sites/{your-site-id}/Products HTTP/1.1

{
  "id": "100982",
  "siteId": <your-site-id>,
  "title": "RCo Atlantis Moisturizing Shampoo 8 oz",
  "price": 9.75,
  "salePrice": 6,
  "sku": "rco-atl-993",
  "gtin": "97350053850012",
  "mpn": "QP1234LOT",
  "length": "4",
  "width": "2",
  "height": "5",
  "weight": "1",
  "weightUnitType": "Pound",
  "lengthUnitType": "Inch",
  "addToScheduledOrder": true,
  "processScheduledOrder": true,
  "availability": "InStock",
  "stock": 50
}

📘

Note

To find out more about Products fields and other examples, please see the Products section

Step 5: Create a Scheduled Order

Now that you have created and set up all related entities, it's time to create a Scheduled Order and put QPilot to work:

Example request: creating a Scheduled Order for a Customer, specifying a Payment Method and Scheduled Order Items:

POST /Sites/{your-site-id}/ScheduledOrders HTTP/1.1

{
   "customerId":"15",
   "paymentMethodId":10933,
   "frequencyType":"Days",
   "frequency":30,
   "scheduledOrderItems":[
      {
         "productId":"100982",
         "quantity":4
      }
   ]
}

📘

Note

To find out more about Scheduled Orders fields and other examples, please see the Scheduled Orders section