models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeSuccess             = 0
	ErrorCodeInvalidEmail        = 300
	ErrorCodeSenderNotFound      = 400
	ErrorCodeUnauthorized        = 401
	ErrorCodeInactiveRecipient   = 402
	ErrorCodeInvalidJSON         = 405
	ErrorCodeInactiveServer      = 406
	ErrorCodeJSONRequired        = 409
	ErrorCodeBatchLimitExceeded  = 410
	ErrorCodeForbiddenAttachment = 411
	ErrorCodeRateLimitExceeded   = 429
	ErrorCodeInternalServerError = 500
	ErrorCodeServiceUnavailable  = 503
)

Common error codes

View Source
const (
	MsgSuccess             = "OK"
	MsgInvalidEmail        = "Invalid email request"
	MsgSenderNotFound      = "Sender signature not found"
	MsgUnauthorized        = "Unauthorized: please provide valid API token"
	MsgInactiveRecipient   = "Inactive recipient"
	MsgInvalidJSON         = "Invalid JSON"
	MsgInactiveServer      = "Inactive server"
	MsgJSONRequired        = "JSON content type required"
	MsgBatchLimitExceeded  = "Too many messages in batch (max 500)"
	MsgForbiddenAttachment = "Forbidden attachment type"
	MsgRateLimitExceeded   = "Rate limit exceeded"
	MsgInternalServerError = "Internal server error"
	MsgServiceUnavailable  = "Service unavailable"
)

Error messages

Variables

This section is empty.

Functions

func WriteError

func WriteError(w http.ResponseWriter, code int, message string)

WriteError writes a PostmarkApp-formatted error response

Types

type Attachment

type Attachment struct {
	Name        string `json:"Name"`
	Content     string `json:"Content"` // Base64-encoded
	ContentType string `json:"ContentType"`
	ContentID   string `json:"ContentID,omitempty"`
}

Attachment represents an email attachment

type BatchEmailRequest

type BatchEmailRequest []EmailRequest

BatchEmailRequest represents a batch email send request

type BatchEmailResponse

type BatchEmailResponse []EmailResponse

BatchEmailResponse represents a batch email send response

type CreateTemplateRequest

type CreateTemplateRequest struct {
	Name           string `json:"Name"`
	Alias          string `json:"Alias,omitempty"`
	Subject        string `json:"Subject,omitempty"`
	HtmlBody       string `json:"HtmlBody,omitempty"`
	TextBody       string `json:"TextBody,omitempty"`
	TemplateType   string `json:"TemplateType,omitempty"`
	LayoutTemplate *int   `json:"LayoutTemplate,omitempty"`
}

CreateTemplateRequest represents a template creation request

type CreateWebhookRequest

type CreateWebhookRequest struct {
	URL           string          `json:"Url"`
	MessageStream string          `json:"MessageStream,omitempty"`
	HttpAuth      *HttpAuth       `json:"HttpAuth,omitempty"`
	HttpHeaders   []Header        `json:"HttpHeaders,omitempty"`
	Triggers      WebhookTriggers `json:"Triggers"`
}

CreateWebhookRequest represents a webhook creation request

type EmailRequest

type EmailRequest struct {
	From          string            `json:"From"`
	To            string            `json:"To"`
	Cc            string            `json:"Cc,omitempty"`
	Bcc           string            `json:"Bcc,omitempty"`
	Subject       string            `json:"Subject"`
	Tag           string            `json:"Tag,omitempty"`
	HtmlBody      string            `json:"HtmlBody,omitempty"`
	TextBody      string            `json:"TextBody,omitempty"`
	ReplyTo       string            `json:"ReplyTo,omitempty"`
	Headers       []Header          `json:"Headers,omitempty"`
	TrackOpens    bool              `json:"TrackOpens,omitempty"`
	TrackLinks    string            `json:"TrackLinks,omitempty"` // None, HtmlOnly, HtmlAndText, TextOnly
	Attachments   []Attachment      `json:"Attachments,omitempty"`
	Metadata      map[string]string `json:"Metadata,omitempty"`
	MessageStream string            `json:"MessageStream,omitempty"`
}

EmailRequest represents a single email send request

type EmailResponse

type EmailResponse struct {
	To          string    `json:"To"`
	SubmittedAt time.Time `json:"SubmittedAt"`
	MessageID   string    `json:"MessageID"`
	ErrorCode   int       `json:"ErrorCode"`
	Message     string    `json:"Message"`
}

EmailResponse represents a successful email send response

type Header struct {
	Name  string `json:"Name"`
	Value string `json:"Value"`
}

Header represents a custom email header

type HttpAuth

type HttpAuth struct {
	Username string `json:"Username"`
	Password string `json:"Password"`
}

HttpAuth represents HTTP authentication for webhooks

type PostmarkError

type PostmarkError struct {
	ErrorCode int    `json:"ErrorCode"`
	Message   string `json:"Message"`
}

