/favicon.ico Skip to content
Sailhouse

Setup

Creating an account

First things first, get signed in and create a team.

Then, install the CLI.

brew install sailhouse

And connect to your fresh-faced, lovely, new account.

sailhouse auth

Creating an app

In Sailhouse, apps are the logical separator for your topics. This could be environments, projects, apps, whatever.

sailhouse apps create [slug]

Oh yeah, we do everything with slugs too.

Get sending events

We have a few language-native SDKs/clients available

Creating a token

With your CLI authenticated, you can create a token easily

sailhouse tokens create

Then, taking the sh_app_ prefixed value, you can store that in an environment variable on the platform you’re running in.

Using the Go SDK

Below is an example for utilising the Go SDK on a Netlify Function

package main

import (
	"os"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/sailhouse/sdk-go/sailhouse"
)

func handler(request events.APIGatewayProxyRequest) (*events.APIGatewayProxyResponse, error) {
	client := sailhouse.NewSailhouseClient(os.Getenv("SAILHOUSE_TOKEN"))

	client.Publish("awesome-example", map[string]string{
		"message": "Hello World!",
	})

	return &events.APIGatewayProxyResponse{
		StatusCode: 200,
		Body:       "Hello World!",
	}, nil
}

func main() {
	lambda.Start(handler)
}

Using the TypeScript SDK

Below is another example of using the TypeScript SDK within a Netlify Function.

import { Handler } from "@netlify/functions";
import { SailhouseClient } from "@sailhouse/client";

export const handler: Handler = async (event, _) => {
  const { body } = event;
  const { email, type } = JSON.parse(body ?? "{}");

  const client = new SailhouseClient(process.env.SAILHOUSE_API_KEY!);

  await client.publish("signups", {
    email,
    type,
  });

  return {
    statusCode: 200,
  };
};