Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Sendmux Go core helpers

Go Reference

Shared runtime helpers used by the Sendmux Go surface packages.

Install

go get sendmux.ai/go@latest

Import

import "sendmux.ai/go/core"

What it provides

  • API-key prefix validation with ValidateAPIKey and KeySurface.
  • Shared APIError, ErrorIssue, SuccessEnvelope, and Pagination types.
  • Retry-aware HTTP clients through NewHTTPClient, NewRetryingTransport, and RetryOptions.
  • Cursor iteration through IterateCursor for code that adapts a response type to the core.Page interface.

Example

package main

import (
	"net/http"
	"os"
	"time"

	"sendmux.ai/go/core"
)

func newHTTPClient() *http.Client {
	if err := core.ValidateAPIKey(os.Getenv("SENDMUX_API_KEY"), core.KeySurfaceRoot); err != nil {
		panic(err)
	}

	return core.NewHTTPClient(nil, core.RetryOptions{
		MaxAttempts: 4,
		BaseDelay:   250 * time.Millisecond,
		MaxDelay:    5 * time.Second,
	})
}

Use KeySurfaceSending for send-capable smx_mbx_ keys or owner-approved Sending-resource smx_agent_ tokens, KeySurfaceMailbox for smx_mbx_ keys or scoped smx_agent_ tokens, and KeySurfaceRoot for smx_root_ keys.

Most applications should import sendmux.ai/go/sending, sendmux.ai/go/mailbox, or sendmux.ai/go/management directly. Those packages apply the core helpers for you.

Documentation