What you need to get started

A TrueToForm Pro plan account with API access. Contact [email protected] in order to get your unique Share Code, API key, and Access Token.

**Make sure to keep your Access Token secret and secure! Anyone with this token will be able to access your account data.

Integrate the measurement widget

For brands looking to collect measurements from their customers remotely, adding our measurement widget to your site is simple, and will take less than 5 minutes!

First, make sure you have created a TrueToForm account. You will need to provide us with the Share Code associated with your account and the domain of your website so that we can whitelist the use of the widget on your site. Email us at [email protected] with this information to obtain your unique API Key.

Next, copy this snippet of code and fill in your own API Key and Share Code. Make sure to keep the quotations around each value in the code. This will be the code that will load our widget into your website page.

<script>
window.addEventListener("message", (event) => {
	if (event.origin === "<https://widget.truetoform.fit>") {
		if (event.data.type === "HANDSHAKE_REQUEST") {
			event.source.postMessage({
				type: "HANDSHAKE",
	    	payload: {
	    	  apiKey: "<YOUR_API_KEY>",
	    	  clientId: "<YOUR_SHARE_CODE>",
		    },
		  }, event.origin);
    }
    
	  if (event.data.type === "GET_SCAN_DATA") {
		  // do your logic here
	    const scanData = event.data.payload
	  }
  }
});
</script>
<iframe src="<https://widget.truetoform.fit>" style="border: none; position: relative; width: 304px; height: 80px; margin: -15px 0;" name="TTF" id="TTF-widget"></iframe>

When a user interacts with the measurement widget and shares a scan with your site, you will receive a “GET_SCAN_DATA” event message. This event contains the following information:

type ScanData = {
  scanId: string; // unique identifier for the user's scan
  isProcessing: boolean; // if the scan data is still being processed to create an avatar/measurements
  name: string; // scanner name
  timestamp: number; // the timestamp when the user took the scan
};

You can see the avatar and its corresponding measurements on the TrueToForm web dashboard for any given scanId at: https://app.truetoform.fit/avatars/viewer/<scanId>

Fetch user avatar and measurements data

In order to get the measurements and avatar OBJ file from the user’s scan, use our REST API endpoint. Fill in your Access Token as a header in your request and provide the scanId for which you would like to fetch the avatar and measurements data.

curl -d '{"scanId": <scanId>}' -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" -X POST <https://api.truetoform.fit/v1/measure-scan-avatar>

Any avatar for which you programmatically fetch data will be automatically approved and added to the scan usage on your account. Any unique scanId will only be counted one time, so if you use the REST API to fetch the avatar data for the same scan 100 times, it will only be counted as 1 scan usage towards your TrueToForm plan.

Configure API response

Every client has different measurements of interest. By default, we will set you up with a configuration that returns all of the standard measurements that are currently available on the TrueToForm dashboard. If you would like to receive a different set of measurements or additional information that is not part of our standard configuration, just let us know. Our team can develop custom measurements, landmarks, and more, all according to your specification.

You can also optionally request that we return a downloadable avatar URL which allows you to get the 3D OBJ avatar file. By default, the expiration time for this URL is 5 minutes for security purposes, so download the file within that timeframe so that you can use it as desired.

List of REST API response codes