WeSupply API Documentation

The WeSupply API allows you to push arbitrary data into WeSupply system. We built it using REST principles for simplicity.
This API accepts and returns valid JSON for all its methods. Each method uses a standard HTTP verb (GET/POST) and uses standard HTTP response codes for returning statuses.

Authentication

Authentication with the Data Import API is done with a generated token. You can create this token by using your client_id and client_secret params, and "client_credentials" as grant_type

<?php

$url = "https://wesupply_client_url/api/oauth/token";
$clienttoken_post = array(
    "grant_type" => "client_credentials",
    "client_id" => 'your_client_id',
    "client_secret" => 'your_client_secret'
);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => http_build_query($clienttoken_post),
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "content-type: application/x-www-form-urlencoded"

    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
?>

Return Codes

Codes in the 2xx range indicate a successful transaction, codes in the 4xx range indicate a bad request, and codes in the 5xx range indicate an error on our end. If errors in the 5xx range persist, please contact RJMetrics support.

400 Bad request - Your request was missing a required parameter.
401 Unauthorized - Authorization failed. Double check your access token.
404 Not Found - The resource you are looking for does not exist.
503 Error - Something wrong with the orders xml structure - you will receive a specific error description pointing out the cause of the error

Send Order Data

The SendOrderData operation allows you to send external orders to WeSupply.AI.

<?php

$accesToken = 'access_token';
$post_array = array('orders'=> '<?xml version="1.0" encoding="utf-8"?>
        <!-- YOUR ORDER XML DATA HERE
	============================================= -->
');

$buildQuery = http_build_query($post_array);
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => 'https://wesupply_client_url/api/import',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_POSTFIELDS => $buildQuery,
    CURLOPT_HTTPHEADER => array("Authorization: Bearer $accesToken")
));

$response = curl_exec($ch);
print_r($response);

?>

Order XML Data

