API V1 is no longer in active development. If you are starting a new integration, it is recommended you use API V2

Purchase Order

The Lead Commerce Purchase Order API allows you to view, create, and receiving.

Views

Views allow you to display data about your purchase order including line items and terms, notes and more. Available output are in xml and json

Example:

header("Content-type: text/xml;");  
$credentials = array('identifier' =>  'LC350000000', 'key'=> 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv'); 
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/PurchaseOrders.xml');
curl_exec($curl);  
curl_close($curl);

With purchase orders, you can filter the result set also by the status, vendor, placed time, ID and more.

header("Content-type: text/xml;");  
$credentials = array('identifier' => 'LC350000000', 'key'        => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv',
	'vendor'   => 10,
	'status' =>1,
	'warehouse'=>3,
	'placed'=>1406239561);  
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/PurchaseOrders.xml');
curl_exec($curl);  
curl_close($curl);

Example Output:

<?xml version="1.0" encoding="UTF-8"?>
<message client="172.4.33.114" time="1406242359">
   <response>
      <code>200</code>
      <data>
         <item>
            <id>1028</id>
            <vendor_contact>1</vendor_contact>
            <warehouse>3</warehouse>
            <notes>Some useful notes</notes>
            <status>Pending</status>
            <term>1</term>
            <fob>See Joe for confirmation slip</fob>
            <vendor>10</vendor>
            <vendor_name>My Vendor</vendor_name>
            <full_name>Joe Smoe</full_name>
            <address_1>1200 Somewhere Avenue</address_1>
            <city>Somewhere</city>
            <region>United States</region>
            <subregion>California</subregion>
            <postal_code>10000</postal_code>
            <products>
               <product>
		  <line_item>1</line_item>
                  <inventory_sku>1000-0010</inventory_sku>
                  <qty>1</qty>
                  <cost>16.80</cost>
                  <discount_type>0</discount_type>
                  <discount_number>0.00</discount_number>
                  <total>16.80</total>
                  <received>0</received>
                  <status>Pending</status>
               </product>
               <product>
		  <line_item>2</line_item>
                  <inventory_sku>1000-0001</inventory_sku>
                  <qty>12</qty>
                  <cost>188.80</cost>
                  <discount_type>0</discount_type>
                  <discount_number>0.00</discount_number>
                  <total>2,265.60</total>
                  <received>0</received>
                  <status>Pending</status>
               </product>
            </products>
         </item>
      </data>
   </response>
</message>

The following filters are allowed on the view. These are not required and can be used in any combination.

Filter Points

Key Data Type Example Notes

vendor

int

1

The ID of the vendor

status

int

1

This number represents the status value. The values goes as follows:
  • 1  Pending
  • 2  Partially Received
  • 3  Received
  • 4  Draft
  • 5  Canceled
  • 6  Over Received

warehouse

int

3

The ID of the warehouse that the Purchase Order is fulfilling.

placed

int

1406239561

UNIX timestamp of when the Purchase Order was placed.

Create

Create allows you to create Purchase Orders as if you went through the Lead Commerce Back Office. Refer to the Data Points table below to learn which data points can be passed when creating Purchase Orders.

Data Points

Key Data Type Required Example Notes

vendor

int

Yes

10

The ID of the vendor

vendor_contact

int

Yes

1

The ID of the vendor contact. This must be tied to the vendor.

warehouse

int

Yes

1

The ID of the warehouse that the Purchase Order is fulfilling.

fob

string

No


Freight On Board

terms

int

No

2

The ID of the terms and conditions.

po_term

string/int

No

Net 15

This value must currently exist. You can use either the ID or the string for the value.

  • 1  COD
  • 2  Check
  • 3  Credit Card
  • 4  CIA
  • 5  NET 15
  • 6  NET 30
  • 7  NET 45
  • 8  NET 60
  • 9  NET 90

date_issued

int

No

1405089472

UNIX Timestamp

due_date

int

No

1406012457

UNIX Timestamp

notes

string

No

These are some notes


placed

int/string

No

Can be a UNIX timestamp (871708681) or string "8/15/1997". If not passed, it will use the current time.
draft boolean No true/false If passed as true, the Purchase Order will not be placed and will be put in draft status, else it will be placed.
Products

All product data is a subvalue under the array value "products"

Key Data Type Required Example Notes
sku string Yes 1154-8211

qty int Yes 6
cost decimal Yes 16.58

Example:

header("Content-type: text/xml;");  
$insert = array('vendor'         =--> 10,
    'vendor_contact'       => 1,
    'warehouse'       => 1,
    'attributes' =>array('attr_legacy_order_date' => '07/09/2014'),
    'fob'         => 'fob data',
    'terms' => 1,
    'po_term' => 'Net 15',
    'attributes' => array(
         'attr_test_data_points' => 2
         ),
    'date_issued' => 1405089472,
    'due_date' => 1406012457,
     'notes'         => 'yes, these are my notes',
    'products'    => array(array('sku'    => '1000-0010',
                      'qty'        => '1',
                      'cost'       => '16.80'),
                       array('sku'    => '1000-0001',
                      'qty'        => '12',
                      'cost'       => '$188.80')
                )
    );
$credentials = array('identifier' => 'LC350000000', 'key'        => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv', 'inserts'    => array($insert)); 
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v/PurchaseOrders/create.xml');
curl_exec($curl);  
curl_close($curl);

Receiving

Receiving allows you to receive Purchase Order items as if you went through the Lead Commerce Back Office to receive items. Refer to the Data Points table below to learn which data points can be passed when receiving Purchase Orders. 

If you want to create multiple receivements for a Purchase Order. You can call the same ID of the Purchase Order. Each call to a Purchase Order will create 1 receivement.

Data Points

Key Data Type Required Example Notes

id

int

Yes

S3

The ID of the Purchase Order. This Purchase Order id can be in any status except for draft and cancelled.

condition

int

No

Net 15

You must use an integer for these types. By default, all products are New

  • 1 New
  • 2 Like New
  • 3 Used
  • 4 Used-Like New
  • 5 Used-Very Good
  • 6 Used-Good
  • 7 Used-Acceptable
  • 8 Expired
  • 9 Refurbished
  • 10 Collectable
  • 11 Vintage

dom

int

No

1405089472

UNIX Timestamp. DOM stands for "Date of Manufacture"

expiration

int

No

1406012457

UNIX Timestamp

notes

string

No

These are some notes


Products

All product data is a subvalue under the array value "products". In order to receive an item, you must pass either the line item number or the SKU. If you have the same SKU multiple times, it is recommended you pass the item number else, the system will pick the first matching SKU.

Key Data Type Required Example Notes
sku string Conditional 1154-8211
Required if item number is not passed
qty int Yes 6
line_item int Conditional 3 Item Number with the Purchase Order

Example:

header("Content-type: text/xml;");  
$insert = array('id' => 'S3',
    'dom' => 1405089472,
    'expiration' => 1406012457,
    'notes'      => 'Some notes about this receiving batch',
    'products'   => array(array('sku'    => '1000-0010',
                      'qty'        => '1'),
                 array('line_item'    =3,
                      'qty'        => '12'),
                 array('line_item'    =7,
                      'qty'        => '35')
                )
    );
$credentials = array('identifier' => 'LC350000000', 'key'        => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv', 'inserts'    => array($insert)); 
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v/PurchaseOrders/receiving.xml');
curl_exec($curl);  
curl_close($curl);

Start your free, no-risk trial today.