inboundgo

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: MIT Imports: 12 Imported by: 0

README ΒΆ

Inbound Go SDK

Go Reference Go Report Card

A Go SDK for Inbound - Email infrastructure made simple for Go developers.

πŸš€ Quick Start

Installation
go get github.com/inboundemail/inbound-golang-sdk
Send your first email
package main

import (
    "context"
    "fmt"
    "log"

    inbound "github.com/inboundemail/inbound-golang-sdk"
)

func main() {
    client, err := inbound.NewClient("your-api-key")
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()
    
    // Send an email
    resp, err := client.Email().Send(ctx, &inbound.PostEmailsRequest{
        From:    "hello@yourdomain.com",
        To:      "recipient@example.com",
        Subject: "Hello from Go!",
        Text:    inbound.String("This email was sent using the Inbound Go SDK!"),
        HTML:    inbound.String("<h1>Hello from Go!</h1><p>This email was sent using the Inbound Go SDK!</p>"),
    }, nil)
    
    if err != nil {
        log.Fatal(err)
    }
    
    if resp.Error != "" {
        log.Fatal(resp.Error)
    }
    
    fmt.Printf("Email sent! ID: %s\n", resp.Data.ID)
}

πŸ“§ Features

  • Send Emails: Send transactional emails with attachments, scheduling, and rich content
  • Receive Emails: Handle inbound emails with webhook processing
  • Domain Management: Add and verify your domains
  • Email Address Management: Create and manage email addresses
  • Endpoint Management: Configure webhook and email endpoints
  • Scheduling: Schedule emails for future delivery
  • Attachments: Support for file attachments and embedded images
  • Idempotency: Built-in support for idempotent operations
  • Context Support: All operations support Go's context for timeouts and cancellation

πŸ“š Usage Examples

Initialize the client
// Basic initialization
client, err := inbound.NewClient("your-api-key")

// With custom base URL
client, err := inbound.NewClient("your-api-key", "https://custom-api-url.com")

// With custom HTTP client
httpClient := &http.Client{Timeout: 10 * time.Second}
client, err := inbound.NewClient("your-api-key")
client.WithHTTPClient(httpClient)
Send emails with attachments
resp, err := client.Email().Send(ctx, &inbound.PostEmailsRequest{
    From:    "sender@yourdomain.com",
    To:      []string{"user1@example.com", "user2@example.com"},
    CC:      "manager@example.com",
    Subject: "Monthly Report",
    HTML:    inbound.String("<h1>Monthly Report</h1><p>Please find the report attached.</p>"),
    Attachments: []inbound.AttachmentData{
        {
            Filename:    "report.pdf",
            Content:     inbound.String("base64-encoded-content"),
            ContentType: inbound.String("application/pdf"),
        },
        {
            Path:     inbound.String("https://example.com/logo.png"),
            Filename: "logo.png",
            ContentID: inbound.String("company-logo"), // For embedding in HTML
        },
    },
    Tags: []inbound.EmailTag{
        {Name: "category", Value: "reports"},
        {Name: "priority", Value: "high"},
    },
}, nil)
Schedule emails
// Schedule with natural language
resp, err := client.Email().Schedule(ctx, &inbound.PostScheduleEmailRequest{
    From:        "notifications@yourdomain.com",
    To:          "user@example.com",
    Subject:     "Reminder: Meeting Tomorrow",
    Text:        inbound.String("Don't forget about our meeting tomorrow at 2 PM!"),
    ScheduledAt: "tomorrow at 1 PM",
    Timezone:    inbound.String("America/New_York"),
}, nil)

// Schedule with ISO 8601 timestamp
resp, err := client.Email().Schedule(ctx, &inbound.PostScheduleEmailRequest{
    From:        "notifications@yourdomain.com", 
    To:          "user@example.com",
    Subject:     "Scheduled Notification",
    HTML:        inbound.String("<p>This is a scheduled email!</p>"),
    ScheduledAt: "2024-12-25T09:00:00Z",
}, nil)
Manage inbound emails
// List received emails
emails, err := client.Mail().List(ctx, &inbound.GetMailRequest{
    Limit:     inbound.Int(10),
    TimeRange: "7d",
    Status:    "all",
})

// Get specific email
email, err := client.Mail().Get(ctx, "email-id")

// Mark as read
_, err = client.Mail().MarkRead(ctx, "email-id")

// Reply to an email
_, err = client.Mail().Reply(ctx, &inbound.PostMailRequest{
    EmailID:  "original-email-id",
    To:       "sender@example.com",
    Subject:  "Re: Your inquiry",
    TextBody: "Thank you for your message. We'll get back to you soon!",
})
Domain management
// Add a domain
domain, err := client.Domain().Create(ctx, &inbound.PostDomainsRequest{
    Domain: "yourdomain.com",
})

// List domains
domains, err := client.Domain().List(ctx, &inbound.GetDomainsRequest{
    Limit:  inbound.Int(20),
    Status: "verified",
})

// Get DNS records for verification
records, err := client.Domain().GetDNSRecords(ctx, "domain-id")

// Verify domain
_, err = client.Domain().Verify(ctx, "domain-id")
Email address management
// Create an email address
emailAddr, err := client.Email().Address.Create(ctx, &inbound.PostEmailAddressesRequest{
    Address:    "support@yourdomain.com",
    DomainID:   "domain-id",
    EndpointID: inbound.String("webhook-endpoint-id"),
    IsActive:   inbound.Bool(true),
})

// List email addresses
addresses, err := client.Email().Address.List(ctx, &inbound.GetEmailAddressesRequest{
    DomainID: "domain-id",
    IsActive: "true",
})
Webhook endpoints
// Create a webhook endpoint
endpoint, err := client.Endpoint().Create(ctx, &inbound.PostEndpointsRequest{
    Name: "Main Webhook",
    Type: "webhook",
    Config: &inbound.WebhookConfig{
        URL:           "https://yourdomain.com/webhook/inbound",
        Timeout:       30000,
        RetryAttempts: 3,
        Headers: map[string]string{
            "X-Custom-Header": "value",
        },
    },
})

// Test endpoint connectivity  
_, err = client.Endpoint().Test(ctx, "endpoint-id")
Convenience methods
// Quick text reply
_, err = client.QuickReply(ctx, "email-id", "Thanks for your message!", "support@yourdomain.com", nil)

// One-step domain setup with webhook
webhookURL := "https://yourdomain.com/webhook"
_, err = client.SetupDomain(ctx, "yourdomain.com", &webhookURL)

// Create email forwarder
_, err = client.CreateForwarder(ctx, "info@yourdomain.com", "support@yourdomain.com")

// Schedule a reminder
_, err = client.ScheduleReminder(ctx, "user@example.com", "Meeting Reminder", "in 1 hour", "notifications@yourdomain.com", nil)

πŸ”§ Error Handling

All methods return an ApiResponse[T] struct with either data or an error:

