(Contacts)
Manage contacts in your audience
- PostContactsCreate - Create a contact
- PutContactsUpdate - Update a contact
- GetContactsFind - Find a contact
- PostContactsDelete - Delete a contact
Add a contact to your audience.
package main
import(
loopsgo "github.com/speakeasy-sdks/loops-go"
"github.com/speakeasy-sdks/loops-go/models/components"
"context"
"log"
)
func main() {
s := loopsgo.New(
loopsgo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := components.ContactRequest{
Email: "[email protected]",
MailingLists: &components.MailingLists{},
}
ctx := context.Background()
res, err := s.Contacts.PostContactsCreate(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ContactSuccessResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.ContactRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.PostContactsCreateResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.ContactFailureResponse | 400,405,409 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Update a contact by email
or userId
.
If you want to update a contact’s email address, the contact will first need a userId
value. You can then make a request containing the userId field along with an updated email address.
package main
import(
loopsgo "github.com/speakeasy-sdks/loops-go"
"github.com/speakeasy-sdks/loops-go/models/components"
"context"
"log"
)
func main() {
s := loopsgo.New(
loopsgo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := components.ContactRequest{
Email: "[email protected]",
MailingLists: &components.MailingLists{},
}
ctx := context.Background()
res, err := s.Contacts.PutContactsUpdate(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ContactSuccessResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.ContactRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.PutContactsUpdateResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.ContactFailureResponse | 400,405 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Search for a contact by email
or userId
. Only one parameter is allowed.
package main
import(
loopsgo "github.com/speakeasy-sdks/loops-go"
"context"
"log"
)
func main() {
s := loopsgo.New(
loopsgo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Contacts.GetContactsFind(ctx, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Contacts != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
email |
*string | ➖ | Email address (URI-encoded) |
userID |
*string | ➖ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetContactsFindResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.ContactFailureResponse | 400 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Delete a contact by email
or userId
.
package main
import(
loopsgo "github.com/speakeasy-sdks/loops-go"
"github.com/speakeasy-sdks/loops-go/models/components"
"context"
"log"
)
func main() {
s := loopsgo.New(
loopsgo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
request := components.ContactDeleteRequest{
Email: "[email protected]",
UserID: "<value>",
}
ctx := context.Background()
res, err := s.Contacts.PostContactsDelete(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.ContactDeleteResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.ContactDeleteRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.PostContactsDeleteResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.ContactFailureResponse | 400,404 | application/json |
sdkerrors.SDKError | 4xx-5xx | / |