PostmarkError represents an error in PostmarkApp format

func (*PostmarkError) Error

func (e *PostmarkError) Error() string

Error implements the error interface

type Server

type Server struct {
	ID                         int       `json:"ID,omitempty"`
	Name                       string    `json:"Name"`
	APIToken                   string    `json:"ApiToken,omitempty"` // Not returned in responses for security
	Color                      string    `json:"Color,omitempty"`
	SmtpApiActivated           bool      `json:"SmtpApiActivated,omitempty"`
	RawEmailEnabled            bool      `json:"RawEmailEnabled,omitempty"`
	ServerLink                 string    `json:"ServerLink,omitempty"`
	InboundAddress             string    `json:"InboundAddress,omitempty"`
	InboundHookUrl             string    `json:"InboundHookUrl,omitempty"`
	BounceHookUrl              string    `json:"BounceHookUrl,omitempty"`
	OpenHookUrl                string    `json:"OpenHookUrl,omitempty"`
	PostFirstOpenOnly          bool      `json:"PostFirstOpenOnly,omitempty"`
	TrackOpens                 bool      `json:"TrackOpens"`
	TrackLinks                 string    `json:"TrackLinks"` // None, HtmlOnly, HtmlAndText, TextOnly
	IncludeBounceContentInHook bool      `json:"IncludeBounceContentInHook,omitempty"`
	EnableSmtpApiErrorHooks    bool      `json:"EnableSmtpApiErrorHooks,omitempty"`
	DeliveryHookUrl            string    `json:"DeliveryHookUrl,omitempty"`
	CreatedAt                  time.Time `json:"CreatedAt,omitempty"`
	UpdatedAt                  time.Time `json:"UpdatedAt,omitempty"`
}

Server represents a PostmarkApp server (API token group)

type Template

type Template struct {
	TemplateID     int       `json:"TemplateId"`
	ServerID       int       `json:"AssociatedServerId"`
	Name           string    `json:"Name"`
	Alias          string    `json:"Alias,omitempty"`
	Subject        string    `json:"Subject,omitempty"`
	HtmlBody       string    `json:"HtmlBody,omitempty"`
	TextBody       string    `json:"TextBody,omitempty"`
	TemplateType   string    `json:"TemplateType"` // Standard, Layout
	LayoutTemplate *int      `json:"LayoutTemplate,omitempty"`
	Active         bool      `json:"Active"`
	CreatedAt      time.Time `json:"CreatedAt,omitempty"`
	UpdatedAt      time.Time `json:"UpdatedAt,omitempty"`
}

Template represents a PostmarkApp template

type TemplateEmailRequest

type TemplateEmailRequest struct {
	From          string                 `json:"From"`
	To            string                 `json:"To"`
	Cc            string                 `json:"Cc,omitempty"`
	Bcc           string                 `json:"Bcc,omitempty"`
	Tag           string                 `json:"Tag,omitempty"`
	ReplyTo       string                 `json:"ReplyTo,omitempty"`
	Headers       []Header               `json:"Headers,omitempty"`
	TrackOpens    bool                   `json:"TrackOpens,omitempty"`
	TrackLinks    string                 `json:"TrackLinks,omitempty"`
	TemplateID    int                    `json:"TemplateId,omitempty"`
	TemplateAlias string                 `json:"TemplateAlias,omitempty"`
	TemplateModel map[string]interface{} `json:"TemplateModel"`
	InlineCss     bool                   `json:"InlineCss,omitempty"`
	Attachments   []Attachment           `json:"Attachments,omitempty"`
	Metadata      map[string]string      `json:"Metadata,omitempty"`
	MessageStream string                 `json:"MessageStream,omitempty"`
}

TemplateEmailRequest represents an email send with template

type TemplateListResponse

type TemplateListResponse struct {
	TotalCount int        `json:"TotalCount"`
	Templates  []Template `json:"Templates"`
}

TemplateListResponse represents a list of templates

type UpdateServerRequest

type UpdateServerRequest struct {
	Name                       string `json:"Name,omitempty"`
	Color                      string `json:"Color,omitempty"`
	RawEmailEnabled            bool   `json:"RawEmailEnabled,omitempty"`
	SmtpApiActivated           bool   `json:"SmtpApiActivated,omitempty"`
	InboundHookUrl             string `json:"InboundHookUrl,omitempty"`
	BounceHookUrl              string `json:"BounceHookUrl,omitempty"`
	OpenHookUrl                string `json:"OpenHookUrl,omitempty"`
	PostFirstOpenOnly          bool   `json:"PostFirstOpenOnly,omitempty"`
	TrackOpens                 bool   `json:"TrackOpens,omitempty"`
	TrackLinks                 string `json:"TrackLinks,omitempty"`
	IncludeBounceContentInHook bool   `json:"IncludeBounceContentInHook,omitempty"`
	EnableSmtpApiErrorHooks    bool   `json:"EnableSmtpApiErrorHooks,omitempty"`
	DeliveryHookUrl            string `json:"DeliveryHookUrl,omitempty"`
}