resp, err := client.Email().Send(ctx, emailParams, nil)
if err != nil {
    // Handle network/client errors
    log.Fatal(err)
}

if resp.Error != "" {
    // Handle API errors
    log.Printf("API Error: %s", resp.Error)
    return
}

// Use the data
fmt.Printf("Email sent with ID: %s\n", resp.Data.ID)

🌐 API Reference

All methods are thoroughly documented with links to the official API documentation:

For complete API documentation, visit docs.inbound.new.

⚑ Advanced Features

Custom HTTP Client
client, err := inbound.NewClient("your-api-key")
if err != nil {
    log.Fatal(err)
}

// Use custom HTTP client with timeout and retry logic
httpClient := &http.Client{
    Timeout: 30 * time.Second,
    Transport: &http.Transport{
        MaxIdleConns:       10,
        IdleConnTimeout:    90 * time.Second,
        DisableCompression: true,
    },
}

client.WithHTTPClient(httpClient)
Idempotency
// Use idempotency key to prevent duplicate sends
options := &inbound.IdempotencyOptions{
    IdempotencyKey: "unique-key-12345",
}

resp, err := client.Email().Send(ctx, emailParams, options)
Context with timeout
// Set timeout for operations
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

resp, err := client.Email().Send(ctx, emailParams, nil)

πŸ›  Development

Building
go build ./...
Testing
go test ./...
Running examples
cd examples
go run send-email/main.go

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Stop juggling email providers. Start building.

Documentation ΒΆ

Overview ΒΆ

Package inboundgo provides a Go client for the Inbound Email API.

The Inbound Email API allows you to send emails, manage domains, endpoints, and email addresses. This client provides a simple interface to interact with all the available endpoints.

Basic Usage:

client, err := inboundgo.NewClient("your-api-key")
if err != nil {
	log.Fatal(err)
}

// Send an email
resp, err := client.Email().Send(ctx, &inboundgo.PostEmailsRequest{
	From:    "sender@example.com",
	To:      "recipient@example.com",
	Subject: "Hello World",
	Text:    inboundgo.String("Hello from Go!"),
}, nil)

// List inbound emails
emails, err := client.Mail().List(ctx, nil)

// Manage domains
domain, err := client.Domain().Create(ctx, &inboundgo.PostDomainsRequest{
	Domain: "example.com",
})

For detailed API documentation, see: https://docs.inbound.new/api-reference

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func Bool ΒΆ

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func Int ΒΆ

func Int(v int) *int

Int returns a pointer to the int value passed in.

func String ΒΆ

func String(v string) *string

String returns a pointer to the string value passed in.

Types ΒΆ

type ApiResponse ΒΆ

type ApiResponse[T any] struct {
	Data  *T     `json:"data,omitempty"`
	Error string `json:"error,omitempty"`
}

Standard response pattern - { data, error }

type AttachmentData ΒΆ

type AttachmentData struct {
	Path        *string `json:"path,omitempty"`        // Remote file URL
	Content     *string `json:"content,omitempty"`     // Base64 encoded content
	Filename    string  `json:"filename"`              // Required display name
	ContentType *string `json:"contentType,omitempty"` // Optional MIME type
	ContentID   *string `json:"content_id,omitempty"`  // Content ID for embedding images in HTML (max 128 chars)
}

Enhanced attachment interface supporting both remote and base64 content

type AttachmentService ΒΆ

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

AttachmentService handles attachment operations

func NewAttachmentService ΒΆ

func NewAttachmentService(client *Inbound) *AttachmentService

NewAttachmentService creates a new attachment service

func (*AttachmentService) Download ΒΆ

func (s *AttachmentService) Download(ctx context.Context, emailID, filename string) ([]byte, error)

Download downloads an email attachment by email ID and filename

API Reference: https://docs.inbound.new/api-reference/attachments/download-attachment

type CatchAllEndpoint ΒΆ

type CatchAllEndpoint struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	IsActive bool   `json:"isActive"`
}

Domains API Types

type DNSRecord ΒΆ

type DNSRecord struct {
	Type       string  `json:"type"`
	Name       string  `json:"name"`
	Value      string  `json:"value"`
	IsVerified bool    `json:"isVerified,omitempty"`
	Status     string  `json:"status,omitempty"`
	Error      *string `json:"error,omitempty"`
}

type DeleteEmailAddressByIDResponse ΒΆ

type DeleteEmailAddressByIDResponse struct {
	Message string `json:"message"`
	Cleanup struct {
		EmailAddress   string `json:"emailAddress"`
		Domain         string `json:"domain"`
		SESRuleUpdated bool   `json:"sesRuleUpdated"`
	} `json:"cleanup"`
}

type DeleteEndpointByIDResponse ΒΆ

type DeleteEndpointByIDResponse struct {
	Message string `json:"message"`
	Cleanup struct {
		EmailAddressesUpdated int   `json:"emailAddressesUpdated"`
		DomainsUpdated        int   `json:"domainsUpdated"`
		GroupEmailsDeleted    int   `json:"groupEmailsDeleted"`
		DeliveriesDeleted     int   `json:"deliveriesDeleted"`
		EmailAddresses        []any `json:"emailAddresses"`
		Domains               []any `json:"domains"`
	} `json:"cleanup"`
}

type DeleteScheduledEmailResponse ΒΆ

type DeleteScheduledEmailResponse struct {
	ID          string `json:"id"`
	Status      string `json:"status"` // 'cancelled'
	CancelledAt string `json:"cancelled_at"`
}

type DeliveryStats ΒΆ

type DeliveryStats struct {
	Total        int     `json:"total"`
	Successful   int     `json:"successful"`
	Failed       int     `json:"failed"`
	LastDelivery *string `json:"lastDelivery"`
}

type DomainInfo ΒΆ

type DomainInfo struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Status string `json:"status"`
}

Email Addresses API Types

type DomainService ΒΆ

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

DomainService handles domain management

func NewDomainService ΒΆ

func NewDomainService(client *Inbound) *DomainService

NewDomainService creates a new domain service

func (*DomainService) CheckStatus ΒΆ

func (s *DomainService) CheckStatus(ctx context.Context, id string) (*ApiResponse[any], error)

CheckStatus checks domain verification status

func (*DomainService) Create ΒΆ

Create creates a new domain

API Reference: https://docs.inbound.new/api-reference/domains/create-domain

func (*DomainService) Delete ΒΆ

func (s *DomainService) Delete(ctx context.Context, id string) (*ApiResponse[any], error)

Delete deletes a domain

API Reference: https://docs.inbound.new/api-reference/domains/delete-domain

func (*DomainService) Get ΒΆ

Get gets a specific domain by ID

API Reference: https://docs.inbound.new/api-reference/domains/get-domain

func (*DomainService) GetDNSRecords ΒΆ

func (s *DomainService) GetDNSRecords(ctx context.Context, id string) (*ApiResponse[any], error)

GetDNSRecords gets DNS records required for domain verification

API Reference: https://docs.inbound.new/api-reference/domains/get-dns-records

func (*DomainService) List ΒΆ

List lists all domains

API Reference: https://docs.inbound.new/api-reference/domains/list-domains

func (*DomainService) Update ΒΆ

Update updates domain settings (catch-all configuration)

API Reference: https://docs.inbound.new/api-reference/domains/update-domain

func (*DomainService) Verify ΒΆ

func (s *DomainService) Verify(ctx context.Context, id string) (*ApiResponse[any], error)

Verify initiates domain verification

type DomainStats ΒΆ

type DomainStats struct {
	TotalEmailAddresses  int  `json:"totalEmailAddresses"`
	ActiveEmailAddresses int  `json:"activeEmailAddresses"`
	HasCatchAll          bool `json:"hasCatchAll"`
}

type DomainWithStats ΒΆ

type DomainWithStats struct {
	ID                 string             `json:"id"`
	Domain             string             `json:"domain"`
	Status             string             `json:"status"`
	CanReceiveEmails   bool               `json:"canReceiveEmails"`
	HasMXRecords       bool               `json:"hasMxRecords"`
	DomainProvider     *string            `json:"domainProvider"`
	ProviderConfidence *string            `json:"providerConfidence"`
	LastDNSCheck       *time.Time         `json:"lastDnsCheck"`
	LastSESCheck       *time.Time         `json:"lastSesCheck"`
	IsCatchAllEnabled  bool               `json:"isCatchAllEnabled"`
	CatchAllEndpointID *string            `json:"catchAllEndpointId"`
	ReceiveDMARCEmails bool               `json:"receiveDmarcEmails"`
	CreatedAt          time.Time          `json:"createdAt"`
	UpdatedAt          time.Time          `json:"updatedAt"`
	UserID             string             `json:"userId"`
	Stats              DomainStats        `json:"stats"`
	CatchAllEndpoint   *CatchAllEndpoint  `json:"catchAllEndpoint,omitempty"`
	VerificationCheck  *VerificationCheck `json:"verificationCheck,omitempty"`
}

type EmailAddressService ΒΆ

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

EmailAddressService handles email address management

func NewEmailAddressService ΒΆ

func NewEmailAddressService(client *Inbound) *EmailAddressService

NewEmailAddressService creates a new email address service

func (*EmailAddressService) Create ΒΆ

Create creates a new email address

API Reference: https://docs.inbound.new/api-reference/email-addresses/create-email-address

func (*EmailAddressService) Delete ΒΆ

Delete deletes an email address

API Reference: https://docs.inbound.new/api-reference/email-addresses/delete-email-address

func (*EmailAddressService) Get ΒΆ

Get gets a specific email address by ID

API Reference: https://docs.inbound.new/api-reference/email-addresses/get-email-address

type EmailAddressWithDomain ΒΆ

type EmailAddressWithDomain struct {
	ID                      string      `json:"id"`
	Address                 string      `json:"address"`
	DomainID                string      `json:"domainId"`
	WebhookID               *string     `json:"webhookId"`
	EndpointID              *string     `json:"endpointId"`
	IsActive                bool        `json:"isActive"`
	IsReceiptRuleConfigured bool        `json:"isReceiptRuleConfigured"`
	ReceiptRuleName         *string     `json:"receiptRuleName"`
	CreatedAt               time.Time   `json:"createdAt"`
	UpdatedAt               time.Time   `json:"updatedAt"`
	UserID                  string      `json:"userId"`
	Domain                  DomainInfo  `json:"domain"`
	Routing                 RoutingInfo `json:"routing"`
}

type EmailConfig ΒΆ

type EmailConfig struct {
	Email string `json:"email"`
}

type EmailGroupConfig ΒΆ

type EmailGroupConfig struct {
	Emails []string `json:"emails"`
}

type EmailItem ΒΆ

type EmailItem struct {
	ID              string     `json:"id"`
	EmailID         string     `json:"emailId"`
	MessageID       *string    `json:"messageId"`
	Subject         string     `json:"subject"`
	From            string     `json:"from"`
	FromName        *string    `json:"fromName"`
	Recipient       string     `json:"recipient"`
	Preview         string     `json:"preview"`
	ReceivedAt      time.Time  `json:"receivedAt"`
	IsRead          bool       `json:"isRead"`
	ReadAt          *time.Time `json:"readAt"`
	IsArchived      bool       `json:"isArchived"`
	ArchivedAt      *time.Time `json:"archivedAt"`
	HasAttachments  bool       `json:"hasAttachments"`
	AttachmentCount int        `json:"attachmentCount"`
	ParseSuccess    *bool      `json:"parseSuccess"`
	ParseError      *string    `json:"parseError"`
	CreatedAt       time.Time  `json:"createdAt"`
}

Mail API Types

type EmailService ΒΆ

type EmailService struct {
	Address *EmailAddressService
	// contains filtered or unexported fields
}

EmailService handles email operations (sending emails)

func NewEmailService ΒΆ

func NewEmailService(client *Inbound) *EmailService

NewEmailService creates a new email service

func (*EmailService) Cancel ΒΆ

Cancel cancels a scheduled email (only works if status is 'scheduled')

func (*EmailService) Get ΒΆ

Get retrieves a sent email by ID

API Reference: https://docs.inbound.new/api-reference/emails/get-email

func (*EmailService) GetScheduled ΒΆ

GetScheduled gets details of a specific scheduled email

func (*EmailService) ListScheduled ΒΆ

ListScheduled lists scheduled emails with filtering and pagination

API Reference: https://docs.inbound.new/api-reference/emails/list-scheduled-emails

func (*EmailService) Reply ΒΆ

Reply replies to an email by ID with optional attachments

API Reference: https://docs.inbound.new/api-reference/emails/reply-to-email

func (*EmailService) Schedule ΒΆ

Schedule schedules an email to be sent at a future time

Supports both ISO 8601 dates and natural language (e.g., "in 1 hour", "tomorrow at 9am").

API Reference: https://docs.inbound.new/api-reference/emails/schedule-email

func (*EmailService) Send ΒΆ

Send sends an email with optional attachments and idempotency options

This method supports both immediate sending and scheduled delivery. If params.ScheduledAt is set, the email will be scheduled for future delivery.

API Reference: https://docs.inbound.new/api-reference/emails/send-email

type EmailTag ΒΆ

type EmailTag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type EndpointService ΒΆ

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

EndpointService handles endpoint management

func NewEndpointService ΒΆ

func NewEndpointService(client *Inbound) *EndpointService

NewEndpointService creates a new endpoint service

func (*EndpointService) Create ΒΆ

Create creates a new endpoint

API Reference: https://docs.inbound.new/api-reference/endpoints/create-endpoint

func (*EndpointService) Delete ΒΆ

Delete deletes an endpoint

API Reference: https://docs.inbound.new/api-reference/endpoints/delete-endpoint

func (*EndpointService) Get ΒΆ

