Skip to content

JSON endpoints

Protocols
json:jsons:
Runtime
Node.jsBrowser
json://<host>[:<port>]/<path>
jsons://<host>[:<port>]/<path>

json: sends HTTP; jsons: sends HTTPS.

import { send } from 'statocysts'
await send('jsons://example.com/notifications', {
title: 'Deployment complete',
body: 'Production is healthy.',
})

The default body is:

{
"title": "Deployment complete",
"body": "Production is healthy."
}

body is omitted when the notification has no body.

A query key whose decoded value starts with a space becomes a request header. A key starting with : becomes an additional body property.

jsons://example.com/notifications?%20Authorization=Bearer%20TOKEN&:environment=production

This sends Authorization: Bearer TOKEN and adds "environment": "production" to the JSON body. Other query parameters remain in the endpoint URL.

json.send() and jsons.send() accept ofetch FetchOptions directly:

import { jsons } from 'statocysts'
await jsons.send(target, notification, {
timeout: 5000,
retry: 2,
})