Skip to content

Quickstart

You need an OhrTech organisation with at least one device, and permission to manage its members (ManageMembers) in the OhrTech Portal.

  1. Create a service account. In the OhrTech Portal, open Service accounts and create one named, say, quickstart.

  2. Grant it two permissions: ViewDevices and SendMessages. Leave its devices, networks and embed sites unlimited for now. You can narrow them later.

  3. Make a token. Choose New token, pick how long it lasts (30 days to a year), and copy it. It starts with ohrs_ and is shown only once. Keep it in an environment variable:

    Terminal window
    export OHR_TOKEN=ohrs_…
  4. List your devices.

    Terminal window
    curl https://api.ohrtech.net/v1/devices -H "Authorization: Bearer $OHR_TOKEN"

    Each device has a deviceId. Pick one that is online.

  5. Show a message on its screen.

    Terminal window
    curl https://api.ohrtech.net/v1/devices/42/messages \
    -H "Authorization: Bearer $OHR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"text": "Hello from the Management API"}'

    The message appears on the device within seconds. The response is the task that carries it: GET /v1/devices/42/tasks/{taskId} shows it go from pending to success.

quickstart.cs
#:package OhrTech.Management@*
// Lists your devices, then shows a message on one of them.
// OHR_TOKEN=ohrs_… dotnet run quickstart.cs list devices
// OHR_TOKEN=ohrs_… dotnet run quickstart.cs -- 42 …and show a message on device 42
using OhrTech.Management;
using var api = OhrManagementClient.ForServiceAccount(
Environment.GetEnvironmentVariable("OHR_TOKEN") ?? throw new InvalidOperationException("Set OHR_TOKEN to a service account token."));
foreach (var d in await api.ListDevicesAsync())
{
var state = d.Online ? "online" : "offline";
var battery = d.BatteryLevel is { } level ? $"{level}%" : "–";
Console.WriteLine($"{d.DeviceId,6} {d.Serial,-16} {d.FleetName ?? "(no fleet)",-24} {state,-8} battery {battery}");
}
if (args.Length > 0 && long.TryParse(args[0], out var deviceId))
{
var task = await api.ShowMessageAsync(deviceId, new ShowMessageRequest { Text = "Hello from the Management API" });
Console.WriteLine($"Sent: task {task.TaskId} is {task.Status}");
}