---
title: Message format
project: OpenSync
version: 1.0
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/opensync/1-0/reference/message-format/
updated: 2026-11-19T09:22:09.965Z
---

# Message format

> The fields of the messages that OpenSync sends to clients.

Every request to `/sync/{channel}/` and every WebSocket `notify` becomes one JSON message. Clients get the same message over [WebSocket](../websocket/) and [Server-Sent Events](../server-sent-events/).

## Example

```json
{"id":"24nb4004pu50d","type":"application/json","channel":"orders","method":"POST","headers":{"host":"sync.example.com","user-agent":"curl/8.7.1","accept":"*/*","content-type":"application/json","content-length":"27"},"ua":"","query":{},"body":{"id":1002,"status":"paid"},"ts":"2026-11-19T08:04:51.361Z","ip":"203.0.113.10","files":[]}
```

## Fields

| Field | Type | Meaning |
|---|---|---|
| `id` | string | A unique ID of the message. |
| `type` | string | The content type of the request, without parameters such as `boundary`: `application/json`, `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`… Empty for a request without a body. Always `application/json` for a WebSocket message. |
| `channel` | string | The channel. |
| `method` | string | `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, or `SOCKET` for a WebSocket message. |
| `headers` | object | The request headers, with lower-case names. Empty for a WebSocket message. |
| `ua` | string | A short form of the browser and system from the `User-Agent` header, for example `Mac Chrome`. Empty for scripts and tools such as curl. |
| `query` | object | The query arguments, as strings. |
| `body` | object or string | JSON and form data as an object, other content as text, an empty string without a body. |
| `ts` | string | The time OpenSync received the request (ISO 8601, UTC). |
| `ip` | string | The IP address of the sender. |
| `files` | array | The uploaded files. See [Send files](../files/). |
| `dtcreated` | string | Only while [Log all requests](../../guides/request-log/) is on: the time the message was logged. |

## The init message

When a client connects, it first gets:

```json
{"type":"init","name":"Demo sync","version":1,"id":"OpenSync"}
```

| Field | Meaning |
|---|---|
| `type` | Always `init`. |
| `name` | The instance name from the **Setup** page. |
| `version` | The OpenSync version number, `1`. |
| `id` | Always `OpenSync`. |
