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

# Go SDK

> Install and use the official Essal Go SDK to access all six apps from your Go project.

The `essal-go` module provides an idiomatic Go client with context support, typed responses, and automatic retry handling.

## Installation

```bash theme={null}
go get github.com/essal/essal-go
```

## Initialisation

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

client := essal.NewClient(essal.Config{
    APIKey:      os.Getenv("ESSAL_API_KEY"),
    Environment: essal.Production, // essal.Production | essal.Staging | essal.Sandbox
})
```

## Usage Examples

```go theme={null}
ctx := context.Background()

// List documents
docs, err := client.Office.Documents.List(ctx, &essal.DocumentListParams{
    Limit: essal.Int(20),
})
if err != nil {
    log.Fatal(err)
}
for _, doc := range docs.Data {
    fmt.Println(doc.Title)
}

// Create a Sales contact
contact, err := client.Sales.Contacts.Create(ctx, &essal.ContactCreateParams{
    DisplayName:      "Jane Smith",
    Email:            "jane@acmecorp.com",
    OrganizationName: "Acme Corp",
})

// Create a Project task
task, err := client.Project.Tasks.Create(ctx, "proj_01HXYZ9876", &essal.TaskCreateParams{
    Title:    "Design review",
    Priority: essal.TaskPriorityHigh,
})
```

## Pagination

```go theme={null}
iter := client.Office.Documents.ListAll(ctx, &essal.DocumentListParams{Limit: essal.Int(50)})
for iter.Next() {
    doc := iter.Document()
    fmt.Println(doc.Title)
}
if err := iter.Err(); err != nil {
    log.Fatal(err)
}
```

## Error Handling

```go theme={null}
_, err := client.Sales.Contacts.Get(ctx, "cnt_nonexistent")
if err != nil {
    var apiErr *essal.APIError
    if errors.As(err, &apiErr) {
        fmt.Printf("API error %s: %s\n", apiErr.Code, apiErr.Message)
    }
}
```
