---
title: Use of WebSockets - POS partners
description: Doshii's WebSocket service is how the POS and Partner Application stay in sync in real-time. Our WebSocket connection is intended to represent a location (a single outlet or venue). As such each devic
---

[Skip to content](https://support.doshii.com/developer-support/websockets-pos-partners#main-content)

English

Show submenu for translations

Doshii Connect Pty Ltd

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- Go to Doshii Connect Pty Ltd

 Go to Doshii Connect Pty Ltd

 Help for Partners

- There are no suggestions because the search field is empty.

1. [Help for Partners](https://support.doshii.com/developer-support?hsLang=en)
2. [WebSocket - POS partners](https://support.doshii.com/developer-support/websocket-pos-partners?hsLang=en)

# Use of WebSockets - POS partners

Doshii's WebSocket service is how the POS and Partner Application stay in sync in real-time.

Our WebSocket connection is intended to represent a location (a single outlet or venue). As such each device, lets say an iPad in a venue does not need to connect individually to Doshii. This design is ideal for legacy, closed loop POS systems who do not have a web presence. Instead they typically have a local server at each site.

For cloud POS systems we do also only accept a single WebSocket connection for all locations, however there are vendor API features available that would allow you to control which location is online/offline.

[Environments](https://support.doshii.com/developer-support/websockets-pos-partners#environments)

[Connection](https://support.doshii.com/developer-support/websockets-pos-partners#connection)

[Cloud POS Connection](https://support.doshii.com/developer-support/websockets-pos-partners#h_01GKFS4JEZPX0H3NSM8BFNHBGR)

[Listening for Events](https://support.doshii.com/developer-support/websockets-pos-partners#h_01GKFS4Q02WMJCSE57CSB7QFKS)

 

 Environments

There are currently two environments available in establishing a connection to the Doshii WebSocket. If you're pre-launch (ie. don't have live credentials), that will be the `sandbox` environment. If you're a live integrator, it will be the aptly named `live`environment.

```
// Sandbox
wss://socket.sandbox.doshii.co/pos/socket?token=

// Live
wss://socket.live.doshii.co/pos/socket?token=
```

 

With `` representing the unique location token provided to you by Doshii.

Already using a different URL than above? Older naming patterns for the URL will continue to work.

 

 Connection

Let's do the example in JavaScript. Those writing other languages will need to adapt the following to suit, guides for your language are coming soon.

Let's start by installing a couple of libraries you'll need to make the connection.

- [WebSockets "ws"](https://github.com/websockets/ws) library for fast and easy WebSocket connection

```
yarn add ws
# Or for you NPMers
npm i -S ws
```

 

Now that's all done, let's establish a connection.

```
const WebSocket = require('ws');

const authToken = location.token;

// Establish a connection to the Doshii Sandbox WebSocket
const ws = new WebSocket('wss://socket.sandbox.doshii.co/pos/socket?token=' + authToken);
```

 

After you've connected to the Doshii WebSocket, you'll need to send **[heartbeats](https://support.doshii.com/developer-support/hc/en-us/articles/360007479253-heartbeats?hsLang=en)** across every 30 seconds so that we know you're still listening.

```
ws.on('open', function(event) {
  function heartbeat() {
    const timestamp = Date.now();
    const posVersion = '1.2.3';
    const payload = JSON.stringify({
        doshii: {
            ping: timestamp,
            version: posVersion
        }
    });
    ws.send(payload);
  }

  heartbeat(); // Send one immediately to complete the handshake
  setInterval(heartbeat, 30000); // Then 30 every seconds or so thereafter to keep alive
});
```

It's a good idea to have some error handling in there too.

```
ws.on('error', function(err) {
  throw new Error('Doshii WebSocket error: ', err);
});
```

 

 Cloud POS Connection

If you're a Cloud POS Vendor then your connection is slightly different as you no longer need to connect for each location. 

```
Sandbox URL wss://socket.sandbox.doshii.co/vendor/socket?token=<jwt>&vendor=<apiName> Live URL wss://socket.live.doshii.co/vendor/socket?token=<jwt>&vendor=<apiName> 
```

 

 The JWT token is built using the same technique described in**[POS Authentication](https://support.doshii.com/developer-support/hc/en-us/articles/360000657534-pos-authentication?hsLang=en)** with the only difference being the Vendor API Name is included rather than the location token.

```
"vendor": The POS Vendor API name"timestamp": The current timestamp in EPOC-Seconds for validating the request expiry time, default is 10 minutes.
```

 

 Listening for Events

Great! Now that you're connected and errors handled, how about we listen for some messages from the server?

```
ws.addEventListener('message', function(event) {
  if (!event) return;
  console.log(event.type);
  console.log(event.data);
}
```

 

The important parts of the event you'll receive are `event.type` and `event.data`. The `event.type` field stores the name of the event that corresponds with the list found in the **[POS API Reference](https://support.doshii.com/developer-support/all-pos-vendor-events?hsLang=en)**.   
For example; `order_created` or `transaction_updated`. Generic messages such as the "pong" response to each of your "ping"s will have the `message` event type.   
The `event.data` field stores the relevant information of the event.

Here's a sample "pong" message event.

```
{
  type: 'message',
  data: {
        doshii: {
            pong: 1539144663417,
            version: '3.2.123'
        }
    },
  target:
    WebSocket {
      ... (connection information)
    }
}
```

 

A list of the WebSocket events can be found in the [**POS API Reference**.](https://support.doshii.com/developer-support/all-pos-vendor-events?hsLang=en)

- [API concepts](https://support.doshii.com/developer-support/api-concepts?hsLang=en)
- [Members](https://support.doshii.com/developer-support/members?hsLang=en)
- [Model](https://support.doshii.com/developer-support/model?hsLang=en)
- [FAQ - Developers](https://support.doshii.com/developer-support/faq-developers?hsLang=en)
- [Resources](https://support.doshii.com/developer-support/resources?hsLang=en)
- [Orders](https://support.doshii.com/developer-support/orders?hsLang=en)
- [Rewards](https://support.doshii.com/developer-support/rewards?hsLang=en)
- [Check-ins](https://support.doshii.com/developer-support/check-ins?hsLang=en)
- [Getting started - App partners](https://support.doshii.com/developer-support/getting-started-app-partners?hsLang=en)
- [Employees](https://support.doshii.com/developer-support/employees?hsLang=en)
- [Getting started - Doshii Dashboard](https://support.doshii.com/developer-support/getting-started-doshii-dashboard?hsLang=en)
- [Quick start for developers](https://support.doshii.com/developer-support/quick-start-for-developers?hsLang=en)
- [Onboarding](https://support.doshii.com/developer-support/onboarding?hsLang=en)
- [Location](https://support.doshii.com/developer-support/location?hsLang=en)
- [All App Partners Event](https://support.doshii.com/developer-support/all-app-partners-event?hsLang=en)
- [Menus](https://support.doshii.com/developer-support/menus?hsLang=en)
- [Loyalty / Checkins](https://support.doshii.com/developer-support/loyalty-checkins?hsLang=en)
- [WebSocket - App partners](https://support.doshii.com/developer-support/websocket-app-partners?hsLang=en)
- [All POS vendor events](https://support.doshii.com/developer-support/all-pos-vendor-events?hsLang=en)
- [Loyalty / Gift Cards](https://support.doshii.com/developer-support/loyalty-gift-cards?hsLang=en)
- [Devices](https://support.doshii.com/developer-support/devices?hsLang=en)
- [Tables](https://support.doshii.com/developer-support/tables?hsLang=en)
- [Workflows](https://support.doshii.com/developer-support/workflows?hsLang=en)
- [FAQ - Doshii Dashboard](https://support.doshii.com/developer-support/faq-doshii-dashboard?hsLang=en)
- [Bookings](https://support.doshii.com/developer-support/bookings?hsLang=en)
- [Transactions](https://support.doshii.com/developer-support/transactions?hsLang=en)
- [Webhooks](https://support.doshii.com/developer-support/webhooks?hsLang=en#main-content)

    - [App Partners](https://support.doshii.com/developer-support/webhooks?hsLang=en#app-partners)
    - [POS Vendors](https://support.doshii.com/developer-support/webhooks?hsLang=en#pos-vendors)
- [App Partner Guide](https://support.doshii.com/developer-support/app-partner-guide?hsLang=en)
- [Authentication](https://support.doshii.com/developer-support/authentication?hsLang=en)
- [Getting started - POS vendors](https://support.doshii.com/developer-support/getting-started-pos-vendors?hsLang=en)
- [Ordering](https://support.doshii.com/developer-support/ordering?hsLang=en)
- [Reservations](https://support.doshii.com/developer-support/reservations?hsLang=en)
- [Pilot](https://support.doshii.com/developer-support/pilot?hsLang=en)
- [Bulk data](https://support.doshii.com/developer-support/bulk-data?hsLang=en)
- [Playbooks](https://support.doshii.com/developer-support/playbooks?hsLang=en)
- [Rejection codes](https://support.doshii.com/developer-support/rejection-codes?hsLang=en)
- [Getting started](https://support.doshii.com/developer-support/getting-started?hsLang=en)
- [WebSocket - POS partners](https://support.doshii.com/developer-support/websocket-pos-partners?hsLang=en)
- [Events - App partners](https://support.doshii.com/developer-support/events-app-partners?hsLang=en)
- [Service channels](https://support.doshii.com/developer-support/service-channels?hsLang=en)
- [Events](https://support.doshii.com/developer-support/events?hsLang=en)
- [Concepts](https://support.doshii.com/developer-support/concepts?hsLang=en)
- [Apps](https://support.doshii.com/developer-support/apps?hsLang=en)

# Doshii Connect Pty Ltd

Doshii Connect Pty Ltd Help Center

Copyright © 2026, Doshii Connect Pty Ltd