Parameter Description
<Orders>						
	<Order>					
		<StoreId>1</StoreId>				
		<WesupplyUpdatedAt>2018-02-05 20:43:41</WesupplyUpdatedAt>				
		<LastModifiedDate>2018-02-02 16:42:52</LastModifiedDate>				
		<OrderModified>2018-02-02 16:42:52</OrderModified>				
		<OrderPaymentTypeId/>				
		<OrderID>2</OrderID>				
		<OrderNumber>000000002</OrderNumber>				
		<OrderContact>Veronica Costello</OrderContact>				
		<FirstName>Veronica</FirstName>				
		<LastName>Costello</LastName>				
		<OrderDate>2018-02-02 16:42:51</OrderDate>				
		<OrderAmount>32.0000</OrderAmount>				
		<OrderAmountShipping>5.0000</OrderAmountShipping>				
		<OrderAmountTax>2.6400</OrderAmountTax>				
		<OrderAmountTotal>39.6400</OrderAmountTotal>				
		<OrderAmountCoupon>0</OrderAmountCoupon>				
		<OrderAmountGiftCard>0</OrderAmountGiftCard>				
		<OrderAmountCredit>				
		<OrderShippingAddress1>6146 Honey Bluff Parkway</OrderShippingAddress1>				
		<OrderShippingAddress2>				
		<OrderShippingCity>Calder</OrderShippingCity>				
		<OrderShippingStateProvince>Michigan</OrderShippingStateProvince>				
		<OrderShippingZip>49628-7978</OrderShippingZip>				
		<OrderShippingPhone>(555) 229-3326</OrderShippingPhone>				
		<OrderShippingCountry>United States</OrderShippingCountry>				
		<OrderShippingCountryCode>US</OrderShippingCountryCode>				
		<OrderPaymentType>Check / Money order</OrderPaymentType>				
		<OrderCardNumber/>				
		<OrderCardExp/>				
		<OrderCardType/>				
		<OrderGiftCardNumber/>				
		<OrderGiftWrapping>false</OrderGiftWrapping>				
		<OrderGiftWrappingCost>0</OrderGiftWrappingCost>				
		<OrderGiftWrappingMessage/>				
		<OrderDiscountDetailsTotal>0.0000</OrderDiscountDetailsTotal>				
		<OrderExternalOrderID>000000002</OrderExternalOrderID>				
		<OrderComeFrom>				
		<OrderSalesPerson/>				
		<OrderSalesPersonNumber/>				
		<OrderStatus>Closed</OrderStatus>				
		<OrderStatusId>2</OrderStatusId>				
		<OrderCustom1>				
		<OrderCustom2>				
		<OrderCustom3>				
		<OrderCustom4>				
		<OrderCustom5>				
			<OrderCustomer>
				<CustomerID>			
				<CustomerCompany>		
				<CustomerName>Veronica Costello</CustomerName>		
				<CustomerFirstName>Veronica</CustomerFirstName>		
				<CustomerLastName>Costello</CustomerLastName>		
				<CustomerAddress1>314 Washington Pl</CustomerAddress1>		
				<CustomerAddress2/>		
				<CustomerCity>Hasbrouck Heights</CustomerCity>		
				<CustomerStateProvince>NJ</CustomerStateProvince>		
				<CustomerPostalCode>49628-7978</CustomerPostalCode>		
				<CustomerCountry>USA</CustomerCountry>		
				<CustomerCountryCode>US</CustomerCountryCode>		
				<CustomerEmail>[email protected]</CustomerEmail>		
				<CustomerPhone>7327405970</CustomerPhone>		
				<CustomerShippingAddresses>		
					<CustomerShippingAddress>	
						<AddressID>3</AddressID>
						<AddressContact>Veronica Costello</AddressContact>
						<AddressAddress1>6146 Honey Bluff Parkway</AddressAddress1>
						<AddressAddress2>
						<AddressCity>Calder</AddressCity>
						<AddressState>Michigan</AddressState>
						<AddressZip>49628-7978</AddressZip>
						<AddressCountry>United States</AddressCountry>
						<AddressCountryCode>US</AddressCountryCode>
						<AddressPhone>(555) 229-3326</AddressPhone>
					</CustomerShippingAddress>	
				</CustomerShippingAddresses>		
			</OrderCustomer>			
		<OrderItems>				
			<Item>			
				<ItemID>2</ItemID>
				<ItemPOShipper>FedEx</ItemPOShipper>
				<ItemName>		
				<ItemSKU>		
				<ItemUPC>		
				<ItemStyleNo>		
				<ItemPrice>32.0000</ItemPrice>		
				<ItemAddressID>3</ItemAddressID>
				<LineItemNumber>		
				<Option1>Size: XS Color: Blue</Option1>		
				<Option2>Color: Blue</Option2>		
				<Option3>		
				<Option4>		
				<Option5>		
					<ItemProduct>	
						<ProductID>1497</ProductID>
						<ProductCode>Minerva LumaTechâ„¢ V-Tee</ProductCode>
						<ProductImageURL>1497</ProductImageURL>
						<ProductPartNo>WS08-XS-Blue</ProductPartNo>
						<ProductUPC>
						<ProductStyleNo>
						<ProductXtra1>
						<ProductXtra2>
						<ProductXtra3>
						<ProductXtra4>
						<ProductXtra5>
					</ItemProduct>	
				<ItemQuantity>1.0000</ItemQuantity>		
				<ItemShippingService>UPS SurePost 1 lb or Greater</ItemShippingService>		
				<ItemShippingTracking>1ZY45F73YW99798395</ItemShippingTracking>		
				<ItemTotal>32.0000</ItemTotal>		
				<ItemTax>2.6400</ItemTax>		
				<ItemCouponAmount>0.0000</ItemCouponAmount>		
				<ItemStatus>Refunded</ItemStatus>		
				<ItemStatusId>2</ItemStatusId>		
				<ItemNotes/>		
				<ItemReturnReason/>		
				<ItemReturnStatus/>		
				<ItemReturnType/>		
				<ItemSupplierCode>KicksUSA-Orange</ItemSupplierCode>		
				<ItemLevelSupplierID>1685</ItemLevelSupplierID>		
				<ItemLevelSupplierName>1037</ItemLevelSupplierName>		
				<CustomData1/>		
				<CustomData2/>		
				<CustomData3/>		
				<CustomData4/>		
				<CustomData5/>		
			</Item>			
		</OrderItems>				
	</Order>				
	<Response>					
		<ResponseHasErrors>false</ResponseHasErrors>				
		<ResponseCode>SUCCESS</ResponseCode>				
		<ResponseDescription/>				
	</Response>					