Get gets a specific endpoint by ID

API Reference: https://docs.inbound.new/api-reference/endpoints/get-endpoint

func (*EndpointService) List ΒΆ

List lists all endpoints

API Reference: https://docs.inbound.new/api-reference/endpoints/list-endpoints

func (*EndpointService) Test ΒΆ

func (s *EndpointService) Test(ctx context.Context, id string) (*ApiResponse[any], error)

Test tests endpoint connectivity

func (*EndpointService) Update ΒΆ

Update updates an endpoint

API Reference: https://docs.inbound.new/api-reference/endpoints/update-endpoint

type EndpointWithStats ΒΆ

type EndpointWithStats struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	Type          string        `json:"type"`   // 'webhook' | 'email' | 'email_group'
	Config        any           `json:"config"` // WebhookConfig | EmailConfig | EmailGroupConfig
	IsActive      bool          `json:"isActive"`
	Description   *string       `json:"description"`
	UserID        string        `json:"userId"`
	CreatedAt     time.Time     `json:"createdAt"`
	UpdatedAt     time.Time     `json:"updatedAt"`
	GroupEmails   []string      `json:"groupEmails"`
	DeliveryStats DeliveryStats `json:"deliveryStats"`
}

type GetDomainByIDResponse ΒΆ

type GetDomainByIDResponse struct {
	ID                 string            `json:"id"`
	Domain             string            `json:"domain"`
	Status             string            `json:"status"`
	CanReceiveEmails   bool              `json:"canReceiveEmails"`
	IsCatchAllEnabled  bool              `json:"isCatchAllEnabled"`
	CatchAllEndpointID *string           `json:"catchAllEndpointId"`
	Stats              DomainStats       `json:"stats"`
	CatchAllEndpoint   *CatchAllEndpoint `json:"catchAllEndpoint,omitempty"`
	CreatedAt          time.Time         `json:"createdAt"`
	UpdatedAt          time.Time         `json:"updatedAt"`
}

type GetDomainsRequest ΒΆ

type GetDomainsRequest struct {
	Limit      *int   `json:"limit,omitempty"`
	Offset     *int   `json:"offset,omitempty"`
	Status     string `json:"status,omitempty"`     // 'pending' | 'verified' | 'failed'
	CanReceive string `json:"canReceive,omitempty"` // 'true' | 'false'
	Check      string `json:"check,omitempty"`      // 'true' | 'false'
}

type GetDomainsResponse ΒΆ

type GetDomainsResponse struct {
	Data       []DomainWithStats `json:"data"`
	Pagination Pagination        `json:"pagination"`
	Meta       struct {
		TotalCount        int            `json:"totalCount"`
		VerifiedCount     int            `json:"verifiedCount"`
		WithCatchAllCount int            `json:"withCatchAllCount"`
		StatusBreakdown   map[string]int `json:"statusBreakdown"`
	} `json:"meta"`
}

type GetEmailAddressByIDResponse ΒΆ

type GetEmailAddressByIDResponse struct {
	ID                      string      `json:"id"`
	Address                 string      `json:"address"`
	DomainID                string      `json:"domainId"`
	EndpointID              *string     `json:"endpointId"`
	IsActive                bool        `json:"isActive"`
	IsReceiptRuleConfigured bool        `json:"isReceiptRuleConfigured"`
	Domain                  DomainInfo  `json:"domain"`
	Routing                 RoutingInfo `json:"routing"`
	CreatedAt               time.Time   `json:"createdAt"`
	UpdatedAt               time.Time   `json:"updatedAt"`
}

type GetEmailAddressesRequest ΒΆ

type GetEmailAddressesRequest struct {
	Limit                   *int   `json:"limit,omitempty"`
	Offset                  *int   `json:"offset,omitempty"`
	DomainID                string `json:"domainId,omitempty"`
	IsActive                string `json:"isActive,omitempty"`                // 'true' | 'false'
	IsReceiptRuleConfigured string `json:"isReceiptRuleConfigured,omitempty"` // 'true' | 'false'
}

type GetEmailAddressesResponse ΒΆ

type GetEmailAddressesResponse struct {
	Data       []EmailAddressWithDomain `json:"data"`
	Pagination Pagination               `json:"pagination"`
}

type GetEmailByIDResponse ΒΆ

type GetEmailByIDResponse struct {
	Object    string    `json:"object"`
	ID        string    `json:"id"`
	From      string    `json:"from"`
	To        []string  `json:"to"`
	CC        []string  `json:"cc"`
	BCC       []string  `json:"bcc"`
	ReplyTo   []string  `json:"reply_to"`
	Subject   string    `json:"subject"`
	Text      string    `json:"text"`
	HTML      string    `json:"html"`
	CreatedAt time.Time `json:"created_at"`
	LastEvent string    `json:"last_event"` // 'pending' | 'delivered' | 'failed'
}

type GetEndpointByIDResponse ΒΆ

type GetEndpointByIDResponse struct {
	ID               string        `json:"id"`
	Name             string        `json:"name"`
	Type             string        `json:"type"`
	Config           any           `json:"config"`
	IsActive         bool          `json:"isActive"`
	Description      *string       `json:"description"`
	DeliveryStats    DeliveryStats `json:"deliveryStats"`
	RecentDeliveries []any         `json:"recentDeliveries"`
	AssociatedEmails []any         `json:"associatedEmails"`
	CatchAllDomains  []any         `json:"catchAllDomains"`
	CreatedAt        time.Time     `json:"createdAt"`
	UpdatedAt        time.Time     `json:"updatedAt"`
}

type GetEndpointsRequest ΒΆ

type GetEndpointsRequest struct {
	Limit  *int   `json:"limit,omitempty"`
	Offset *int   `json:"offset,omitempty"`
	Type   string `json:"type,omitempty"`   // 'webhook' | 'email' | 'email_group'
	Active string `json:"active,omitempty"` // 'true' | 'false'
}

type GetEndpointsResponse ΒΆ

type GetEndpointsResponse struct {
	Data       []EndpointWithStats `json:"data"`
	Pagination Pagination          `json:"pagination"`
}

type GetMailByIDResponse ΒΆ

type GetMailByIDResponse struct {
	ID          string    `json:"id"`
	EmailID     string    `json:"emailId"`
	Subject     string    `json:"subject"`
	From        string    `json:"from"`
	To          string    `json:"to"`
	TextBody    string    `json:"textBody"`
	HTMLBody    string    `json:"htmlBody"`
	ReceivedAt  time.Time `json:"receivedAt"`
	Attachments []any     `json:"attachments"`
}

type GetMailRequest ΒΆ

type GetMailRequest struct {
	Limit           *int   `json:"limit,omitempty"`
	Offset          *int   `json:"offset,omitempty"`
	Search          string `json:"search,omitempty"`
	Status          string `json:"status,omitempty"` // 'all' | 'processed' | 'failed'
	Domain          string `json:"domain,omitempty"`
	TimeRange       string `json:"timeRange,omitempty"` // '24h' | '7d' | '30d' | '90d'
	IncludeArchived *bool  `json:"includeArchived,omitempty"`
	EmailAddress    string `json:"emailAddress,omitempty"`
	EmailID         string `json:"emailId,omitempty"`
}

