Event type: stop.status-changed

The “stop.status-changed” webhook event is triggered whenever there is a change in the status of a stop or booking in the Locate2u system. This status change can occur from multiple sources within the system, such as the app portal, mobile apps, or through the API. Developers integrating with Locate2u can subscribe to this webhook event and handle these status changes on their URL/website. Here’s how you subscribe to the “stop.status-changed” webhook:

  • Subscribe to the “stop.status-changed” event by making a POST call to the api/v1/webhooks endpoint with two parameters : “eventType” and “url”.

Example Request Body

The request body should be in raw format and should contain below fields:

  • eventType (string, required): The type of event for the webhook. Here we are subscribing to stop.status-changed webhook.
  • url (string, required): The URL where the webhook payload will be sent.
{
  "eventType": "stop.status-changed",
  "url": "https://hookb.in/"
}

Once subscribed to the “stop.status-changed” event, the Locate2u webhook will send a payload with details of the event whenever there is a change in the status of a stop/booking, allowing you to perform actions on your end accordingly. See the response section for an example payload sent by the webhook. Below, you will find example requests on how to subscribe to the “stop.status-changed” event.

List of statuses:

Created

Pending

Enroute 

Arrived

Cancelled

Delayed 

Complete

On Hold

Sample code

C#
Java
NodeJS
PHP
Python
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "http://api.locate2u.com/api/v1/webhooks");
request.Headers.Add("Authorization", "Bearer yourBearerTokenHere");
var content = new StringContent("{\"eventType\": \"my.event\", \"url\" : \"https://hookb.in/"}", 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, "{\"eventType\": \"stop.status-changed\", \"url\" : \"https://hookb.in/"}");
Request request = new Request.Builder()
  .url("http://api.locate2u.com/api/v1/webhooks")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer yourBearerTokenHere")
  .build();
Response response = client.newCall(request).execute();
var http = require('follow-redirects').http;
var fs = require('fs');

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

var req = http.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({
  "eventType": "stop.status-changed",
  "url": "https://hookb.in/"
});

req.write(postData);

req.end();
 'http://api.locate2u.com/api/v1/webhooks',
  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 =>'{"eventType": "stop.status-changed", "url" : "https://hookb.in/"}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer yourBearerTokenHere'
  ),
));

$response = curl_exec($curl);

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

url = "http://api.locate2u.com/api/v1/webhooks"

payload = json.dumps({
  "eventType": "stop.status-changed",
  "url": "https://hookb.in/"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer yourBearerTokenHere'
}

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

print(response.text)

Response

Example response code for stop status change event:

{
  "stopId": 987786,
  "stopRef": "L20222704I1H4ZE",
  "tripDate": "2024-04-27",
  "shipmentId": null,
  "actionDate": "2024-04-27T14:16:40.9450989+10:00",
  "oldStatus": "Enroute",
  "newStatus": "Arrived",
  "notes": null,
  "location": null,
  "assignedTo": {
    "name": "Steve Parker",
    "id": "a823361e-9d40-4438-bb28-b2b58cdb957e"
  },
  "changedByUser": {
    "name": "Steve Parker",
    "id": "a823361e-9d40-4438-bb28-b2b58cdb957e"
  },
  "source": null,
  "sourceReference": null
}