Create or Update an Asset Class

Use this endpoint to create or update an asset class. An asset class represents the product at the highest level. The asset class is derived from the products unique identifier, the Global Trace Identification Number. Asset classes are automatically created the first time an item is created or received.

This endpoint can be run repeatedly to update data and documents related to the item.

Outcome

The result of the API is to create an asset representing the asset class or update an existing asset class.

Endpoint

https://tracapi.com/api.v2/class/

Fields/Parameters

Fields/Parameter Value
auth_key Your api key "blockchain address:secret key" assigned for the location receiving the product Required
gtin The globally unique item number of the product. Usually GTIN or UPC code. Required
data (JSON Object) Optional data related to the item, purchase order, shipment that will be returned in a trace if included. Data must be formatted as a JSON object. Optional
documents (JSON Array) Optional list of documents linked to the Asset Class. Optional

Test it

Sample Code - PHP/Curl

<?php

$auth_key=$_POST['auth_key'];
$gtin=$_POST['gtin'];
$data=$_POST['data'];
$documents=$_POST['documents'];

//URL of the endpoint.
$url = 'https://tracapi.com/api.v2/class/';

//Create an array of POST data to be sent to the endpoint.
$fields = array(
'auth_key' => $auth_key,
'gtin' => $gtin,
'data' => $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);
?>