type GetMailResponse ΒΆ

type GetMailResponse struct {
	Emails     []EmailItem `json:"emails"`
	Pagination Pagination  `json:"pagination"`
}

type GetScheduledEmailResponse ΒΆ

type GetScheduledEmailResponse struct {
	ID          string            `json:"id"`
	From        string            `json:"from"`
	To          []string          `json:"to"`
	CC          []string          `json:"cc,omitempty"`
	BCC         []string          `json:"bcc,omitempty"`
	ReplyTo     []string          `json:"replyTo,omitempty"`
	Subject     string            `json:"subject"`
	Text        *string           `json:"text,omitempty"`
	HTML        *string           `json:"html,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	Attachments []AttachmentData  `json:"attachments,omitempty"`
	Tags        []EmailTag        `json:"tags,omitempty"`
	ScheduledAt string            `json:"scheduled_at"`
	Timezone    string            `json:"timezone"`
	Status      string            `json:"status"`
	Attempts    int               `json:"attempts"`
	MaxAttempts int               `json:"max_attempts"`
	NextRetryAt *string           `json:"next_retry_at,omitempty"`
	LastError   *string           `json:"last_error,omitempty"`
	CreatedAt   string            `json:"created_at"`
	UpdatedAt   string            `json:"updated_at"`
	SentAt      *string           `json:"sent_at,omitempty"`
	SentEmailID *string           `json:"sent_email_id,omitempty"`
}

type GetScheduledEmailsRequest ΒΆ

type GetScheduledEmailsRequest struct {
	Limit  *int   `json:"limit,omitempty"`
	Offset *int   `json:"offset,omitempty"`
	Status string `json:"status,omitempty"` // Filter by status
}

type GetScheduledEmailsResponse ΒΆ

type GetScheduledEmailsResponse struct {
	Data       []ScheduledEmailItem `json:"data"`
	Pagination Pagination           `json:"pagination"`
}

type GetThreadByIDResponse ΒΆ

type GetThreadByIDResponse struct {
	Thread     ThreadMetadata  `json:"thread"`
	Messages   []ThreadMessage `json:"messages"`
	TotalCount int             `json:"totalCount"`
}

type GetThreadStatsResponse ΒΆ

type GetThreadStatsResponse struct {
	TotalThreads             int                  `json:"totalThreads"`
	TotalMessages            int                  `json:"totalMessages"`
	AverageMessagesPerThread float64              `json:"averageMessagesPerThread"`
	MostActiveThread         *MostActiveThread    `json:"mostActiveThread"`
	RecentActivity           ThreadRecentActivity `json:"recentActivity"`
	Distribution             ThreadDistribution   `json:"distribution"`
	UnreadStats              ThreadUnreadStats    `json:"unreadStats"`
}

type GetThreadsFilters ΒΆ

type GetThreadsFilters struct {
	Search       *string `json:"search,omitempty"`
	UnreadOnly   *bool   `json:"unreadOnly,omitempty"`
	ArchivedOnly *bool   `json:"archivedOnly,omitempty"`
	Domain       *string `json:"domain,omitempty"`
	Address      *string `json:"address,omitempty"`
}

type GetThreadsRequest ΒΆ

type GetThreadsRequest struct {
	Limit    *int   `json:"limit,omitempty"`
	Offset   *int   `json:"offset,omitempty"`
	Search   string `json:"search,omitempty"`
	Unread   *bool  `json:"unread,omitempty"`
	Archived *bool  `json:"archived,omitempty"`
	Domain   string `json:"domain,omitempty"`
	Address  string `json:"address,omitempty"`
}

type GetThreadsResponse ΒΆ

type GetThreadsResponse struct {
	Threads    []ThreadSummary   `json:"threads"`
	Pagination Pagination        `json:"pagination"`
	Filters    GetThreadsFilters `json:"filters"`
}

type IdempotencyOptions ΒΆ

type IdempotencyOptions struct {
	IdempotencyKey string `json:"idempotencyKey,omitempty"`
}

Idempotency options for email sending

type Inbound ΒΆ

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

Inbound is the main client for the Inbound Email SDK

func NewClient ΒΆ

func NewClient(apiKey string, baseURL ...string) (*Inbound, error)

NewClient creates a new Inbound Email client

func (*Inbound) Attachment ΒΆ

func (c *Inbound) Attachment() *AttachmentService

func (*Inbound) CreateForwarder ΒΆ

func (c *Inbound) CreateForwarder(ctx context.Context, from, to string) (*ApiResponse[PostEndpointsResponse], error)

CreateForwarder creates a simple email forwarding setup

func (*Inbound) Domain ΒΆ

func (c *Inbound) Domain() *DomainService

func (*Inbound) Email ΒΆ

func (c *Inbound) Email() *EmailService

func (*Inbound) Endpoint ΒΆ

func (c *Inbound) Endpoint() *EndpointService

func (*Inbound) Mail ΒΆ

func (c *Inbound) Mail() *MailService

Add service properties to the main client

func (*Inbound) QuickReply ΒΆ

func (c *Inbound) QuickReply(ctx context.Context, emailID, message, from string, options *IdempotencyOptions) (*ApiResponse[PostEmailReplyResponse], error)

QuickReply provides a quick text reply to an email

func (*Inbound) ScheduleReminder ΒΆ

func (c *Inbound) ScheduleReminder(ctx context.Context, to, subject, when, from string, options *IdempotencyOptions) (*ApiResponse[PostScheduleEmailResponse], error)

ScheduleReminder creates a quick scheduled email reminder

func (*Inbound) SetupDomain ΒΆ

func (c *Inbound) SetupDomain(ctx context.Context, domain string, webhookURL *string) (*ApiResponse[any], error)

SetupDomain provides one-step domain setup with optional webhook

func (*Inbound) Thread ΒΆ

func (c *Inbound) Thread() *ThreadService

func (*Inbound) WithHTTPClient ΒΆ

func (c *Inbound) WithHTTPClient(client *http.Client) *Inbound

WithHTTPClient sets a custom HTTP client

type InboundEmailConfig ΒΆ

type InboundEmailConfig struct {
	ApiKey  string `json:"apiKey"`
	BaseUrl string `json:"baseUrl,omitempty"`
}

Base configuration

type MailService ΒΆ

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

MailService handles mail operations (inbound emails)

func NewMailService ΒΆ

func NewMailService(client *Inbound) *MailService

NewMailService creates a new mail service

func (*MailService) Archive ΒΆ

func (s *MailService) Archive(ctx context.Context, id string) (*ApiResponse[any], error)

Archive archives an email

func (*MailService) Bulk ΒΆ

func (s *MailService) Bulk(ctx context.Context, emailIDs []string, updates map[string]any) (*ApiResponse[any], error)

Bulk performs bulk operations on multiple emails

func (*MailService) Get ΒΆ

Get retrieves a specific email by ID

API Reference: https://docs.inbound.new/api-reference/mail/get-email

func (*MailService) List ΒΆ

List retrieves all emails in the mailbox

API Reference: https://docs.inbound.new/api-reference/mail/list-emails

func (*MailService) MarkRead ΒΆ

func (s *MailService) MarkRead(ctx context.Context, id string) (*ApiResponse[any], error)

MarkRead marks an email as read

func (*MailService) MarkUnread ΒΆ

func (s *MailService) MarkUnread(ctx context.Context, id string) (*ApiResponse[any], error)

MarkUnread marks an email as unread

func (*MailService) Reply ΒΆ

Reply replies to an email

func (*MailService) Thread ΒΆ

func (s *MailService) Thread(ctx context.Context, id string) (*ApiResponse[any], error)

Thread retrieves email thread/conversation by email ID

func (*MailService) Unarchive ΒΆ

func (s *MailService) Unarchive(ctx context.Context, id string) (*ApiResponse[any], error)

Unarchive unarchives an email

type MostActiveThread ΒΆ

type MostActiveThread struct {
	ThreadID      string  `json:"threadId"`
	MessageCount  int     `json:"messageCount"`
	Subject       *string `json:"subject"`
	LastMessageAt string  `json:"lastMessageAt"`
}

type Pagination ΒΆ

type Pagination struct {
	Limit   int  `json:"limit"`
	Offset  int  `json:"offset"`
	Total   int  `json:"total"`
	HasMore bool `json:"hasMore,omitempty"`
}

Pagination interface

type PostDomainsRequest ΒΆ

type PostDomainsRequest struct {
	Domain string `json:"domain"`
}

type PostDomainsResponse ΒΆ

type PostDomainsResponse struct {
	ID         string      `json:"id"`
	Domain     string      `json:"domain"`
	Status     string      `json:"status"`
	DNSRecords []DNSRecord `json:"dnsRecords"`
	CreatedAt  time.Time   `json:"createdAt"`
}

type PostEmailAddressesRequest ΒΆ

type PostEmailAddressesRequest struct {
	Address    string  `json:"address"`
	DomainID   string  `json:"domainId"`
	EndpointID *string `json:"endpointId,omitempty"`
	WebhookID  *string `json:"webhookId,omitempty"`
	IsActive   *bool   `json:"isActive,omitempty"`
}

type PostEmailAddressesResponse ΒΆ

type PostEmailAddressesResponse struct {
	ID         string      `json:"id"`
	Address    string      `json:"address"`
	DomainID   string      `json:"domainId"`
	EndpointID *string     `json:"endpointId"`
	IsActive   bool        `json:"isActive"`
	Domain     DomainInfo  `json:"domain"`
	Routing    RoutingInfo `json:"routing"`
	CreatedAt  time.Time   `json:"createdAt"`
}

type PostEmailReplyRequest ΒΆ

type PostEmailReplyRequest struct {
	From            string            `json:"from"`
	FromName        *string           `json:"from_name,omitempty"`
	To              any               `json:"to,omitempty"`  // string or []string
	CC              any               `json:"cc,omitempty"`  // string or []string
	BCC             any               `json:"bcc,omitempty"` // string or []string
	Subject         *string           `json:"subject,omitempty"`
	Text            *string           `json:"text,omitempty"`
	HTML            *string           `json:"html,omitempty"`
	ReplyTo         any               `json:"replyTo,omitempty"` // string or []string
	Headers         map[string]string `json:"headers,omitempty"`
	Attachments     []AttachmentData  `json:"attachments,omitempty"`
	Tags            []EmailTag        `json:"tags,omitempty"`
	IncludeOriginal *bool             `json:"includeOriginal,omitempty"`
	ReplyAll        *bool             `json:"replyAll,omitempty"`
	Simple          *bool             `json:"simple,omitempty"`
}

Reply API Types

type PostEmailReplyResponse ΒΆ

type PostEmailReplyResponse struct {
	ID                string  `json:"id"`
	MessageID         string  `json:"messageId"`
	AWSMessageID      *string `json:"awsMessageId,omitempty"`
	RepliedToEmailID  string  `json:"repliedToEmailId"`
	RepliedToThreadID *string `json:"repliedToThreadId,omitempty"`
	IsThreadReply     bool    `json:"isThreadReply"`
}

type PostEmailsRequest ΒΆ

type PostEmailsRequest struct {
	From        string            `json:"from"`
	To          any               `json:"to"` // string or []string
	Subject     string            `json:"subject"`
	BCC         any               `json:"bcc,omitempty"`     // string or []string
	CC          any               `json:"cc,omitempty"`      // string or []string
	ReplyTo     any               `json:"replyTo,omitempty"` // string or []string
	HTML        *string           `json:"html,omitempty"`
	Text        *string           `json:"text,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	Attachments []AttachmentData  `json:"attachments,omitempty"`
	Tags        []EmailTag        `json:"tags,omitempty"`
	ScheduledAt *string           `json:"scheduled_at,omitempty"` // Schedule email to be sent later
	Timezone    *string           `json:"timezone,omitempty"`     // User's timezone for natural language parsing
}

