Go SDK
go get github.com/lbframe/klozeo-sdk-goRequires Go 1.23+.
Quick start
Section titled “Quick start”import klozeo "github.com/lbframe/klozeo-sdk-go"
client := klozeo.New("sk_live_your_api_key")
// Create a lead// Optional string fields use pointers to distinguish "not set" from "empty string"lead, err := client.Create(ctx, &klozeo.Lead{ Name: "Acme Corp", Source: "website", City: "Berlin",})
// List with filtersleads, err := client.List(ctx, klozeo.City().Eq("Berlin"), klozeo.Rating().Gte(4.0), klozeo.Sort(klozeo.FieldRating, klozeo.Desc), klozeo.Limit(20),)
// Iterate all pages (Go 1.23+ range-over-function iterator)for lead, err := range client.Iterator(ctx, klozeo.City().Eq("Berlin")) { if err != nil { log.Fatal(err) } fmt.Println(lead.Name)}
// Export to CSVreader, err := client.Export(ctx, klozeo.ExportCSV)OR logic
Section titled “OR logic”Combine Or() with standard filters in the same List() call:
leads, err := client.List(ctx, klozeo.City().Eq("Paris"), // AND city = Paris klozeo.Or().Rating().Gte(4.0), // OR rating >= 4)Error handling
Section titled “Error handling”import "errors"
resp, err := client.Create(ctx, &klozeo.Lead{Name: "Acme", Source: "web"})if err != nil { var apiErr *klozeo.APIError if errors.As(err, &apiErr) { switch apiErr.Code { case klozeo.ErrRateLimit: // retry after apiErr.RetryAfter case klozeo.ErrNotFound: // lead not found case klozeo.ErrUnauthorized: // invalid API key } }}note, err := client.AddNote(ctx, leadID, "Called back — very interested.")notes, err := client.Notes(ctx, leadID)err = client.DeleteNote(ctx, noteID)Batch operations
Section titled “Batch operations”// Create up to 100 leads at onceresults, err := client.BatchCreate(ctx, leads)
// Delete by IDserr = client.BatchDelete(ctx, []string{"cl_...", "cl_..."})Full API reference: pkg.go.dev/github.com/lbframe/klozeo-sdk-go
Notes pagination
Section titled “Notes pagination”The existing notes list method returns all notes by following server cursors in
pages of 50. For bounded reads use ListNotesPage(ctx, leadID, 20, cursor).
The page includes notes, a continuation cursor and a has-more flag. Pass the cursor unchanged to read the next page. Iteration stops when
has_more is false. A missing or empty cursor while more notes remain, repeated
cursors and more than 10,000 pages raise an error
rather than returning a silently truncated history. API limits are 1–50 (default 20).