Getting Started / Authentication

Overview

This guide covers how to authenticate with the Pegasus Gateway API and manage access tokens securely. The API uses token-based authentication: you exchange credentials for a session token, then include that token in all subsequent requests.

Key concepts:

  • Session tokens — Short-lived tokens obtained via login. They expire after 60 minutes of inactivity.
  • Application tokens — Scoped, long-lived tokens for integrations. They follow the principle of least privilege by restricting access to only the resources you specify.
  • Receiver tokens — Special-purpose tokens for ingesting data from third-party devices.
⚠️

Security Best Practice

Rotate tokens regularly and always grant the minimum permissions necessary. Prefer finite (time-limited) tokens over long-lived ones. Revoke tokens immediately when they are no longer needed.


Authentication

Authenticate using the login endpoint to obtain a session token. There are two authentication methods:

MethodEndpointRequired Parameters
Central Auth Serverhttps://auth.pegasusgateway.com/username, password, gateway
Pegasus Domain URLhttps://yourpegasusdomain.com/api/loginusername, password

Central Auth:

curl --request POST \
     --url https://auth.pegasusgateway.com/ \
     --header 'Content-Type: application/json' \
     --data '
{
  "username": "[email protected]",
  "password": "*********",
  "gateway": "cloud.pegasusgateway.com"
}'

Domain URL:

curl --request POST \
     --url https://www.yourpegasusdomain.com/api/login \
     --header 'Content-Type: application/json' \
     --data '
{
  "username": "[email protected]",
  "password": "*********"
}'

Response

A successful login returns a session token in the auth field:

{
  "message": "User successfully authenticated",
  "app": null,
  "auth": "208b....a0ce"
}

👍

Include the token in every subsequent request using the HTTP header Authenticate

Session tokens expire after 60 minutes of inactivity by default. This is by design — short-lived tokens reduce the risk of unauthorized access if a token is compromised.


Get User Info

Retrieve the authenticated user's profile and permissions:

curl --request GET \
     --url 'https://api.pegasusgateway.com/user' \
     --header 'Authenticate: AUTH_SESSION_TOKEN'
{
  "username": "[email protected]",
  "scopes": {
    "sims": "r",
    ...
  }
}

For information on embedding applications in Pegasus, see Applications.


Application Tokens

Application tokens provide scoped, restricted access to the API. Use them to grant integrations or third parties access to only the specific resources they need — without exposing your full account permissions.

Key principles:

  • An application token cannot exceed the permissions of the user who created it.
  • Always scope tokens to the minimum required groups and permissions.
  • Rotate tokens periodically — revoke old tokens and issue new ones on a regular schedule.
  • Name tokens descriptively (via the app parameter) so you can audit and manage them.

Creating an Application Token

Use the POST /user/sessions endpoint:

ParameterDescription
schemefinite
limitToken lifetime in seconds
appDescriptive name for the token (e.g., "fleet-dashboard")
scopesAccess restrictions in URL param format: groups=<IDs>&read=<scopes>&write=<scopes>
app_schemeReserved for Pegasus platform applications

Example — Create a scoped token:

curl -X POST https://api.pegasusgateway.com/user/sessions \
    --header 'Content-Type: application/json' \
    --header 'Authenticate: 7ebb...12c0' \
    -d '{"scheme":"finite","limit":86400,"app":"fleet-dashboard","scopes":"groups=285&write=remote.output,tasks"}'

Response:

{
  "origin": "--",
  "scopes": "groups=285&write=remote.output,tasks",
  "app": "fleet-dashboard",
  "token": "af11...cef5",
  "app_scheme": "",
  "user": 1,
  "scheme": "finite"
}

Verifying an Application Token

Call Get user info with an application token to confirm its effective permissions:

curl --request GET \
     --url 'https://api.pegasusgateway.com/user?auth=APP_TOKEN' \
     --header 'Accept: application/json'
{
  "username": "[email protected]",
  "scopes": {
    "sims": "r",
    ...
  },
  "virtual_id": "scoped:54",
  "virtual": true
}
💡

Virtual user: When virtual is true, the token is an application token. The virtual_id identifies the originating user whose permissions are being virtualized.


List all your tokens:

GET /user/sessions
{
  "tokens": [
    {
      "origin": "--",
      "scopes": "groups=285&write=remote.output,tasks",
      "app": "fleet-dashboard",
      "expires": 7183,
      "token": "9c56...3724",
      "app_scheme": "",
      "scheme": "finite"
    }
  ],
  "session": {
    "origin": "--",
    "scopes": "",
    "app": "None",
    "expires": 3600,
    "token": "7ebb...12c0",
    "app_scheme": "",
    "scheme": "normal"
  }
}

Revoke a token:

curl https://api.pegasusgateway.com/logout?auth=640c...56e2 \
    --header 'Content-Type: application/json'
{"message": "Session terminated"}
🔐

Token hygiene: Regularly audit your active tokens via GET /user/sessions and revoke any that are no longer in use. Accounts are limited to 50 long-lived tokens — if you hit this limit, it indicates tokens are not being properly rotated or cleaned up.


Receiver tokens

Receiver tokens authorize the data receiver endpoints to accept data from third-party devices into your Pegasus Gateway.

ParameterDescription
resourceThe data receiver endpoint (e.g., receivers.json)
appDescriptive name for the receiver
app_schemeIP allowlist/blocklist config: ips=<CSV of IPs> and optionally ips_blacklist=1 to treat the list as a blocklist
🔐

Always restrict receiver tokens by IP address using the app_scheme parameter. This ensures only known sources can send data to your gateway.

Create a receiver token:

curl -X POST https://api.pegasusgateway.com/tokens \
    --header 'Content-Type: application/json' \
    --header 'Authenticate: 7ebb...12c0' \
    -d '{"resource":"receivers.json","app":"my-app","app_scheme":"ips=12.12.12.12,13.13.13.13"}'
{
  "origin": "--",
  "app": "my-app",
  "token": "89bf...6789",
  "app_scheme": "ips=12.12.12.12,13.13.13.13",
  "scheme": "infinite"
}

List receiver tokens:

GET /tokens

Delete a receiver token:

curl -X DELETE https://api.pegasusgateway.com/tokens/89bf...6789 \
    --header 'Content-Type: application/json'

Data Streams

Monitor incoming requests for a specific receiver token:

GET /tokens/:receiver_token/stream
{
  "size": 25,
  "items": [
    {
      "body": "[{\"vehicle.name\":\"red truck\",\"engine.hours\":4.59,\"position.altitude\":1453,...}]",
      "url": "http://pegasus2.peginstances.com/json",
      "headers": "X-Client-Ip: 12.12.12.12\nContent-Length: 648\nAuthenticate: 89bf...6789\nConnection: Keep-alive\nHost: cloud.pegasusgateway.com\nContent-Type: application/json\n",
      "time": "2021-09-07 11:34:39+00:00",
      "method": "POST",
      "remote_ip": "12.12.12.12"
    }
  ]
}

