> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solvapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> SolvaPay quick facts:
> - REST API base URL: https://api.solvapay.com. All public endpoints are under /v1/sdk/ (for example GET https://api.solvapay.com/v1/sdk/products). Sandbox and production share this URL.
> - Auth: send a secret key as `Authorization: Bearer <secret key>` (the REST API also accepts `X-API-Key: <secret key>`).
> - Secret key prefixes: `sk_sandbox_` (sandbox, test payments) and `sk_live_` (production). The prefix selects the environment.
> - Get keys in SolvaPay Console (https://app.solvapay.com) > Developers > API Keys. Use a sandbox key while building.
> - Admin MCP Server: https://mcp.solvapay.com/mcp (Streamable HTTP). Connect with OAuth: add the URL and sign in with the SolvaPay account; no API key needed. OAuth sessions use the live account; for sandbox data or headless clients, send `Authorization: Bearer <secret key>` (X-API-Key is ignored).
> - Install the SolvaPay agent skills: `npx skills add https://solvapay.com` (skills CLI older than 1.5.7: `npx skills add solvapay/skills`).
> - TypeScript SDK setup: `npx solvapay@latest init`. The SDK reads SOLVAPAY_SECRET_KEY and defaults to https://api.solvapay.com.
> - Plans take an options[] array (billingCycle, charge, limit, ...). Retired plan fields price, freeUnits and billingCycle are rejected.
> - Step-by-step from zero to a first paid call: Managed MCP https://docs.solvapay.com/build/managed-mcp.md, TypeScript SDK https://docs.solvapay.com/build/typescript-sdk.md, agent skill https://docs.solvapay.com/build/agent-skill.md.
> - Details: https://docs.solvapay.com/api-reference/authentication.md. OpenAPI spec: https://docs.solvapay.com/api-reference/openapi.json.

# Installation

> Install the SolvaPay Go SDK and set your keys.

## Prerequisites

* Go 1.26 or later
* A SolvaPay account with a product and at least one plan

## Install the module

```bash theme={null}
go get github.com/solvapay/solvapay-sdk/go@latest
```

Import it as `solvapay`:

```go theme={null}
import solvapay "github.com/solvapay/solvapay-sdk/go"
```

Agent payments live in a subpackage, `github.com/solvapay/solvapay-sdk/go/agents`. See [Agent payments](https://docs.solvapay.com/sdks/go/guides/agents.md).

## Set up with the CLI

In an existing project, `npx solvapay init` signs you in, writes `SOLVAPAY_SECRET_KEY` and `SOLVAPAY_PRODUCT_REF` to `.env`, and runs `go get` for the module, pinned exactly. It needs Node.js 22 or later to run. The SDK reads environment variables, not `.env`, so load `.env` when your app starts or export the variables.

```bash theme={null}
npx solvapay init
```

For a new paid MCP server, scaffold one instead:

```bash theme={null}
npm create solvapay@latest my-mcp-server -- --type mcp --language go
```

`npx solvapay doctor` checks that the SDK is the newest release and prints the upgrade command. See [CLI setup](https://docs.solvapay.com/sdks/typescript/setup/cli.md) for the flags.

## Set your keys

1. In SolvaPay Console, go to **Developers** > **API Keys** and copy a sandbox secret key (`sk_sandbox_…`).
2. Copy the reference (`prd_…`) of the product you want to charge for.
3. Set them in your environment:

```bash theme={null}
export SOLVAPAY_SECRET_KEY=sk_sandbox_...
export SOLVAPAY_PRODUCT_REF=prd_...
```

| Variable | Required | Read by |
| - | - | - |
| `SOLVAPAY_SECRET_KEY` | Yes | `NewClient`, when `Config.APIKey` is empty. A missing key fails with the code `missing_secret`. |
| `SOLVAPAY_PRODUCT_REF` | Yes, unless you pass a product in code | `NewPaywall` and `NewMCPServer`, when no `ProductRef` is set. With no product, `Payable` and `NewMCPServer` fail with the code `missing_product`. |
| `SOLVAPAY_API_BASE_URL` | No | `NewClient`, when `Config.APIBaseURL` is empty. Defaults to `https://api.solvapay.com`. |

Keep the secret key on your server. Never ship it to a browser or a client app.

## Versions

* The Go SDK has its own version line, starting at v0.1.0. Its numbers don't follow the TypeScript packages.
* Releases are tagged `go/vX.Y.Z` in the [solvapay-sdk](https://github.com/solvapay/solvapay-sdk) repository. `go get …@latest` picks the newest release.
* Until v1.0.0, a minor release (v0.x to v0.y) may change the API.
* Each release behaves like the TypeScript SDK: a shared conformance suite checks the paywall, its messages, the MCP tools and webhook verification on every change.

To try the next release before it ships, ask for a preview by its version (previews are tagged `go/vX.Y.Z-dev.N`), or take the `dev` branch as a pseudo-version:

```bash theme={null}
go get github.com/solvapay/solvapay-sdk/go@dev
```

The API reference for every version is on [pkg.go.dev](https://pkg.go.dev/github.com/solvapay/solvapay-sdk/go).

## Next steps

* [Quick start](https://docs.solvapay.com/sdks/go/setup/quick-start.md): make your first paid function.
* [MCP server](https://docs.solvapay.com/sdks/go/guides/mcp.md): sell MCP tools.
* The TypeScript equivalent of this page: [Installation](https://docs.solvapay.com/sdks/typescript/setup/installation.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.