API Quick Start Guide

Introduction

This article will assist you with using the Turvo Public API by enabling you to authenticate your user. After you complete all the steps in this article, you can hit your required API endpoint in less than ten minutes. In this article, you will go through the steps to make a call to the Get a Shipment API. To accomplish the objective of this article, you must download the Postman QSG Collections Sample attached at the end of this article. 

You can also refer to the API Getting Started Guide for detailed hands on exercise on the Turvo APIs. 

Before you begin

The Get a Shipment API is a GET call, and it fetches all shipment details. To fetch shipment details, you will need a shipment ID. Your shipment ID is an integer.  
Shipment IDs are displayed when you view shipments in Turvo. Using the left navigation menu, go to Shipments page. Shipment IDs are listed in their own column when viewing the page in List view, or at the top of each card when viewing the Shipments page in Card view. 
Screenshot_2023-05-25_at_2.02.26_PM.png
Note: Your shipment ID is Q20097. Remove the letter Q from the shipment ID and send your request using 20097 as an ID. Before you make a call to this endpoint, you will need to obtain an authentication token.
You have your shipment id and can now obtain your access token. Obtain your access token by following the instructions below:

Getting an Authentication Token

The Turvo Public API supports the authentication of your application API requests using the OAuth 2.0 (bearer token) authentication method. Your authentication token is the access_token you receive in your authentication response.

Making API requests

Authentication

You authenticate all Turvo API calls using your bearer token. The token is set at the authorization header. All parameters must be URL-encoded.

  • Get your bearer token from https://my-sandbox-publicapi.turvo.com/v1/oauth/token
  • To complete the authentication, replace the client_id with the authentication client id, and the client_secret with the OAuth client secret. 

This is what the request sample looks like when you are authenticating: 

{
  "grant_type": "password",
"client_id: "publicapi",   "client_secret": "secret",   "username": "john@turvo.com",   "password": "password",   "scope": "read+trust+write",   "type": "business" }

Refer to the authentication instructions on Turvo's API documentation site for more detailed authentication information.

Sandbox environment

The Turvo authentication API is available in the following sandbox environment:

https://my-sandbox-publicapi.turvo.com/v1/shipments/{shipmentId}

You can use the sandbox environment until you are ready to use the production environment. However, note that the shipmentId is already defined in the previous section in this article. 

Using Postman

There are several ways you can use Turvo APIs. You can write code in your preferred language, like PHP or Java, or you can send a cURL command from a CLI (or just use Postman).

In this example, we will show you how to make the API call using Postman. 

To make your first shipment API request, go to the API and use your access_token to make a call to the shipment API. In this case, we will call the Get a Shipment endpoint using ID.

Once you make the API call, you will see success 200 OK response. 

Using cURL

An equivalent curl command, for the same request as above, would look like this on your terminal:

curl --location 'https://my-sandbox-publicapi.turvo.com/v1/shipments/438540' \
--header 'sec-ch-ua: "Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"' \
--header 'X-TU-Window-ID: 6934acf9-9664-4f22-b470-3d6f4414c801' \
--header 'Nonce: 4b2a2fd5-a69d-48d5-bfbd-3902dfe0da24' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'Authorization: Bearer 2b_-2c8d59e6-8c4f-494a-b573-2c9412194546' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Referer: https://my-sandbox.turvo.com/' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'x-api-key: 6PxdP0FzJ69UWIpsBD9SjkCEQyoCqhR2rrNpAGWa' \
--header 'Cookie: dtCookie=v_4_srv_6_sn_BD6B385C6D469BF271631B1CB4B28E17_perc_100000_ol_0_mul_1_app-3A9812989f44f07d40_1_rcs-3Acss_0'

Your shipment_id is an integer and AUTH is your access_token you obtain from your authentication API response. 

Once you send the cURL request, you will see success 200 OK response. 

Congratulations! You have successfully made a simple API call to a Turvo API endpoint. 

Next Steps

Now that you’ve successfully made a call to an endpoint, you can now explore other ways to use and test our API for more workflows based on your requirement.

If you want to... See...
Review the first steps to use Turvo APIs and understand some best practices Using Turvo APIs: Initial setup steps and best practices
Refer to the API Getting Started guide for detailed hands on exercise API Getting Started Guide
Review the Turvo Public API endpoints  API Reference
Learn about the latest feature updates  Release Notes
Learn more about Turvo TMS feature and functionality Turvo Help Center

 

Was this article helpful?

1 out of 2 found this helpful