{
    "size": 25,
    "items": [
        {
            "body": "[{\"vehicle.name\":\"red truck\",\"engine.hours\":4.59,\"position.altitude\":1453,\"position.heading\":179,\"position.hdop\":0.7,\"position.latitude\":6.322105,\"position.longitude\":-75.551478,\"position.satellites\":10,\"position.speed\":6,\"position.valid\":true,\"server.timestamp\":1631014478.971503,\"timestamp\":1630937864,\"vehicle.mileage\":112766.605}]",
            "url": "http://pegasus2.peginstances.com/json",
            "headers": "X-Client-Ip: 12.12.12.12\nContent-Length: 648\nAuthenticate: 89bf...6789\nConnection: Keep-alive\nHost: cloud.pegasusgateway.com\nContent-Type: application/json\n",
            "time": "2021-09-07 11:34:39+00:00",
            "method": "POST",
            "remote_ip": "12.12.12.12"
        },
        ...


Scopes / API Permissions

API access is governed by two mechanisms:

  1. Groups — Determine which entities (vehicles, SIMs, assets, devices) a user can see.
  2. Scopes — Determine what actions a user can perform on each resource type.

Permission Levels

LevelHTTP MethodsDescription
rGETRead-only access
wGET, POST, PUT, DELETEFull read/write access

Example: A user with { "triggers": "r", "vehicles": "w" } can view triggers but can create, edit, and delete vehicles.

📘

Permission denied: Attempting to access a resource without the required scope returns HTTP 401 Unauthorized.


Retrieve the full list at resources/users/scopes. Below is the complete reference:

resourcepermissiondescriptionAPI
assets:trackerwriteallows asset trackers the ability to update checkpoints (geofences) (used in Taurus App)
assetsreadsee the assets (drivers, things, etc)assets
assetswritecreate and edit assets (drivers, things, etc)assets
configurationsreadread the managed configurationsconfigurations
device.mutereadview event mute statusdevices
device.mutewritemute device eventsdevices
devicesreadview devicesdevices
deviceswritecreate devices is not available, contact support
entities.linkwriteassociate or disassociate two entitiesentities
formswriteview and fill out forms assigned to this user
forwardersreadview forwarder statusforwarders
forwarderswritecontact support to create forwarders
geofencesreadview own geofencesgeofences
geofenceswritecreate and edit your own geofencesgeofences
geofences:adminwriteallows user to modify any geofence within their group even if another owner owns it
geofences:visibilitywriteview public geofencesgeofences
geofences:visibility.allwritecreate public geofencesgeofences
geofences:visibility.groupswritecreate geofences for your groupgeofences
groupsreadread the groups and its' infogroups
groupswritecreate and edit groupsgroups
groups.assetswritemanage assets within your groupassets
groups.userswritemanage users within your groupusers
groups.vehicleswritemanage vehicles within your groupvehicles
pindropswritecreate a pindrop (safe zone) around an entitypindrops
plugins.garminreadsee garmin jobs & messagesplugins.garmin
plugins.garminwritecreate garmin jobs and send garmin messagesplugins.garmin
plugins.lumewayreadread the lumeway dataplugins.lumeway
plugins.lumewaywritetake a photo with the lumeway accessoryplugins.lumeway
plugins.photocamreadsee the photosphotos
plugins.photocamwritetake photosphotos
plugins.satcomreadsee satcom parameterssatcom
plugins.satcomwriteset satcom parameterssatcom
rawdatareadget the vehicle's rawdatarawdata
remotereadsee the remote GET methodsremote
remotewriteability to execute all remote commands (the dot commands below)remote
remote.callwritecall an authorized numberremote
remote.configurationwriteset a managed configurationremote
remote.consolewritesend console (freestyle) commandsremote
remote.diagnosticwriteable to send the diagnostic command that connects the device to diagnostic portal
remote.ecu_consolewriteable to send the query for updating ecu monitor variables
remote.fwupdatewriteexecute a firmware updateremote
remote.gps_statuswriteable to send a diagnostic message for the gps of syrus devices
remote.ky_resetwriteable to resync a managed configuration
remote.mdtwritesend mdt (serial port) messagesremote
remote.outputwriteset an outputremote
remote.outputsetlogreadview the output activation logs
remote.phoneswriteauthorize a numberremote
remote.rpmwriteset rpm thresholdremote
remote.safe_immowriteexecute a safe engine immobilizationremote
remote.segmentswriteconfigure the segments for an entitySegments (Trips)
remote.sms_aliaswriteset an sms_alias for actionsremote
remote.speedwriteset a speed limit thresholdremote
remote.statereadview the state of the inputs/outputs of a device
remote.tracking_resolutionwriteset tracking resolutionremote
remote.trigger_position_eventwritequery device's live locationremote
routesreadsee entity routesroutes
routeswritecreate routesroutes
simsreadsee the SIMs infosims
sims:subaccountsreadallows to manage wireless and super sims
tasksreadview a tasktasks
taskswritecreate/edit a tasktasks
triggersreadsee the triggers assigned to your usertriggers
triggerswritecreate and edit triggerstriggers
users.application_datareadview permissions for other usersusers
users.application_datawriteassign permissions for other usersusers
users.password_resetwriteset or reset the password of other usersusers
usersreadread the user's infousers
userswritecreate and edit the usersusers
vehiclesreadread the vehicle list and it's informationvehicles
vehicleswritecreate and edit a vehiclevehicles
vehicles.countersreadread the vehicle's countersvehicle-counters
vehicles.counterswriteedit the global vehicle countersvehicle-counters


Security Recommendations

PracticeWhy
Always use finite tokensLimits exposure window if a token is compromised
Rotate tokens regularlyReduces risk from leaked or stale credentials
Scope tokens narrowlyPrevents accidental or malicious access to unrelated resources
Restrict receiver tokens by IPEnsures only trusted sources can send data
Audit tokens periodically (GET /user/sessions)Identifies orphaned or unnecessary tokens to revoke
Revoke unused tokens immediatelyMinimizes your active attack surface