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

Create Shipment Charge Line
This endpoint allows the creation of a new charge line for a specific shipment.

Request
Method: POST

URL: https://api.locate2u.com/api/v1/shipments/{shipmentId}/charge-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 charge-line.

Request body:

The request body should be in raw format and should include the following parameters:

  • description (string, optional): Description of the charge line.
  • quantity (number, required): Quantity of the charge line.
  • unitPriceExTax (number, required): Unit price of the charge line excluding tax.

Example body:

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

Sample code

C#
Java
NodeJS
PHP
Python
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.locate2u.com/api/v1/shipments/175368/charge-lines");
request.Headers.Add("Authorization", "Bearer yourBearerTokenHere");
var content = new StringContent("{\r\n  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.01\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  \"description\": \"Fuel charge\",\r\n  \"quantity\": 1,\r\n  \"unitPriceExTax\": 10.01\r\n}");
Request request = new Request.Builder()
  .url("https://api.locate2u.com/api/v1/shipments/175368/charge-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/175368/charge-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 = JSON.stringify({
  "description": "Fuel charge",
  "quantity": 1,
  "unitPriceExTax": 10.01
});

req.write(postData);

req.end();
 'https://api.locate2u.com/api/v1/shipments/175368/charge-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.01
}',
  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/175368/charge-lines"

payload = json.dumps({
  "description": "Fuel charge",
  "quantity": 1,
  "unitPriceExTax": 10.01
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer yourBearerTokenHere'
}

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

print(response.text)

Response

The response will contain the ID, description, quantity, and unit price of the newly created charge line.

The response for this request is a JSON object conforming to the following schema:

JSON

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "quantity": {
      "type": "number"
    },
    "unitPriceExTax": {
      "type": "number"
    }
  }
}