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

Vendors

Use the Lead Commerce Vendor API to view, create, and update vendors.

Views

Display information about your Vendors including ID, Name, Status, Addresses, and any Warehouses that have been associated to each Vendor.

Example:

<?php  
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/Vendors.xml');  
curl_exec($curl);  
curl_close($curl);  
?>

Example Output:

<message client="192.168.100.208" time="1395334414">
    <response>
        <code>200</code>
        <data>
            <item>
                <id>1072</id>
                <name>Insulation Company</name>
                <auto_approve>N</auto_approve>
                <drop_ship>N</drop_ship>
                <send_email>N</send_email>
                <vendor_term>Net 15</vendor_term>
                <created>7/10/2013 12:52PM</created>
                <last_updated>10/22/2013 12:11PM</last_updated>
                <status>Active</status>
                <addresses>
                    <address>
                        <id>1072</id>
                        <full_name>Tom Jones</full_name>
                        <email>[email protected]</email>
                        <address_1>5000 Business Parkway</address_1>
                        <address_2/>
                        <city>Los Angeles</city>
                        <subregion>3684</subregion>
                        <postal_code>90210</postal_code>
                        <region>840</region>
                        <phone>310-555-1234</phone>
                        <fax>310-555-8765</fax>
                        <default>Y</default>
                        <status>Active</status>
                    </address>
                </addresses>
                <warehouses>
                    <warehouse>
                        <id>1</id>
                        <name>My Warehouse</name>
                        <status>Active</status>
                    </warehouse>
                </warehouses>
            </item>
        </data>
    </response>
</message>

Create

Create allows you to create Vendors as if you went through the Lead Commerce Back Office and includes automatic ID creation. Refer to the Data Points table below to learn which data points can be passed when creating Vendors.

This sample Create Vendor code shows how you would insert a Vendor called 'Lead Commerce' into the database and set it to 'Active' Status.

Example:

$insert = array('name'         => 'Lead Commerce',
                'status'       => 'active',
                'terms'        => 5,
                'send_email'   => 0,
                'addresses'    => array(array('full_name'    => 'Lead Commerce - San Diego',
                                              'email'        => '[email protected]',
                                              'address_1'    => '5000 Business Parkway',
                                              'city'         => 'San Diego',
                                              'region'       => 'United States',
                                              'subregion'    => 'CA',
                                              'phone'        => '619-555-1212',
                                              'postal_code'  => '92103',
                                              'default'      => 'yes'),
                                        array('full_name'    => 'Lead Commerce - Los Angeles',
                                              'email'        => '[email protected]',
                                              'address_1'    => '5000 Business Ave',
                                              'city'         => 'Los Angeles',
                                              'phone'        => '310-555-1958',
                                              'region'       => 'United States',
                                              'subregion'    => 'California',
                                              'postal_code'  => '08759')),
                'warehouses' => array(1)));
$fields = array('identifier' => "LC350000000",
                'key'        => "dynKSr4I7y2K3RrPRsFYFJr03IXUbv",
                'inserts'    => array($insert));
$curl = curl_init();
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/Vendors/create.xml');
curl_exec($curl);
curl_close($curl);

Data Points

Key Data Type Required Example Notes
name string Yes Lead Commerce
terms int Yes 5
send_email boolean No 1 Automatically send Vendor email when PO placed
status string No Active Active by default
addresses array No Array containing an additional array of each address. See below for data points

Address Data Points

Key Data Type Required Example Notes
full_name string Yes Tom Smith Customer full name for shipping
status int/string No 1 ( or 'Active') Set address status, default to active if not set
address_1 string Yes 5000 Parkway Ave. Customer street address
address_2 string No #423 Unit/Apartment Number
city string Yes Los Angeles
subregion string Yes CA Customer state (abbr)
postal_code string Yes 90210
region string Yes United States Customer country
phone string No 310-555-9876
default_billing int No 1 Set address as default billing address
default_shiping int No 1 Set address as default shipping address

Update

Update allows you to update Vendors as if you went through the Lead Commerce Back Office. When updating a Vendor, you are NOT required to pass all fields; passing a blank or empty field will update the field value as blank.

Running the sample Update code below for Vendor ID 44 would change its Name to 'XYZ Company, Inc.' and set its Status to 'Inactive.'

Example:

<?php  
$update = array('id'     => '44',  
                'name'   => 'XYZ Company, Inc.',  
                'status' => 'inactive');
$fields = array('identifier' => "LC350000000",
                'key'        => "dynKSr4I7y2K3RrPRsFYFJr03IXUbv",
                'inserts'    => array($update));
$curl = curl_init();
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/Vendors/update.xml');
curl_exec($curl);
curl_close($curl);
?>

Refer to the Data Points table above to update your Vendors. The only difference is described below:

Key Data Type Required Example Notes
id int Yes 44 ID of the Vendor

Start your free, no-risk trial today.