Skip to main content
The Go SDK provides a clean and idiomatic Go interface for integrating Dodo Payments into your applications. It offers context support, strongly typed responses, middleware capabilities, and is safe for concurrent use.

Installation

Install the SDK using Go modules:
Or to pin to a specific version:
The SDK requires Go 1.22 or later versions, leveraging modern Go features for optimal performance.

Quick Start

Initialize the client and create your first checkout session:
Always store your API keys securely using environment variables. Never hardcode them in your source code.

Core Features

Context Support

Full support for context.Context for cancellation and timeouts

Strong Typing

Strongly typed requests and responses for compile-time safety

Middleware

Extensible middleware support for logging, metrics, and custom logic

Goroutine Safe

Thread-safe client designed for concurrent operations

Configuration

Context and Timeouts

Leverage Go’s context for timeouts and cancellation:

Retry Configuration

Configure automatic retry behavior:

Common Operations

Create a Checkout Session

Generate a checkout session:

Manage Customers

Create and retrieve customer information:

Handle Subscriptions

Create and manage recurring subscriptions:
Billing requires at minimum the two-letter ISO Country code. Customer is a CustomerRequestUnionParam — pass AttachExistingCustomerParam{CustomerID: ...} for an existing customer or NewCustomerParam{Email: ..., Name: ...} for a new one. ProductPrice is in the lowest currency denomination.

Usage-Based Billing

Ingest Usage Events

Track custom events:

List Usage Events

Error Handling

When the API returns a non-success status code, the SDK returns an error of type *dodopayments.Error. It exposes the StatusCode, the underlying *http.Request and *http.Response, and the JSON of the error body. Use the errors.As pattern to inspect it, and branch on StatusCode to handle specific cases:

Middleware

Add custom middleware for logging or metrics:

Concurrency

The client is safe for concurrent use:

Resources

GitHub Repository

View source code and contribute

API Reference

Complete API documentation

Discord Community

Get help and connect with developers

Report Issues

Report bugs or request features

Support

Need help with the Go SDK?

Contributing

We welcome contributions! Check the contributing guidelines to get started.
Last modified on June 10, 2026