</Orders>						
										


If Multistore set store ID value, ex. 1, 2, 3. else : 1
Last Modified Order Date
Last Modified Order Date
Last Modified Order Date
Payment Type ID
Order ID (mandatory)
Order Number Internal (if inexistent then External)
Customer First and Last Name
Customer First Name
Customer Last Name
Order Creation Date (mandatory and valid date format)
Order Amount (Subtotal) (mandatory and numeric)
Shipping Amount
Order Total Tax Amount(mandatory and numeric)
Order Grand Total (mandatory and numeric)
Order Coupon Amount (Discount)
Order Gift Card Amount
Order Store Credit Amount
Order Shipping Address Line 1
Order Shipping Address Line 2
Order Shipping City
Order Shipping State (mandatory)
Order Shipping Zip Code (mandatory)
Order Shipping Phone Number
Order Shipping Country (mandatory)
Order Shipping Country Code
Order Payment Type: CC / GC / COD
CC Last 4 digits
CC Expiration Date
CC Type
Gift Card Number
Gift Wrapping
Gift Wrapping Cost
Gift Wrapping Message
Order Discount Amount
Order Number (External order number such as Ecomm platform order number)(mandatory)
Order Source
Order Sales Person
Order Sales Person Number (ID)
Order Status (Processing / Canceled / Shipped / Returned)
Order Status ID
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data

Customer Id (mandatory and numeric)
Customer Billing Company
Customer Billing First and Last Name
Customer Billing First Name
Customer Billing Last Name
Customer Billing Address 1
Customer Billing Address 2
Customer Billing City
Customer Billing State
Customer Billing Zip Code
Customer Billing Country
Customer Billing Country Code
Customer Billing Email (mandatory and valid email format)
Customer Billing Phone Number


Customer Shipping Address ID(mandatory and numeric - must be equal to <AddressID>
Customer Shipping Address First and Last Name(leave empty if no info)
Customer Shipping Address Line 1(leave empty if no info)
Customer Shipping Address Line 2
Customer Shipping Address City(leave empty if no info)
Customer Shipping Address State(mandatory)
Customer Shipping Address ZIP(mandatory)
Customer Shipping Address Country(mandatory)
Customer Shipping Address Contry Code(leave empty if no info)
Customer Shipping Address Phone Number(leave empty if no info)





Order Item ID(mandatory and numeric)
Item Shipper(mandatory)
Order Item Name
Order Item SKU
Order Item UPC
Order Item Style No
Order Item Price(mandatory and numeric)
Order Item Shipping Address ID(mandatory and numeric)
Order Item Line Item Number
Order Item Variables





Order Item Variable ID(mandatory and numeric)
Order Item Variable Name(mandatory)
Order Item Variable Image external URL
Order Item Variant SKU
Order Item Variant UPC
Order Item Variant Style No






Order Item QTY(mandatory and numeric)
Order Item Shipping Method
Order Item Shipping Tracking Number
Order Item Total Amount(mandatory and numeric)
Order Item Tax Amount
Order Item Discount Amount
Order Item Status
Order Item Status ID
Item Notes
Item Return Reason
Item Return Status
Item Return Type
Item Supplier (shipping location)
Item Supplier ID
Item Supplier Name(mandatory)
Custom Data
Custom Data
Custom Data
Custom Data
Custom Data




If Order Inquiry has error
Order Inquiry response code
Order Inquiry response description