loops

package
v0.30.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package loops provides a client for the Loops.so email API. See https://loops.so/docs/api-reference for full documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents an error response from the Loops API.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides methods to interact with the Loops.so API.

func New

func New(apiKey string) *Client

New creates a new Loops client with the given API key.

func (*Client) CreateContact

func (c *Client) CreateContact(ctx context.Context, req *ContactRequest) error

CreateContact creates a new contact in Loops.

func (*Client) SendEvent

func (c *Client) SendEvent(ctx context.Context, req *EventRequest) error

SendEvent sends an event to trigger automations in Loops.

func (*Client) SendTransactional

func (c *Client) SendTransactional(ctx context.Context, req *TransactionalRequest) error

SendTransactional sends a transactional email via the Loops API.

func (*Client) UpdateContact

func (c *Client) UpdateContact(ctx context.Context, req *ContactRequest) error

UpdateContact updates an existing contact in Loops.

type ContactRequest

type ContactRequest struct {
	// Email is the contact's email address (required).
	Email string `json:"email"`
	// UserID is an optional external identifier for the contact.
	UserID string `json:"userId,omitempty"`
	// FirstName is the contact's first name (optional).
	FirstName string `json:"firstName,omitempty"`
	// LastName is the contact's last name (optional).
	LastName string `json:"lastName,omitempty"`
	// Properties are custom contact properties (optional).
	Properties map[string]any `json:"properties,omitempty"`
}

ContactRequest contains the fields for creating or updating a contact.

type EventRequest

type EventRequest struct {
	// Email is the contact's email address (required if UserID not set).
	Email string `json:"email,omitempty"`
	// UserID is the contact's user ID (required if Email not set).
	UserID string `json:"userId,omitempty"`
	// EventName is the name of the event to trigger (required).
	EventName string `json:"eventName"`
	// EventProperties are custom properties for the event (optional).
	EventProperties map[string]any `json:"eventProperties,omitempty"`
}

EventRequest contains the fields for sending an event.

type TransactionalRequest

type TransactionalRequest struct {
	// Email is the recipient's email address (required).
	Email string `json:"email"`
	// TransactionalID is the template ID from the Loops dashboard (required).
	TransactionalID string `json:"transactionalId"`
	// DataVariables are template variables to inject into the email (optional).
	DataVariables map[string]any `json:"dataVariables,omitempty"`
	// AddToAudience creates a contact if one doesn't exist (optional, default false).
	AddToAudience bool `json:"addToAudience,omitempty"`
	// IdempotencyKey prevents duplicate sends within 24 hours (optional).
	IdempotencyKey string `json:"-"`
}

TransactionalRequest contains the fields for sending a transactional email.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL