Learn how to configure and add your first contact with SendX golang SDK
go get github.com/sendx/sendx-go-sdk
package main import ( "context" "fmt" "os" sendx "github.com/sendx/sendx-go-sdk" ) func main() { ctx := context.WithValue( context.Background(), sendx.ContextAPIKeys, map[string]sendx.APIKey{ "apiKeyAuth": {Key: "YOUR_API_KEY"}, }, ) contactRequest := *sendx.NewContactRequest() // ContactRequest | contactRequest.Email = sendx.PtrString("jane@doe.com") contactRequest.FirstName = sendx.PtrString("Jane") contactRequest.LastName = sendx.PtrString("Doe") contactRequest.Company = sendx.PtrString("Tech Solutions Inc.") contactRequest.LastTrackedIp = sendx.PtrString("34.94.159.140") contactRequest.CustomFields = &map[string]string{"K2mxBVReqBhbwx9e0ItSea": "VIP", "7o3Tl1aY2yKp2X1aflRjOL": "Special Offer Subscriber"} contactRequest.Lists = []string{"1244"} contactRequest.Tags = []string{"MKdhTovsTJDetCyrJmRySL"} configuration := sendx.NewConfiguration() apiClient := sendx.NewAPIClient(configuration) resp, r, err := apiClient.ContactAPI.CreateContact(ctx).ContactRequest(contactRequest).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `ContactAPI.CreateContact``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `CreateContact`: Response fmt.Fprintf(os.Stdout, "Response from `ContactAPI.CreateContact`: %v\n", resp) }
Was this page helpful?