Emails API Types (for sending)

type PostEmailsResponse ΒΆ

type PostEmailsResponse struct {
	ID          string  `json:"id"`
	MessageID   *string `json:"messageId,omitempty"`    // AWS SES Message ID
	ScheduledAt *string `json:"scheduled_at,omitempty"` // ISO 8601 timestamp
	Status      *string `json:"status,omitempty"`       // 'sent' | 'scheduled'
	Timezone    *string `json:"timezone,omitempty"`     // Timezone used for scheduling
}

type PostEndpointsRequest ΒΆ

type PostEndpointsRequest struct {
	Name        string  `json:"name"`
	Type        string  `json:"type"` // 'webhook' | 'email' | 'email_group'
	Description *string `json:"description,omitempty"`
	Config      any     `json:"config"` // WebhookConfig | EmailConfig | EmailGroupConfig
}

type PostEndpointsResponse ΒΆ

type PostEndpointsResponse struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Type        string    `json:"type"`
	Config      any       `json:"config"`
	IsActive    bool      `json:"isActive"`
	Description *string   `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
}

type PostMailRequest ΒΆ

type PostMailRequest struct {
	EmailID  string  `json:"emailId"`
	To       string  `json:"to"`
	Subject  string  `json:"subject"`
	TextBody string  `json:"textBody"`
	HTMLBody *string `json:"htmlBody,omitempty"`
}

type PostMailResponse ΒΆ

type PostMailResponse struct {
	Message string `json:"message"`
}

type PostScheduleEmailRequest ΒΆ

type PostScheduleEmailRequest struct {
	From        string            `json:"from"`
	To          any               `json:"to"` // string or []string
	Subject     string            `json:"subject"`
	BCC         any               `json:"bcc,omitempty"`     // string or []string
	CC          any               `json:"cc,omitempty"`      // string or []string
	ReplyTo     any               `json:"replyTo,omitempty"` // string or []string
	HTML        *string           `json:"html,omitempty"`
	Text        *string           `json:"text,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	Attachments []AttachmentData  `json:"attachments,omitempty"`
	Tags        []EmailTag        `json:"tags,omitempty"`
	ScheduledAt string            `json:"scheduled_at"`       // ISO 8601 or natural language
	Timezone    *string           `json:"timezone,omitempty"` // User's timezone for natural language parsing
}

Email Scheduling API Types

type PostScheduleEmailResponse ΒΆ

type PostScheduleEmailResponse struct {
	ID          string `json:"id"`
	ScheduledAt string `json:"scheduled_at"` // Normalized ISO 8601 timestamp
	Status      string `json:"status"`       // 'scheduled'
	Timezone    string `json:"timezone"`
}

type PostThreadActionsRequest ΒΆ

type PostThreadActionsRequest struct {
	Action string `json:"action"` // 'mark_as_read' | 'mark_as_unread' | 'archive' | 'unarchive'
}

type PostThreadActionsResponse ΒΆ

type PostThreadActionsResponse struct {
	Success          bool   `json:"success"`
	Action           string `json:"action"`
	ThreadID         string `json:"threadId"`
	AffectedMessages int    `json:"affectedMessages"`
	Message          string `json:"message"`
}

type PutDomainByIDRequest ΒΆ

type PutDomainByIDRequest struct {
	IsCatchAllEnabled  bool    `json:"isCatchAllEnabled"`
	CatchAllEndpointID *string `json:"catchAllEndpointId"`
}

type PutDomainByIDResponse ΒΆ

type PutDomainByIDResponse struct {
	ID                 string            `json:"id"`
	Domain             string            `json:"domain"`
	IsCatchAllEnabled  bool              `json:"isCatchAllEnabled"`
	CatchAllEndpointID *string           `json:"catchAllEndpointId"`
	CatchAllEndpoint   *CatchAllEndpoint `json:"catchAllEndpoint,omitempty"`
	UpdatedAt          time.Time         `json:"updatedAt"`
}

type PutEmailAddressByIDRequest ΒΆ

type PutEmailAddressByIDRequest struct {
	IsActive   *bool   `json:"isActive,omitempty"`
	EndpointID *string `json:"endpointId,omitempty"`
	WebhookID  *string `json:"webhookId,omitempty"`
}

type PutEmailAddressByIDResponse ΒΆ

type PutEmailAddressByIDResponse struct {
	ID        string      `json:"id"`
	Address   string      `json:"address"`
	IsActive  bool        `json:"isActive"`
	Domain    DomainInfo  `json:"domain"`
	Routing   RoutingInfo `json:"routing"`
	UpdatedAt time.Time   `json:"updatedAt"`
}

type PutEndpointByIDRequest ΒΆ

type PutEndpointByIDRequest struct {
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
	IsActive    *bool   `json:"isActive,omitempty"`
	Config      any     `json:"config,omitempty"`
}

type PutEndpointByIDResponse ΒΆ

type PutEndpointByIDResponse struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description *string   `json:"description"`
	IsActive    bool      `json:"isActive"`
	Config      any       `json:"config"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type RoutingInfo ΒΆ

type RoutingInfo struct {
	Type     string  `json:"type"` // 'webhook' | 'endpoint' | 'none'
	ID       *string `json:"id"`
	Name     *string `json:"name"`
	Config   any     `json:"config,omitempty"`
	IsActive bool    `json:"isActive"`
}

type ScheduledEmailItem ΒΆ

type ScheduledEmailItem struct {
	ID          string   `json:"id"`
	From        string   `json:"from"`
	To          []string `json:"to"`
	Subject     string   `json:"subject"`
	ScheduledAt string   `json:"scheduled_at"`
	Status      string   `json:"status"`
	Timezone    string   `json:"timezone"`
	CreatedAt   string   `json:"created_at"`
	Attempts    int      `json:"attempts"`
	LastError   *string  `json:"last_error,omitempty"`
}

type ThreadAttachment ΒΆ

type ThreadAttachment struct {
	Filename           string `json:"filename"`
	ContentType        string `json:"contentType"`
	Size               int    `json:"size"`
	ContentID          string `json:"contentId"`
	ContentDisposition string `json:"contentDisposition"`
}

type ThreadDistribution ΒΆ

type ThreadDistribution struct {
	SingleMessageThreads int `json:"singleMessageThreads"`
	ShortThreads         int `json:"shortThreads"`
	MediumThreads        int `json:"mediumThreads"`
	LongThreads          int `json:"longThreads"`
}

type ThreadLatestMessage ΒΆ

type ThreadLatestMessage struct {
	ID             string  `json:"id"`
	Type           string  `json:"type"` // 'inbound' | 'outbound'
	Subject        *string `json:"subject"`
	FromText       string  `json:"fromText"`
	TextPreview    *string `json:"textPreview"`
	IsRead         bool    `json:"isRead"`
	HasAttachments bool    `json:"hasAttachments"`
	Date           *string `json:"date"`
}

Threads API Types

type ThreadMessage ΒΆ

type ThreadMessage struct {
	ID             string             `json:"id"`
	MessageID      *string            `json:"messageId"`
	Type           string             `json:"type"` // 'inbound' | 'outbound'
	ThreadPosition int                `json:"threadPosition"`
	Subject        *string            `json:"subject"`
	TextBody       *string            `json:"textBody"`
	HTMLBody       *string            `json:"htmlBody"`
	From           string             `json:"from"`
	FromName       *string            `json:"fromName"`
	FromAddress    *string            `json:"fromAddress"`
	To             []string           `json:"to"`
	CC             []string           `json:"cc"`
	BCC            []string           `json:"bcc"`
	Date           *string            `json:"date"`
	ReceivedAt     *string            `json:"receivedAt"`
	SentAt         *string            `json:"sentAt"`
	IsRead         bool               `json:"isRead"`
	ReadAt         *string            `json:"readAt"`
	HasAttachments bool               `json:"hasAttachments"`
	Attachments    []ThreadAttachment `json:"attachments"`
	InReplyTo      *string            `json:"inReplyTo"`
	References     []string           `json:"references"`
	Headers        map[string]any     `json:"headers"`
	Tags           []EmailTag         `json:"tags,omitempty"`
	Status         *string            `json:"status,omitempty"`
	FailureReason  *string            `json:"failureReason,omitempty"`
}

type ThreadMetadata ΒΆ

type ThreadMetadata struct {
	ID                string   `json:"id"`
	RootMessageID     string   `json:"rootMessageId"`
	NormalizedSubject *string  `json:"normalizedSubject"`
	ParticipantEmails []string `json:"participantEmails"`
	MessageCount      int      `json:"messageCount"`
	LastMessageAt     string   `json:"lastMessageAt"`
	CreatedAt         string   `json:"createdAt"`
	UpdatedAt         string   `json:"updatedAt"`
}

type ThreadRecentActivity ΒΆ

type ThreadRecentActivity struct {
	ThreadsToday     int `json:"threadsToday"`
	MessagesToday    int `json:"messagesToday"`
	ThreadsThisWeek  int `json:"threadsThisWeek"`
	MessagesThisWeek int `json:"messagesThisWeek"`
}

type ThreadService ΒΆ

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

ThreadService handles thread management

func NewThreadService ΒΆ

func NewThreadService(client *Inbound) *ThreadService

NewThreadService creates a new thread service

func (*ThreadService) Archive ΒΆ

Archive archives a thread

func (*ThreadService) Get ΒΆ

Get retrieves a specific thread by ID with all messages

API Reference: https://docs.inbound.new/api-reference/threads/get-thread

func (*ThreadService) List ΒΆ

List retrieves all email threads with optional filtering

API Reference: https://docs.inbound.new/api-reference/threads/list-threads

func (*ThreadService) MarkAsRead ΒΆ

MarkAsRead marks all messages in a thread as read

func (*ThreadService) MarkAsUnread ΒΆ

MarkAsUnread marks all messages in a thread as unread

func (*ThreadService) PerformAction ΒΆ

PerformAction performs an action on a thread (mark as read, archive, etc.)

API Reference: https://docs.inbound.new/api-reference/threads/thread-actions

func (*ThreadService) Stats ΒΆ

Stats retrieves statistics about all threads

API Reference: https://docs.inbound.new/api-reference/threads/thread-stats

func (*ThreadService) Unarchive ΒΆ

Unarchive unarchives a thread

type ThreadSummary ΒΆ

type ThreadSummary struct {
	ID                string               `json:"id"`
	RootMessageID     string               `json:"rootMessageId"`
	NormalizedSubject *string              `json:"normalizedSubject"`
	ParticipantEmails []string             `json:"participantEmails"`
	MessageCount      int                  `json:"messageCount"`
	LastMessageAt     string               `json:"lastMessageAt"`
	CreatedAt         string               `json:"createdAt"`
	HasUnread         bool                 `json:"hasUnread"`
	IsArchived        bool                 `json:"isArchived"`
	LatestMessage     *ThreadLatestMessage `json:"latestMessage,omitempty"`
}

type ThreadUnreadStats ΒΆ

type ThreadUnreadStats struct {
	UnreadThreads  int `json:"unreadThreads"`
	UnreadMessages int `json:"unreadMessages"`
}

type VerificationCheck ΒΆ

type VerificationCheck struct {
	DNSRecords      []DNSRecord `json:"dnsRecords,omitempty"`
	SESStatus       string      `json:"sesStatus,omitempty"`
	IsFullyVerified bool        `json:"isFullyVerified,omitempty"`
	LastChecked     string      `json:"lastChecked,omitempty"`
}

type WebhookAddress ΒΆ

type WebhookAddress struct {
	Name    *string `json:"name"`
	Address string  `json:"address"`
}

type WebhookAddressGroup ΒΆ

type WebhookAddressGroup struct {
	Text      string           `json:"text"`
	Addresses []WebhookAddress `json:"addresses"`
}

type WebhookAttachment ΒΆ

type WebhookAttachment struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	ContentID   string `json:"contentId"`
	URL         string `json:"url"`
	DownloadUrl string `json:"downloadUrl"`
}

type WebhookCleanedContent ΒΆ

type WebhookCleanedContent struct {
	HTML        string              `json:"html"`
	Text        string              `json:"text"`
	HasHTML     bool                `json:"hasHtml"`
	HasText     bool                `json:"hasText"`
	Attachments []WebhookAttachment `json:"attachments"`
	Headers     map[string]any      `json:"headers"`
}

type WebhookConfig ΒΆ

type WebhookConfig struct {
	URL           string            `json:"url"`
	Timeout       int               `json:"timeout"`
	RetryAttempts int               `json:"retryAttempts"`
	Headers       map[string]string `json:"headers,omitempty"`
}

Endpoints API Types

type WebhookEmailData ΒΆ

type WebhookEmailData struct {
	ID             string                 `json:"id"`
	MessageID      string                 `json:"messageId"`
	From           WebhookAddressGroup    `json:"from"`
	To             WebhookAddressGroup    `json:"to"`
	Recipient      string                 `json:"recipient"`
	Subject        string                 `json:"subject"`
	ReceivedAt     string                 `json:"receivedAt"`
	ParsedData     WebhookParsedData      `json:"parsedData"`
	CleanedContent *WebhookCleanedContent `json:"cleanedContent,omitempty"`
}

type WebhookEndpointRef ΒΆ

type WebhookEndpointRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type WebhookParsedData ΒΆ

type WebhookParsedData struct {
	MessageID   string               `json:"messageId"`
	Date        any                  `json:"date"` // Can be string or Date object
	Subject     string               `json:"subject"`
	From        WebhookAddressGroup  `json:"from"`
	To          WebhookAddressGroup  `json:"to"`
	Cc          *WebhookAddressGroup `json:"cc"`
	Bcc         *WebhookAddressGroup `json:"bcc"`
	ReplyTo     *WebhookAddressGroup `json:"replyTo"`
	InReplyTo   *string              `json:"inReplyTo,omitempty"`
	References  *string              `json:"references,omitempty"`
	TextBody    string               `json:"textBody"`
	HTMLBody    string               `json:"htmlBody"`
	Attachments []WebhookAttachment  `json:"attachments"`
	Headers     map[string]any       `json:"headers"`
	Priority    *string              `json:"priority,omitempty"`
}

type WebhookPayload ΒΆ

type WebhookPayload struct {
	Event     string              `json:"event"`
	Timestamp string              `json:"timestamp"`
	Email     WebhookEmailData    `json:"email"`
	Endpoint  *WebhookEndpointRef `json:"endpoint,omitempty"`
}

Webhook Payload Types - for incoming email.received webhooks

func ParseWebhookPayload ΒΆ

func ParseWebhookPayload(reader io.Reader) (*WebhookPayload, error)

ParseWebhookPayload parses an incoming webhook payload into the WebhookPayload struct

func (*WebhookPayload) GetFromAddress ΒΆ

func (w *WebhookPayload) GetFromAddress() string

GetFromAddress extracts the properly formatted from address from the webhook

func (*WebhookPayload) GetHeaders ΒΆ

func (w *WebhookPayload) GetHeaders() map[string][]string

GetHeaders converts the headers from the webhook format to a standard map[string][]string format

func (*WebhookPayload) GetToAddress ΒΆ

func (w *WebhookPayload) GetToAddress() string

GetToAddress extracts the properly formatted to address from the webhook

Jump to

Keyboard shortcuts

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