Read inventory, gift card and customer order data from VRP, post gift card transactions, and create inventory items, customer orders and purchase orders.
The REST API uses Basic Authentication. Send the user name and password with every request. The password is case-sensitive.
Test user
Password
Rights
vrp
vrp
Read only
Dim request = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
request.Credentials = New System.Net.NetworkCredential("USER", "PASSWORD")
The stored procedures run on the VRP database itself. Call them over a SQL Server connection with a login that has EXECUTE permission on them. Ask the VRP administrator for the server, database and login. Pass the JSON as an NVARCHAR(MAX) parameter, as in the samples, rather than building it into a SQL string.
Inventory
Get inventory
Returns inventory items: one row per item and store.
GEThttp://dev.visualretailplus.com/inventory
Results can be filtered by any of the fields returned, for example /inventory?upc=800111&StoreID=01.
Try
Dim request = CType(System.Net.WebRequest.Create("http://dev.visualretailplus.com/inventory?upc=800111"), System.Net.HttpWebRequest)
request.Credentials = New System.Net.NetworkCredential("USER", "PASSWORD")
request.Method = "GET"
Using rsp = CType(request.GetResponse(), System.Net.HttpWebResponse)
Using reader As New System.IO.StreamReader(rsp.GetResponseStream())
Dim json As String = reader.ReadToEnd()
Console.WriteLine(json)
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Creates inventory items from one JSON string: the product, its color / size items in each store, and the related vendor, group, color, size, unit-of-measure, weight and alias-UPC records. Field names are the same names Get inventory returns.
The call also returns one row per item and store. All of it is saved in one transaction: if anything is wrong, the call raises an error and nothing is saved.
using System.Data;
using Microsoft.Data.SqlClient;
string json = File.ReadAllText("items.json");
using var cn = new SqlConnection(connectionString);
cn.Open();
using var cmd = new SqlCommand("dbo.CreateInventoryFromJson", cn)
{
CommandType = CommandType.StoredProcedure,
CommandTimeout = 120
};
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json;
var created = cmd.Parameters.Add("@CreatedOut", SqlDbType.Int);
created.Direction = ParameterDirection.Output;
try
{
using (var rd = cmd.ExecuteReader())
{
while (rd.Read())
Console.WriteLine($"{rd["StoreID"]} {rd["UPC"]} {rd["ProductID"]} {rd["Color"]}/{rd["Size"]} {rd["Status"]}");
} // the output parameter is filled once the reader is closed
Console.WriteLine($"Created {created.Value} store rows");
}
catch (SqlException ex) when (ex.Number >= 50101 && ex.Number <= 50118)
{
// the JSON was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}");
}
Imports System.Data
Imports Microsoft.Data.SqlClient
Dim json As String = IO.File.ReadAllText("items.json")
Using cn As New SqlConnection(connectionString)
cn.Open()
Using cmd As New SqlCommand("dbo.CreateInventoryFromJson", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = 120
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json
Dim created = cmd.Parameters.Add("@CreatedOut", SqlDbType.Int)
created.Direction = ParameterDirection.Output
Try
Using rd = cmd.ExecuteReader()
While rd.Read()
Console.WriteLine($"{rd("StoreID")} {rd("UPC")} {rd("ProductID")} {rd("Color")}/{rd("Size")} {rd("Status")}")
End While
End Using ' the output parameter is filled once the reader is closed
Console.WriteLine($"Created {created.Value} store rows")
Catch ex As SqlException When ex.Number >= 50101 AndAlso ex.Number <= 50118
' the JSON was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}")
End Try
End Using
End Using
JSON shape
Each item is one product / color / size / WIL. Send it in any of these forms; they can be mixed in one call.
Cost · selling price · list price · wholesale price
decimal
0
AverageCost
Average cost
decimal
UnitCost
VSN · ParentItem · ivLocation
Vendor style number · parent item · shelf location
text 20
blank
IU1 · IU2 · IU3 · IU4
Item user-defined fields
text 100 · 40 · 1000 · 40
blank
Redlevel · MaxLevel · TagsToPrint
Reorder point · maximum stock · tags to print
integer
0
isInactive
Flag
0 / 1
0
Descriptions and related records
Field
What it sets
Type / max
VName · MinOrd
Vendor name · vendor minimum order
text 100 · decimal
MGDesc · SGDesc · SSGDesc
Group descriptions
text 50
ColorDesc · Swatch
Color description and swatch for this product
text 400 · 20
SizeDescription
Size description (for that size code in every product)
text
ItemUOM · ContainerUOM
Units of measure
text 20
UnitWeight
Weight in pounds
decimal
Assortments
Alias UPCs that scan as this item, separated by |
text 30 each
Ignored: OnHand, OnOrder, OnLayaway, OnCustOrder, OHExt, pu, LastXfrIn, CaseQty, SizeSeq, LastUpdate. New items start with zero quantities.
Send prices on every item. When an existing item is added to a new store, its prices and cost are not copied from the stores that already carry it; a missing SalePrice becomes 0.
UPC rules
An item (product + color + size + WIL) has exactly one UPC, the same in every store, and a UPC belongs to exactly one item.
You send
Result
A UPC that already belongs to a different product, color, size or WIL
50113
An existing item with a different UPC than the one it has
50114
The same item twice in one call with different UPCs
50109
The same UPC for two different items
50110
A UPC that is an alias UPC of another item
50115
No UPC, and the item already has more than one UPC
50118
No UPC, and the item already exists
uses its UPC
No UPC, and the item is new
new UPC from the UserCode range
Errors
Every rejection is a SQL error with one of these numbers; the message starts with CreateInventoryFromJson: and names the item (counting from 1 in the order sent) where it helps.
Number
Meaning
What to do
50101
Not valid JSON
Check the JSON syntax
50102 · 50103 · 50104
Wrong shape: an array element or Items element is not an object, or no items
Send objects { }
50105
No ProductID, a key that is too long, or a non-numeric UnitWeight / MinOrd
Fix the item named in the message
50106
A value does not fit its column, e.g. value "abc" does not fit rpiv.SalePrice (decimal(18,2))
Fix that field
50107 · 50108
A StoreID does not exist, or there is no active store
Send valid store codes
50109 · 50110 · 50111
Conflicts inside the JSON (see UPC rules); 50111: one item twice for the same store
Remove the conflict
50112
Another item creation was still running after 30 seconds
Retry
50113 · 50114 · 50115 · 50118
UPC conflicts with existing items (see UPC rules)
Send the right UPC, or leave it out
50116
No new UPC could be generated
Check the UserCode UPC range, or send UPCs
50117
An Assortments UPC is too long, is an item UPC, or belongs to another item
Try
Dim request = CType(System.Net.WebRequest.Create("http://dev.visualretailplus.com/giftcard/123"), System.Net.HttpWebRequest)
request.Credentials = New System.Net.NetworkCredential("USER", "PASSWORD")
request.Method = "GET"
Using rsp = CType(request.GetResponse(), System.Net.HttpWebResponse)
Using reader As New System.IO.StreamReader(rsp.GetResponseStream())
Console.WriteLine(reader.ReadToEnd())
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Adds an amount to a card (FILL) or takes an amount from it (Charge).
PUThttp://dev.visualretailplus.com/giftcard
Field
Type
Description
TransTyperequired
String
FILL adds the amount to the card; Charge takes it from the card
CardIDrequired
String
Card to add the transaction to
TransAmountrequired
Decimal
Amount of the transaction
ReceiptNo
Big integer
VRP receipt the transaction belongs to
StoreID
String
VRP store the transaction took place in
Try
Dim content As String = "{ ""TransType"":""Charge"",""CardID"":""123"",""TransAmount"":5,""ReceiptNo"":0,""StoreID"":""01"" }"
Dim request = CType(System.Net.WebRequest.Create("http://dev.visualretailplus.com/giftcard"), System.Net.HttpWebRequest)
request.Credentials = New System.Net.NetworkCredential("USER", "PASSWORD")
request.Method = "PUT"
request.ContentType = "application/json"
Dim body As Byte() = System.Text.Encoding.UTF8.GetBytes(content)
request.ContentLength = body.Length
Using stream = request.GetRequestStream()
stream.Write(body, 0, body.Length)
End Using
Using rsp = CType(request.GetResponse(), System.Net.HttpWebResponse)
Using reader As New System.IO.StreamReader(rsp.GetResponseStream())
Console.WriteLine(reader.ReadToEnd())
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Returns customer orders with their lines, payments and customer.
GEThttp://dev.visualretailplus.com/orders
Parameter
Type
Description
StoreIDrequired
String
VRP store code, 5 characters or less
ReceiptNo
Big integer
VRP receipt number
TRSDate
Date
Date of the transaction
TRSTime
Time
Time of the transaction
Try
Dim request = CType(System.Net.WebRequest.Create("http://dev.visualretailplus.com/orders?ReceiptNo=12"), System.Net.HttpWebRequest)
request.Credentials = New System.Net.NetworkCredential("USER", "PASSWORD")
request.Method = "GET"
Using rsp = CType(request.GetResponse(), System.Net.HttpWebResponse)
Using reader As New System.IO.StreamReader(rsp.GetResponseStream())
Console.WriteLine(reader.ReadToEnd())
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Creates a customer order, together with its customer and shipping address, from one JSON string. The same procedure also creates sales and layaways; the type is set by rpTransaction.
The call also returns one row (StoreID, ReceiptNo, CustomerID). Field names in the JSON are the VRP column names and are not case-sensitive. All of it is saved in one transaction: if anything is wrong, nothing is saved.
using System.Data;
using Microsoft.Data.SqlClient;
string json = File.ReadAllText("order.json");
using var cn = new SqlConnection(connectionString);
cn.Open();
using var cmd = new SqlCommand("dbo.CreateReceiptFromJson", cn) { CommandType = CommandType.StoredProcedure };
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json;
var receiptNo = cmd.Parameters.Add("@ReceiptNoOut", SqlDbType.BigInt);
receiptNo.Direction = ParameterDirection.Output;
var customerID = cmd.Parameters.Add("@CustomerIDOut", SqlDbType.VarChar, 20);
customerID.Direction = ParameterDirection.Output;
try
{
cmd.ExecuteNonQuery();
Console.WriteLine($"Order {receiptNo.Value} for customer {customerID.Value}");
}
catch (SqlException ex) when (ex.Number >= 50001 && ex.Number <= 50012)
{
// the order was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}");
}
Imports System.Data
Imports Microsoft.Data.SqlClient
Dim json As String = IO.File.ReadAllText("order.json")
Using cn As New SqlConnection(connectionString)
cn.Open()
Using cmd As New SqlCommand("dbo.CreateReceiptFromJson", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json
Dim receiptNo = cmd.Parameters.Add("@ReceiptNoOut", SqlDbType.BigInt)
receiptNo.Direction = ParameterDirection.Output
Dim customerID = cmd.Parameters.Add("@CustomerIDOut", SqlDbType.VarChar, 20)
customerID.Direction = ParameterDirection.Output
Try
cmd.ExecuteNonQuery()
Console.WriteLine($"Order {receiptNo.Value} for customer {customerID.Value}")
Catch ex As SqlException When ex.Number >= 50001 AndAlso ex.Number <= 50012
' the order was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}")
End Try
End Using
End Using
The order's tax (6.04) was built from the two lines' LineTax, a new customer was created because no customer had that email or phone, and the shipping address was linked to the receipt.
Order header
Field
Type
Description
StoreIDrequired
String
VRP store code, 5 characters or less
TRSDaterequired
Date / time
Date of the order, ISO format. Its time part is used when TrsTime is not sent.
rpTransaction
String
CO customer order · LA layaway · missing: S sale. CO and LA need a customer.
ReceiptNo
Big integer
Missing: the next VRP receipt number. A number that already exists for the store is an error.
Cashregister · Cashier
String
Register and cashier codes, 5 characters or less
CustomerID
String
An existing VRP customer. Not needed when RPCust is sent.
TaxAmt
Decimal
Missing: the total of the line taxes
TRSNote
String
Note on the order, for example the web order number
Lines · RPTrsd array
At least one line or one payment is required.
Field
Type
Description
UPCrequired
String
Item UPC. An alias UPC is changed to its item UPC.
Quantity
Decimal
Missing: 1
Amount
Decimal
Unit price
Discount
Decimal
Line discount
LineTax
Decimal
Tax of the line
TaxRule
Integer
VRP tax rule of the line
Cost
Decimal
Missing: the item's average cost
Lineitem
Integer
Missing: the position in the array
Payments · rpPay array
Field
Type
Description
PayTyperequired
String
VRP tender code, as set up in the store's tenders. Ask the VRP administrator for the codes.
Amount
Decimal
Amount paid
PaymentNumber
Integer
Missing: the position in the array
Rate
Decimal
Currency rate. Missing: 1
Tax details · TaxCollectedDetails array
Optional: lineitem, taxCollected, Authority, SoldAmount. When it is not sent, it is built from the lines' LineTax, or from the header TaxAmt when no line has tax.
Customer · RPCust object
Any column of the VRP customer table can be sent (FirstName, LastName, EmailAddress, PhoneNumber, Address1, City, StateOrProvince, PostalCode, ...).
With CustomerID: that customer is used. If it exists, only the fields sent are updated; otherwise it is created.
Without CustomerID: an existing customer with the same EmailAddress, else the same phone number, is used. Otherwise a new customer is created and returned in @CustomerIDOut.
Shipping · ShippingAddresses and ShippingReceipt objects
ShippingAddresses takes FirstName, LastName, Address1, Address2, City, State, Zip, Country, Phone1. An identical address of the customer is reused; otherwise it is added. ShippingReceipt (ShippingServiceCode, Weight) links the order to the address. Shipping needs a customer.
Errors
Number
Meaning
50001
Not valid JSON
50002 · 50003
StoreID or TRSDate is missing
50004 · 50005
A line has no UPC, or a payment has no PayType
50006
No lines and no payments
50007 · 50008
No receipt number could be generated, or the receipt number already exists for the store
50009
RPCust, ShippingAddresses or ShippingReceipt is not a JSON object
50010 · 50011
Shipping without a customer, or ShippingReceipt alone without the Seq of an existing address
50012
A CO or LA order has no customer
Purchase orders
Create a purchase order
Creates a purchase order for one vendor, with its lines for one or more stores, from one JSON string. The items' on order quantities are updated as soon as the PO is saved.
EXECdbo.CreatePOFromJson @Json, @PONOOut OUTPUT
Parameter
Type
Description
@Jsonrequired
NVARCHAR(MAX)
The purchase order as JSON
@PONOOut
VARCHAR(20) OUTPUT
Number of the new PO
The call also returns one row (PONO, VendorID, Lines, QtyOrdered, TotalCost). Field names in the JSON are the VRP column names and are not case-sensitive. All of it is saved in one transaction: if anything is wrong, nothing is saved.
using System.Data;
using Microsoft.Data.SqlClient;
string json = File.ReadAllText("po.json");
using var cn = new SqlConnection(connectionString);
cn.Open();
using var cmd = new SqlCommand("dbo.CreatePOFromJson", cn) { CommandType = CommandType.StoredProcedure };
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json;
var pono = cmd.Parameters.Add("@PONOOut", SqlDbType.VarChar, 20);
pono.Direction = ParameterDirection.Output;
try
{
cmd.ExecuteNonQuery();
Console.WriteLine($"PO {pono.Value} created");
}
catch (SqlException ex) when (ex.Number >= 50201 && ex.Number <= 50212)
{
// the PO was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}");
}
Imports System.Data
Imports Microsoft.Data.SqlClient
Dim json As String = IO.File.ReadAllText("po.json")
Using cn As New SqlConnection(connectionString)
cn.Open()
Using cmd As New SqlCommand("dbo.CreatePOFromJson", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@Json", SqlDbType.NVarChar, -1).Value = json
Dim pono = cmd.Parameters.Add("@PONOOut", SqlDbType.VarChar, 20)
pono.Direction = ParameterDirection.Output
Try
cmd.ExecuteNonQuery()
Console.WriteLine($"PO {pono.Value} created")
Catch ex As SqlException When ex.Number >= 50201 AndAlso ex.Number <= 50212
' the PO was rejected; nothing was saved
Console.WriteLine($"Rejected ({ex.Number}): {ex.Message}")
End Try
End Using
End Using
No PONO was sent, so the next PO number was taken. The second line had no cost and got the store's current unit cost (8.00); the third line is for store 02.
PO header
Field
Type / max
If not sent
VendorIDrequired
text 20
Error 50202. Must be an existing VRP vendor.
PONO
text 20
The next PO number, by the shop's PO numbering. A number that already exists is an error.
StoreID
text 5
Store for the lines that do not send their own
PODate
date
Today
StartShipDate
date
PODate
CancelDate
date
StartShipDate + 90 days
VendorPONO · Note
text
blank
TermsNetDays · TermsNetPCT
integer · decimal
The vendor's terms
Freight
decimal
0
BillTo
text 5
The header StoreID, else the first line's store
UserCode
text 5
API. Also picks the PO number range when the shop numbers POs per user.
OTBPeriod
text 15
blank
isOpen · ChangeIVCostUponRcv
0 / 1
1 · 0
Lines · PODetail2 array
At least one line is required. A UPC may appear only once per store; send its total quantity.
Field
Type / max
If not sent
UPCrequired
text 20
Error 50205. An alias UPC is changed to its item UPC; the item must exist in the line's store.
StoreID
text 5
The header StoreID; one of the two is required
QtyOrdered
decimal
1
UnitCost · MSRP · SalePrice
decimal
The item's current values in that store
CustomerID
text 20
blank. The customer the line is ordered for.
Seq
integer
The position in the array
Errors
Number
Meaning
50201
Not valid JSON, or not a single JSON object { }
50202 · 50203
VendorID is missing, or is not a VRP vendor
50204
No lines in PODetail2
50205
A line has no UPC or store, or a line value does not fit (the message names the line, counting from 1)
50206
A header value does not fit, e.g. value "2026-13-45" does not fit RPPO2.PODate (datetime)
50207
A UPC is not in the inventory of the line's store
50208
The same UPC is on more than one line for the same store
50209
The PONO sent already exists
50210 · 50211
No PO number could be generated (the shop does not number POs automatically, or the range is full); send PONO
50212
Another PO creation was still running after 30 seconds; retry