> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.usglobalmail.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.usglobalmail.com/_mcp/server.

# SDKs

We publish official SDKs so you don't have to hand-roll HTTP calls, auth headers, pagination, retries,
or error handling. Every SDK is generated from the same [OpenAPI spec](/api) that powers this
reference, so it always matches the live API — and is fully typed.

#### [TypeScript](/sdks/client-libraries/type-script)

`npm install @usgm/sdk`

#### [Python](/sdks/client-libraries/python)

`pip install usgm`

#### [PHP](/sdks/client-libraries/php)

`composer require usgm/sdk`

#### [Go](/sdks/client-libraries/go)

`go get github.com/usgm/usgm-go`

## What every SDK gives you

* **Authentication** — pass your API key once as `token`; the SDK sends it on every request.
* **Typed models** — resources and parameters are fully typed for editor autocomplete and safety.
* **Cursor pagination** — list methods return a page (`data`, `next_cursor`, `total_count`); pass `next_cursor` back to fetch the next page.
* **Retries with backoff** — transient `429`/`5xx` responses are retried automatically.
* **Typed errors** — non-2xx responses raise a typed error carrying the HTTP `status` and the problem+json `body` (which includes `code` and `request_id`).

## Environments

The SDKs ship a typed environment enum — point at the sandbox while developing, then switch to
production (the default):

**`TypeScript`**

```typescript title="TypeScript"
import { UsgmClient, UsgmEnvironment } from "@usgm/sdk";

const usgm = new UsgmClient({
  token: process.env.USGM_API_KEY!,
  environment: UsgmEnvironment.Sandbox, // omit for Production
});
```

**`Python`**

```python title="Python"
import os
from usgm import Usgm, UsgmEnvironment

usgm = Usgm(
    token=os.environ["USGM_API_KEY"],
    environment=UsgmEnvironment.SANDBOX,  # omit for production
)
```

**`PHP`**

```php title="PHP"
use Usgm\UsglobalmailClient;
use Usgm\Environments;

$usgm = new UsglobalmailClient(
    getenv('USGM_API_KEY'),
    ['baseUrl' => Environments::Sandbox->value], // omit for production
);
```

**`Go`**

```go title="Go"
import (
	usgm "github.com/usgm/usgm-go"
	usgmclient "github.com/usgm/usgm-go/client"
	"github.com/usgm/usgm-go/option"
)

client := usgmclient.NewClient(
	option.WithToken(os.Getenv("USGM_API_KEY")),
	option.WithBaseURL(usgm.Environments.Sandbox), // omit for production
)
```

> **Note**
>
> SDKs are generated with [Fern](https://buildwithfern.com) from the gateway's OpenAPI 3.1 document.
> When the API changes, the SDKs are regenerated and re-published from the same spec, so the client is
> never out of date.