Skip to content
ndStill is in development. These docs describe the v2 API as designed; the SDKs and the hosted MCP server are previews and not generally available.
Docs

Go SDK

Reference for ndstill-go: the client, Pay, approvals, simulate and the x402 round tripper.

Preview, not generally available

github.com/ndstill/ndstill-go is the designed Go client for the v2 API: one package, context-aware calls, typed params and models, an http.RoundTripper for x402 and net/http Verify middleware. Go 1.22 or later.

Install#

Terminal
go get github.com/ndstill/ndstill-go

Create a client#

Go
import (
	"os"

	"github.com/ndstill/ndstill-go"
)

client := ndstill.New(os.Getenv("NDSTILL_API_KEY"))

// With options:
client = ndstill.New(os.Getenv("NDSTILL_API_KEY"),
	ndstill.WithVersion("2026-11-01"),
	ndstill.WithMaxRetries(2),
	ndstill.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
)
Client options
OptionDefaultNotes
WithBaseURL(url)https://api.ndstill.com/v2A regional cell or a local mock.
WithVersion(v)2026-11-01Sent as Ndstill-Version.
WithAccessToken(t)noneUse an OAuth 2.1 token instead of the key.
WithMaxRetries(n)2Network errors, 429, 502, 504; same idempotency key.
WithHTTPClient(c)http.DefaultClient with a 30 s timeoutBring your own.

Pay#

Go
payment, err := client.Pay(ctx, ndstill.PayParams{
	Agent:        "agt_01JD8Q3W6Z",
	Amount:       ndstill.Money{Amount: 4200, Asset: "USD"},
	Counterparty: "Delta Air Lines",
	Purpose:      "Flight SFO to JFK for the offsite",
})
if err != nil {
	var declined *ndstill.DeclinedError
	if errors.As(err, &declined) {
		log.Println(declined.DeclineReasons[0].Message, declined.RequestID)
		return
	}
	return err
}

if payment.Status == ndstill.StatusHeld {
	// A person approves first.
	approval, err := client.Approvals.Wait(ctx, payment.ApprovalID, 10*time.Minute)
	_ = approval
	_ = err
}

PayParams also takes RailPreference, MandateID, Dims and IdempotencyKey. Without a key, the client generates one and reuses it on retries.

Resources#

Main methods
MethodEndpoint
client.Pay / client.Payments.CreatePOST /payment-intents
client.Payments.Get, client.Payments.ListGET /payment-intents…
client.SimulatePOST /decisions/simulate
client.Approvals.Get, client.Approvals.WaitGET /approvals/{id}
client.Budgets.CheckGET /budgets for the agent's scopes
client.Agents.Freeze, client.Freezes.CreatePOST /agents/{id}/freeze, POST /freezes
client.Policies.Validate, client.Policies.Replay/policies/{id}/…
ndstill.VerifyWebhook(body, header, secret)Local Standard Webhooks check

Simulate in tests#

Go
func TestTravelPolicy(t *testing.T) {
	sim, err := client.Simulate(ctx, ndstill.SimulateParams{
		Agent:        travelAgent,
		Amount:       ndstill.Money{Amount: 45000, Asset: "USD"},
		Counterparty: "Delta Air Lines",
	})
	if err != nil {
		t.Fatal(err)
	}
	if sim.WouldOutcome == ndstill.OutcomeDecline {
		t.Fatalf("a normal flight would be declined: %v", sim.Reasons)
	}
}

Pagination#

Go
iter := client.Payments.List(ctx, ndstill.PaymentListParams{Status: "held"})
for iter.Next() {
	p := iter.Current()
	_ = p
}
if err := iter.Err(); err != nil {
	return err
}

Errors#

Every non-2xx response is an *ndstill.Error with Type, Code, Message, RequestID, Fields and DeclineReasons; use errors.As for the typed ones: *DeclinedError, *InvalidRequestError, *StepUpRequiredError, *RateLimitError (with RetryAfter). A held payment is not an error. See Errors and decline reasons.

x402 round tripper#

Go
httpClient := &http.Client{
	Transport: ndstill.X402Transport(client, ndstill.X402Options{
		Agent:     "agt_01JD8Q3W6Z",
		Wallet:    wallet, // anything that implements ndstill.TypedDataSigner
		MaxAmount: ndstill.Money{Amount: 100000, Asset: "USDC"},
	}),
}
resp, err := httpClient.Get("https://api.northwind.example/v1/search?q=agents")

On 402 Payment Required, the transport asks ndStill for a decision first and signs only against an approved payment approval token. See x402 and USDC.

Verify middleware#

Go
mux.Handle("/v1/search", ndstill.Verify(ndstill.VerifyOptions{Require: "passport"})(searchHandler))
// inside the handler: agent := ndstill.AgentFrom(r.Context())

See Verify for sellers.