Skip to content

Email with the Go SDK

Manage Longbridge Email from Go with the longbridge-go client — the Email method set, and a short example that lists domains and mints a send key, reading its reveal-once secret.

The longbridge-go client manages Email resources from Go, over the same public API the CLI and Terraform provider use. This page covers the Email methods; for install and authentication, start with the SDK introduction.

Early access. Email is being rolled out behind an Org flag. If you don’t see it in the Console, it isn’t enabled for your organization yet.

The method set

Email methods hang off the same *longbridge.Client, one per management operation — ListEmailDomains, CreateEmailDomain, ArmEmailDomainReceive, MintEmailSendKey, RevokeEmailSendKey, CreateEmailWebhook, RotateEmailWebhookSecret, CreateEmailRoute, ListEmailMessages, ListEmailSuppressions, and their siblings. The reveal-once secrets — a send key’s secret and a webhook’s signing secret — are returned only by the mint, create, and rotate calls, never by a read.

An example

List the Org’s domains, then mint a send key scoped to the first one and read its secret — the single time it’s available:

package main

import (
	"context"
	"fmt"
	"log"

	longbridge "github.com/longbridgehq/longbridge-go"
)

func main() {
	c := longbridge.New(longbridge.DefaultEndpoint, "lngbr_…")
	ctx := context.Background()

	domains, err := c.ListEmailDomains(ctx)
	if err != nil {
		log.Fatal(err)
	}
	if len(domains) == 0 {
		log.Fatal("no email domains registered")
	}
	for _, d := range domains {
		fmt.Printf("%s  send=%s  receive=%s\n", d.Name, d.SendState, d.ReceiveState)
	}

	// Mint a key restricted to the first domain. The secret is disclosed here
	// and never again — persist it now.
	minted, err := c.MintEmailSendKey(ctx, longbridge.EmailSendKeySpec{
		Name:    "production api",
		Domains: []string{domains[0].ID},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("minted %s — secret (shown once): %s\n",
		minted.SendKey.KeyID, minted.Secret)
}

minted.SendKey.KeyID is the lpk_… public half (the SMTP username) and minted.Secret is the full lpk_<id>.<secret> credential — also the SMTP password. The wire types are regenerated from the published OpenAPI, so the client never drifts from what the API serves.

The canonical reference

Every method, type, and field is documented on the Go package reference, generated from the source:

Where to next

  • SDK introduction — install and authenticate.
  • Send keys — the credential this example mints.
  • CLI — the same operations from your terminal.