Rate

Allows you to get estimated break-down costs excluding GST of moving freight from one place to another. Required fields are in bold text.

Access

To get access to this API, please fill in the Developer Registration form

Resource URI

Make an HTTP POST request to:

https://api.mainfreight.com/transport/1.0/customer/rate?region={region}

Resource Information

TypeValue 
Authentication API Key  
Response Formats JSON / XML  
HTTP Methods POST  
API Version 1.0  

HTTP Headers

You must add the following HTTP Headers to your request:

HeaderDescriptionTypeRequired
Content-Type Request content type. Supported types are "application/json" or "application/xml" string Yes
Authorization

The word " Secret" followed by a space, then your unique Rate API Key

e.g: Secret wdnOId93-VXZECxvVRPQEJZNxPB5XZ...

string Yes
Accept

Result content type. Supported types are "application/json" or "application/xml"

string No

Parameters

You have to provide the parameters marked as required:

HTTP Request Parameters

HeaderDescriptionTypeRequired
region

Region code, a list of available regions can be found here

string Yes

Request Body

FieldDescriptionTypeLengthRequired
account

Account provided to your organization

object    
code Your account number string 50 Yes
serviceLevel Defines the service your freight is carried on object    
code Service level code, a list of available of types can be found here string 50 Yes
origin   object    
freightRequiredDateTime

Required date and time your freight need to be picked up or provided to Mainfreight by. Format is yyyy-MM-ddTHH:mm:ss

datetime   Yes 
freightRequiredDateTimeZone

Timezone of required date and time, a list of avaible timezones can be found here

string 50  
address The address details for the origin of the shipment object   Yes 
suburb The suburb for the origin of the shipment string 50 Required for New Zealand
postCode The post code for the origin of the shipment string 50  Required for Australia
town The town for the origin of the shipment string 50 Required for Australia
city The city for the origin of the shipment string 50 Required for New Zealand
stateCode The state code for the origin of the shipment, list of avaiable states can be found here string 50 Required for Australia
countryCode The country code for the origin of the shipment in ISO Alpha-2 code string 50 Yes 
destination   object    
address The address details for the destination of the shipment object   Yes 
suburb The suburb for the destinationof the shipment string 50 Required for New Zealand
postCode The post code for the destinationof the shipment string 50  Required for Australia
town The town for the destination of the shipment string 50  Required for Australia
city The city for the destinationof the shipment string 50 Required for New Zealand
stateCode The state code for the destination of the shipment, list of avaiable states can be found here string 50  Required for Australia
countryCode The country code for the destination of the shipment string 50  Yes 
freightDetails   object    
units

Number of units

integer   Yes
packTypeCode

Package Type, a list of available package type codes can be found here

string 10  Yes 
height Height of the freight, in metres (m). decimal   Yes, If volume is not provided 
length Length of the freight, in metres (m). decimal    Yes, If volume is not provided 
width Width of the freight, in metres (m). decimal    Yes, If volume is not provided 
weight Weight of the freight, in kilograms (kg). integer    Yes
volume Volume of the freight, in cubic metres (m3). decimal   Yes, If Length, Width and Height are not provided 

Response Body

FieldDescriptionTypeLength 
rate   object    
charges List of charges included in the rate array    
name Name of charge component, avaiable charge components: FreightAmount, FuelAmount, FuelPercentage, OtherFeeAmount, TotalExcludingGSTAmount. string 50  
value Charge component value  decimal    

Code samples

JSON Example

To Generate an Transport Rate in JSON format you will need to POST a JSON object:

  • URL
< > grab code
https://api.mainfreight.com/transport/1.0/customer/rate?region=NZ

You are going to send a JSON object similar to this:

  • REQUEST JSON
