Package or Repackage a Product
Use this endpoint to process a product to create a new product from inputs or ingredients. This API endpoint has the same basic functionality as the /process endpoint. The endpoint does not transfer the location of the resulting product.
Endpoint
https://traceapi.com/api.v2/package/
Fields/Parameters
Fields/Parameter | Value | |
---|---|---|
api_key | Your api key "blockchain address:secret key" assigned for the location receiving the product | Required |
package_gtin | The globally unique item number of the packaged product that is created. Usually either a GTIN or UPC depending on the packaging of the product. | Required |
package_lot | Lot number, batch number, or serial number of the product created by the process. | Required |
package_data (JSON Object) | Optional data related to the item being created that will be returned in a trace if included. Data must be formatted as a JSON object. | Optional |
product_gtin | The globally unique item number of the product that is packaged. Usually an internal GTIN to handle a bulk product created. | Required |
product_lot | Lot number, batch number, or serial number of the product packaged. | Required |
product_data (JSON Object) | Optional data related to the item being packaged. Data must be formatted as a JSON object. | Optional |
documents (JSON Array) | Documents linked to the packaged product. | Optional |
Test it
Sample Code - PHP/Curl
<?php
$auth_key=$_POST['auth_key'];
$product_gtin=$_POST['product_gtin'];
$product_lot=$_POST['product_lot'];
$product_data=$_POST['product_data'];
$package_gtin=$_POST['package_gtin'];
$package_lot=$_POST['package_lot'];
$package_data=$_POST['package_data'];
$documents=$_POST['documents'];
//URL of the endpoint.
$url = 'https://tracapi.com/api.v2/package/';
//Create an array of POST data to be sent to the endpoint.
$fields = array(
'auth_key' => $auth_key,
'product_gtin' => $product_gtin,
'product_lot' => $product_lot,
'product_data' => $product_data,
'package_gtin' => $package_gtin,
'package_lot' => $package_lot,
'package_data' => $package_data,
'documents' => $documents);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//execute post
$result = curl_exec($ch);
//echo the result
echo $result;
//close connection
curl_close($ch);
?>