Create/Update a Location

Use this endpoint to create or update a location. If you use this endpoint your current secret key will be connected to the location. If you are linking documents to the location, make sure you have created the document and make sure you use the proper asset id.

Outcome

The result of the API is to create an asset identifying a location where products may be located that is enabled to execute API commands using the secret key provided. Do not use this endpont to create locations for vendors or customers.

Endpoint

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

Fields/Parameters

Fields/Parameter Value
auth_key Your api key "blockchain address:secret key" assigned one of the locations on your account. This will be included in the new asset record to identify the creator of the location record. Required
address The physical street address of the location. Required to be an actual searchable street address.
suite A suite number if the physical location has multiple suites or units. Optional
city The name of the city. Required
state The abbreviation of the state or provice. Required
zip The zip or postal code. Optional
gln The GS1 global identification location (GLN) if the location is using GLN. Optional
data Optional data related to the location that can be returned in a trace. Data must be formatted as a JSON object. Optional

Test it

Sample Code - PHP/Curl

<?php

$auth_key=$_POST['auth_key'];
$address=$_POST['address'];
$suite=$_POST['suite'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$gln=$_POST['gln'];
$data=$_POST['data'];
$documents=$_POST['documents'];

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

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