Skip to main content

Overview

In addition to the WebSocket-based SDK, Brook provides a REST API for publishing messages. This is useful for:
  • Server-side applications
  • One-way message publishing (no subscription needed)
  • Integration with services that don’t support WebSockets
  • Serverless functions and cron jobs

Endpoint

Authentication

Aptly uses API keys for authentication. Include your API key in the x-api-key header.
Use Server Keys (sk_) for REST API requests. Public keys (pk_) cannot publish messages.

Required Headers

Server Keys vs Public Keys

Authentication Guide

Learn when to use public keys vs server keys

Request Format

Body

Examples

Using cURL

Using Fetch (Browser/Node.js)

Using Axios

Response Format

Success Response

Error Response

Use Cases

Serverless Functions

Webhooks

Scheduled Tasks

Best Practices

Use environment variables for your API key to keep it secure.
Implement retry logic for critical messages to handle temporary network issues.
Rate limits apply - avoid sending too many requests in a short period.
REST API is one-way - use the WebSocket SDK if you need to subscribe to messages.

Error Handling

Next Steps

JavaScript SDK

Use the full SDK for bidirectional communication

React SDK

Integrate Brook into React applications