UpdateServerRequest represents a server update request

type UpdateTemplateRequest

type UpdateTemplateRequest struct {
	Name           string `json:"Name,omitempty"`
	Alias          string `json:"Alias,omitempty"`
	Subject        string `json:"Subject,omitempty"`
	HtmlBody       string `json:"HtmlBody,omitempty"`
	TextBody       string `json:"TextBody,omitempty"`
	TemplateType   string `json:"TemplateType,omitempty"`
	LayoutTemplate *int   `json:"LayoutTemplate,omitempty"`
}

UpdateTemplateRequest represents a template update request

type UpdateWebhookRequest

type UpdateWebhookRequest struct {
	URL           string          `json:"Url,omitempty"`
	MessageStream string          `json:"MessageStream,omitempty"`
	HttpAuth      *HttpAuth       `json:"HttpAuth,omitempty"`
	HttpHeaders   []Header        `json:"HttpHeaders,omitempty"`
	Triggers      WebhookTriggers `json:"Triggers,omitempty"`
}

UpdateWebhookRequest represents a webhook update request

type Webhook

type Webhook struct {
	ID            int             `json:"ID,omitempty"`
	URL           string          `json:"Url"`
	MessageStream string          `json:"MessageStream"`
	HttpAuth      *HttpAuth       `json:"HttpAuth,omitempty"`
	HttpHeaders   []Header        `json:"HttpHeaders,omitempty"`
	Triggers      WebhookTriggers `json:"Triggers"`
	CreatedAt     time.Time       `json:"CreatedAt,omitempty"`
	UpdatedAt     time.Time       `json:"UpdatedAt,omitempty"`
}

Webhook represents a PostmarkApp webhook

type WebhookBounceTrigger

type WebhookBounceTrigger struct {
	Enabled        bool `json:"Enabled"`
	IncludeContent bool `json:"IncludeContent"`
}

WebhookBounceTrigger represents a bounce/spam event trigger

type WebhookEvent

type WebhookEvent struct {
	RecordType string            `json:"RecordType"` // Bounce, Delivery, Open, Click, SpamComplaint
	ServerID   int               `json:"ServerID,omitempty"`
	MessageID  string            `json:"MessageID"`
	Recipient  string            `json:"Recipient,omitempty"`
	Tag        string            `json:"Tag,omitempty"`
	Metadata   map[string]string `json:"Metadata,omitempty"`
	Subject    string            `json:"Subject,omitempty"`
	ReceivedAt time.Time         `json:"ReceivedAt,omitempty"`

	// Bounce-specific fields
	Type      string    `json:"Type,omitempty"`
	TypeCode  int       `json:"TypeCode,omitempty"`
	Email     string    `json:"Email,omitempty"`
	BouncedAt time.Time `json:"BouncedAt,omitempty"`
	Details   string    `json:"Details,omitempty"`

	// Open-specific fields
	FirstOpen bool   `json:"FirstOpen,omitempty"`
	UserAgent string `json:"UserAgent,omitempty"`
	Platform  string `json:"Platform,omitempty"`
	Client    string `json:"Client,omitempty"`
	OS        string `json:"OS,omitempty"`

	// Click-specific fields
	ClickLocation string `json:"ClickLocation,omitempty"`
	OriginalLink  string `json:"OriginalLink,omitempty"`
}

WebhookEvent represents an event to be sent to webhooks

type WebhookListResponse

type WebhookListResponse struct {
	Webhooks []Webhook `json:"Webhooks"`
}

WebhookListResponse represents a list of webhooks

type WebhookOpenTrigger

type WebhookOpenTrigger struct {
	Enabled           bool `json:"Enabled"`
	PostFirstOpenOnly bool `json:"PostFirstOpenOnly"`
}

WebhookOpenTrigger represents an open event trigger

type WebhookTrigger

type WebhookTrigger struct {
	Enabled bool `json:"Enabled"`
}

WebhookTrigger represents a simple trigger

type WebhookTriggers

type WebhookTriggers struct {
	Open               *WebhookOpenTrigger   `json:"Open,omitempty"`
	Click              *WebhookTrigger       `json:"Click,omitempty"`
	Delivery           *WebhookTrigger       `json:"Delivery,omitempty"`
	Bounce             *WebhookBounceTrigger `json:"Bounce,omitempty"`
	SpamComplaint      *WebhookBounceTrigger `json:"SpamComplaint,omitempty"`
	SubscriptionChange *WebhookTrigger       `json:"SubscriptionChange,omitempty"`
}

WebhookTriggers represents which events trigger the webhook

Jump to

Keyboard shortcuts

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