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

# Go SDK

> Programmatic access to Formal with the Go SDK

## Overview

Use the Formal Go SDK to build custom tools, automation, and integrations.

> [!NOTE]
>
> For most infrastructure management tasks, use the [Terraform
> provider](https://docs.formal.ai/docs/guides/configuration/terraform.md) instead of the SDK.

The SDK source is at [github.com/formalco/go-sdk](https://github.com/formalco/go-sdk).

## Features

* Create, read, update, delete Formal objects
* Query logs and sessions programmatically
* Manage policies dynamically
* Integrate Formal into CI/CD pipelines
* Build custom dashboards

## Example

Install the SDK:

```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
go get github.com/formalco/go-sdk/v3@latest
```

List your Resources:

```go theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
package main

import (
    "context"
    "fmt"
    "log"
    "os"

    formal "github.com/formalco/go-sdk/v3"
    corev1 "github.com/formalco/go-sdk/v3/core/v1"
)

func main() {
    client, err := formal.New(formal.WithAPIKey(os.Getenv("FORMAL_API_KEY")))
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.ResourceServiceClient.ListResources(context.Background(), &corev1.ListResourcesRequest{Limit: 50})
    if err != nil {
        log.Fatal(err)
    }

    for _, r := range res.Resources {
        fmt.Println(r.Id, r.Name, r.Technology)
    }
}
```

The client calls `https://api.formal.ai` by default.

To call the API without the SDK, see [HTTP API](https://docs.formal.ai/docs/guides/configuration/sdks/http-api.md).

## API Documentation

See the [API Reference](https://docs.formal.ai/docs/api/introduction.md) for complete endpoint documentation.


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