POST api/v1/shipments/{shipmentId}/cost-lines

Shipment Cost Lines
This endpoint allows you to add the cost lines for a specific shipment.

This information helps in accurately tracking and allocating costs associated with the shipment, providing insights into the overall cost structure of the services or items involved.

Request
Method: POST

URL: https://api.locate2u.com/api/v1/shipments/175368/cost-lines

Headers:

Content-Type: application/json

Input parameters:
shipmentId

Shipment id is a * required integer($int32)(path). This id here is the unique shipment id of the shipment in your Locate2u account for which you want to add cost-line.

Request Body
The request body should be in JSON format and include the following parameters:

  • description (string, optional): A description of the cost line.
  • quantity (number): The quantity of the item.
  • unitPriceExTax (number): The unit price of the item excluding tax.

Example request body:

{
  "description": "Fuel charge",
  "quantity": 1,
  "unitPriceExTax": 10.05
}

Sample code

C#
Java
NodeJS
PHP
Python
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.locate2u.com/api/v1/shipments/105333/cost-lines");
request.Headers.Add("Authorization", "Bearer yourBearerTokenHere");
var content = new StringContent("\r\n{\r\n  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.05\r\n},\r\n{\r\n  \"description\": \"Visit charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 11.05\r\n},\r\n{\r\n  \"description\": \"Parts changed\",\r\n  \"quantity\": 3,\r\n  \"unitPriceExTax\": 10.05\r\n}\r\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "\r\n{\r\n  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.05\r\n},\r\n{\r\n  \"description\": \"Visit charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 11.05\r\n},\r\n{\r\n  \"description\": \"Parts changed\",\r\n  \"quantity\": 3,\r\n  \"unitPriceExTax\": 10.05\r\n}\r\n");
Request request = new Request.Builder()
  .url("https://api.locate2u.com/api/v1/shipments/105333/cost-lines")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer yourBearerTokenHere")
  .build();
Response response = client.newCall(request).execute();
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.locate2u.com',
  'path': '/api/v1/shipments/105333/cost-lines',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer yourBearerTokenHere'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData =  "\r\n{\r\n  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.05\r\n},\r\n{\r\n  \"description\": \"Visit charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 11.05\r\n},\r\n{\r\n  \"description\": \"Parts changed\",\r\n  \"quantity\": 3,\r\n  \"unitPriceExTax\": 10.05\r\n}\r\n";

req.write(postData);

req.end();
 'https://api.locate2u.com/api/v1/shipments/105333/cost-lines',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'
{
  "description": "Fuel charge",
  "quantity": 1,
  "unitPriceExTax": 10.05
},
{
  "description": "Visit charge",
  "quantity": 1,
  "unitPriceExTax": 11.05
},
{
  "description": "Parts changed",
  "quantity": 3,
  "unitPriceExTax": 10.05
}
',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer yourBearerTokenHere'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import requests
import json

url = "https://api.locate2u.com/api/v1/shipments/105333/cost-lines"

payload = "\r\n{\r\n  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.05\r\n},\r\n{\r\n  \"description\": \"Visit charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 11.05\r\n},\r\n{\r\n  \"description\": \"Parts changed\",\r\n  \"quantity\": 3,\r\n  \"unitPriceExTax\": 10.05\r\n}\r\n"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer yourBearerTokenHere'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response

The response will be a JSON object with a status code of 200 ok for a success:

{
    "costLineId": 1194848,
    "description": "Fuel charge",
    "quantity": 1.0,
    "unitPriceExTax": 10.05,
    "type": "surcharge"
}