< > grab code
{
	"account": {
		"code": "{YOUR_ACCOUNT_CODE}"
	},
	"serviceLevel": {
		"code": "LCL"
	},
	"origin": {
		"freightRequiredDateTime": "2018-07-04T17:33:10",
		"freightRequiredDateTimeZone": "New Zealand Standard Time",
		"address": {
			"suburb": "Grey Lynn",
			"postCode": "1011",
			"city": "Auckland",
			"countryCode": "NZ"
		}
	},
	"destination": {
		"address": {
			"suburb": "Mount Cook",
			"postCode": "6011",
			"city": "Wellington",
			"countryCode": "NZ"
		}
	},
	"freightDetails": [{
		"units": "1",
		"packTypeCode": "PLT",
		"height": "1.23",
		"length": "1.45",
		"width": "1.6",
		"weight": "120",
		"volume": "2.86"
	},
	{
		"units": "2",
		"packTypeCode": "Bag",
		"height": "2.23",
		"length": "1.45",
		"width": "1.6",
		"weight": "60",
		"volume": "10.35"
	}]
}

You are going get another JSON object similar to this:

  • RESPONSE JSON
< > grab code
{
	"charges": [{
		"name": "FreightAmount",
		"value": 1509.51
	},
	{
		"name": "FuelAmount",
		"value": 199.1
	},
	{
		"name": "FuelPercentage",
		"value": 13.19
	},
	{
		"name": "OtherFeeAmount",
		"value": 0
	},
	{
		"name": "TotalExcludingGSTAmount",
		"value": 1708.61
	}]
}
XML Example

To Generate an Transport Rate in XML format, you will need to POST XML object.

  • URL
< > grab code
https://api.mainfreight.com/transport/1.0/customer/rate?region=NZ

You are going to send XML document similar to this:

  • XML REQUEST
< > grab code
<rate>
	<account>
		<code>{YOUR_ACCOUNT_CODE}</code>
	</account>
	<serviceLevel>
		<code>LCL</code>
	</serviceLevel>
	<origin>
		<freightRequiredDateTime>2018-07-04T17:33:10</freightRequiredDateTime>
		<freightRequiredDateTimeZone>New Zealand Standard Time</freightRequiredDateTimeZone>
		<address>
			<suburb>Grey Lynn</suburb>
			<postCode>1011</postCode>
			<town/>
			<city>Auckland</city>
			<stateCode/>
			<countryCode>NZ</countryCode>
		</address>
	</origin>
	<destination>
		<address>
			<suburb>Mount Cook</suburb>
			<postCode>6011</postCode>
			<town/>
			<city>Wellington</city>
			<stateCode/>
			<countryCode>NZ</countryCode>
		</address>
	</destination>
	<freightDetails>
		<freightDetail>
			<units>1</units>
			<packTypeCode>PLT</packTypeCode>
			<height>1.23</height>
			<length>1.45</length>
			<width>1.6</width>
			<weight>120</weight>
			<volume>2.86</volume>
		</freightDetail>
		<freightDetail>
			<units>2</units>
			<packTypeCode>Bag</packTypeCode>
			<height>2.23</height>
			<length>1.45</length>
			<width>1.6</width>
			<weight>60</weight>
			<volume>10.35</volume>
		</freightDetail>
	</freightDetails>
</rate>

You are going to get a XML document similar to this:

  • XML RESPONSE
< > grab code
<rate>
	<charges>
		<charge>
			<name>FreightAmount</name>
			<value>1509.51</value>
		</charge>
		<charge>
			<name>FuelAmount</name>
			<value>199.10</value>
		</charge>
		<charge>
			<name>FuelPercentage</name>
			<value>13.19</value>
		</charge>
		<charge>
			<name>OtherFeeAmount</name>
			<value>0.00</value>
		</charge>
		<charge>
			<name>TotalExcludingGSTAmount</name>
			<value>1708.61</value>
		</charge>
	</charges>
</rate>
NOTE: Content in the panels below this point are not visible on the site unless used by other features e.g. gadgets, OB&E, etc.