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

# Use the Go SDK

> Install the Leadping Go SDK, configure API authentication with a Kiota request adapter, and follow an example to retrieve a lead using typed API routes.

* Module and repository: [`github.com/leadpingai/leadping-go`](https://github.com/leadpingai/leadping-go)

## Install

```bash theme={null}
go get github.com/leadpingai/leadping-go
go get github.com/microsoft/kiota-http-go@v1.4.0
```

## Prepare the example

Use Go 1.23 or later in an initialized module. Set `LEADPING_API_KEY`, replace `lead-id` with an existing record in that organization, and save the example as `main.go`. Run it with `go run .`.

The context timeout bounds how long this example waits for its read. In a service, derive the timeout from the incoming request or job context.

## Create the client

```go theme={null}
package main

import (
    "context"
    "fmt"
    "os"
    "time"

    leadping "github.com/leadpingai/leadping-go"
    auth "github.com/microsoft/kiota-abstractions-go/authentication"
    kiotahttp "github.com/microsoft/kiota-http-go"
)

func main() {
    credential := os.Getenv("LEADPING_API_KEY")
    if credential == "" {
        panic("LEADPING_API_KEY is not set")
    }

    authProvider, err := auth.NewApiKeyAuthenticationProviderWithValidHosts(
        "Bearer "+credential,
        "Authorization",
        auth.HEADER_KEYLOCATION,
        []string{"api.leadping.ai"},
    )
    if err != nil {
        panic(err)
    }

    adapter, err := kiotahttp.NewNetHttpRequestAdapter(authProvider)
    if err != nil {
        panic(err)
    }

    client := leadping.NewLeadpingOpenApiClient(adapter)

    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()

    lead, err := client.Leads().ById("lead-id").Get(ctx, nil)
    if err != nil {
        panic(err)
    }

    if lead == nil || lead.GetId() == nil {
        panic("Leadping returned no lead ID")
    }
    fmt.Println(*lead.GetId())
}
```

The client defaults to `https://api.leadping.ai`. Set `LEADPING_API_KEY` to an organization API key. `client.Users().Me()` requires a user access token; source keys are only for lead intake.

## Call routes

Use this pattern inside a function that receives a context and returns an error:

```go theme={null}
source, err := client.Sources().ById("source-id").Get(ctx, nil)
if err != nil {
    return err
}
// Inspect source only after checking err.
```

The SDK does not store credentials. Use generated request-body interfaces when creating or updating records, confirm contracts in the [API Reference](https://leadping.ai/docs/api-reference.md), and follow the [rate-limit guide](https://leadping.ai/docs/rate-limits.md).

Generated getters commonly return pointers for optional values. Check for nil before dereferencing. The console example uses `panic` to stop on failure; a service should return or classify the error so its worker can apply a bounded retry or request investigation.


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