kirora

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Kirora Go SDK

Use the Kirora API from Go to manage contacts, track events, and send campaigns and transactional messages.

Go guide · API reference · Package docs · Examples · Changelog

  • Typed requests and responses generated from Kirora's OpenAPI specification.
  • Automatic pagination and retries, with idempotency keys for supported operations.
  • Webhook verification, user token signing, and partner workspace support.
  • Standard library only, with no dependencies.

Contents

Installation

Requires Go 1.24 or later. In an empty directory, first run go mod init example.com/kirora-quickstart. Then install the SDK in your module:

go get github.com/kiroratech/kirora-go

Create an API key in the Kirora dashboard and set it in your server's environment:

export KIRORA_API_KEY="your_api_key"

Keep the key on your server. For browser and mobile apps, use server-issued user tokens.

Quickstart

Save the following as main.go in your module.

This example creates or updates a contact. Replace the sample external ID and email with your own test values.

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	client, err := kirora.NewClient("") // Reads KIRORA_API_KEY.
	if err != nil {
		log.Fatal(err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	contact, err := client.Contacts.Identify(ctx, &kirora.IdentifyContactInput{
		ExternalID: kirora.Value("go-quickstart-user"),
		Email:      kirora.Value("ada@example.com"),
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Contact saved: %s\n", contact.ID)
}

Run it:

go run .

A successful request prints Contact saved: <contact ID>. To check your credentials without creating data, use client.Me(ctx).

Usage

The snippets below go inside a function returning an error, with client and ctx initialized as in the quickstart. Add fmt to your imports where used.

Contacts

Identify creates or updates a contact, matching by external ID, then email, then phone. Use a contact reference to retrieve it:

contact, err := client.Contacts.Get(ctx, kirora.ContactEmail("ada@example.com"))
if err != nil {
	return err
}
fmt.Println(contact.ID)

Use kirora.ContactID for a Kirora ID or kirora.ContactExternalID for your own user ID.

Events
_, err := client.Events.Track(ctx, &kirora.TrackEventInput{
	ExternalID: kirora.Ptr("go-quickstart-user"),
	Name:       "Order Completed",
	Properties: map[string]any{"orderId": "1234", "total": 49.99, "currency": "GBP"},
}, kirora.WithIdempotencyKey("order-1234-completed"))
if err != nil {
	return err
}

Derive the idempotency key from the operation in your application, and reuse it when retrying that same operation with the same body.

Transactional messages

Complete your workspace's email sending setup and configure an email template first. Replace order-receipt with your template's identifier and the recipient with a test address.

sent, err := client.Transactional.Send(ctx, &kirora.SendTransactionalInput{
	To:    kirora.ContactIdentifier{Email: kirora.Ptr("customer@example.com")},
	Data:  map[string]any{"orderId": "1234"},
	Email: &kirora.SendTransactionalInputEmail{Template: kirora.Ptr("order-receipt")},
}, kirora.WithIdempotencyKey("receipt-1234"))
if err != nil {
	return err
}
fmt.Println(sent.Messages)
for _, s := range sent.SkippedChannels {
	fmt.Printf("%s not sent: %s (%s)\n", s.Channel, s.Message, s.Code)
}
for _, s := range sent.SkippedCopies {
	fmt.Printf("%s copy to %s not sent: %s (%s)\n", s.Kind, s.Email, s.Message, s.Code)
}

A successful send can skip a channel the contact can't receive, or a CC or BCC address that is suppressed. Check SkippedChannels and SkippedCopies when you need to know that every recipient got the message.

Events.TrackBatch and Transactional.SendBatch accept up to 100 entries. Check each entry in Results for errors even when the call succeeds. Set each entry's IdempotencyKey when retrying batches from your application.

Services
Service Use it to
Contacts Identify, update, merge, export, and delete contacts; manage preferences and push devices.
Events Track individual events or batches.
Transactional Send messages individually or in batches; cancel scheduled messages.
Campaigns Create campaigns, check eligibility, send, and schedule.
Lists Create lists and manage membership.
Messages Inspect sent messages.
Suppressions Manage suppressed email addresses.
Workspaces Manage tenant workspaces with a partner key.
EmbedSessions Create sessions for embedded Kirora builders.

See the package docs for method signatures and the API reference for endpoint requirements.

Client configuration

Create one client and reuse it; clients are safe for concurrent use. Pass an API key directly to NewClient, or pass "" to read KIRORA_API_KEY:

client, err := kirora.NewClient("",
	kirora.WithTimeout(10*time.Second),
	kirora.WithMaxRetries(2),
)
if err != nil {
	return err
}
Option Default Purpose
WithTimeout(d) 30 seconds Limit each attempt, including reading the response.
WithMaxRetries(n) 3 Allow 0–10 retries after the first attempt.
WithMaxRetryDelay(d) 30 seconds Limit the wait between attempts; a longer Retry-After stops retries.
WithBaseURL(url) KIRORA_BASE_URL or https://api.kirora.io Set the API host, without /v1: an http or https URL without a query or fragment.
WithHTTPClient(c) http.DefaultClient Use a custom HTTP client or transport.
WithWorkspace(externalID) None Scope a partner key to a tenant workspace.
WithHeader(name, value) None Add a request header.
WithAppInfo(name, version) None Add your app to the User-Agent.

Every API method takes a context.Context first. Use a context deadline to limit the total time, including retries; WithTimeout limits each attempt separately.

Shared options can also be passed to a single API call to override client settings. WithIdempotencyKey and WithResponseInto are call-only options; WithAppInfo is client-only. See configuration details.

Errors

Import the standard library's errors and log packages to inspect typed API errors:

contact, err := client.Contacts.Get(ctx, kirora.ContactExternalID("go-quickstart-user"))
if err != nil {
	if kirora.IsErrorCode(err, kirora.ErrorCodeNotFound) {
		return nil // Handle the missing contact in your application.
	}
	var apiErr *kirora.Error
	if errors.As(err, &apiErr) {
		log.Printf("Kirora error: code=%s status=%d request_id=%s",
			apiErr.Code, apiErr.StatusCode, apiErr.RequestID)
	}
	return err
}
fmt.Println(contact.ID)

*kirora.Error includes the API code, HTTP status, request ID, field errors, and available rate-limit details. Include the request ID when reporting a failure. Network failures return *kirora.ConnectionError; unusable success responses return *kirora.ResponseError. Cancelled calls can return context.Canceled or context.DeadlineExceeded.

See error handling and the API error codes.

Retries

The SDK allows up to 3 retries by default, with exponential backoff and jitter:

  • Rate limits (429) and failures that never established a connection can be retried.
  • Other network failures and 5xx responses are retried only when repeating the operation is safe.
  • IDEMPOTENCY_KEY_IN_USE (409) can be retried when the call has a key.
  • Other 4xx responses and cancelled calls are not retried.

Use kirora.WithMaxRetries(0) to disable retries. See the retry guide for operation-specific rules and timeout behavior.

Idempotency keys

For supported operations, the SDK generates an idempotency key per call and reuses it for its own retries. Separate calls get separate keys. To deduplicate retries from your application, pass a stable kirora.WithIdempotencyKey(key) to each call for the same operation and body, as in the event and transactional examples above.

Idempotency keys apply to individual calls; they cannot be set on the client. See idempotency details.

The usage guide covers each of these in detail.

Optional fields

Use kirora.Ptr(v) for optional pointer fields, kirora.Value(v) for nullable fields, and kirora.Null[T]() to explicitly clear a nullable field. Omitting an update field leaves its current value unchanged. See data handling.

Pagination

Use a service's All iterator to fetch pages automatically, or List to fetch a single page and manage cursors yourself. See pagination examples.

Webhooks

Verify the raw request body with kirora.VerifyWebhook before parsing it. Webhooks can arrive more than once; deduplicate using the verified headers.EventID, and record an event as handled only once its work has succeeded, so a failed delivery is handled again on retry. See the verification guide and runnable webhook server.

Authenticate browser and mobile SDK users

Create user tokens on your server with kirora.CreateUserToken, using your SDK token secret and the authenticated user's ID. See user token signing.

Partner workspaces

Use client.ForWorkspace(externalID) with a partner key to scope calls to a tenant. See workspace and embed session examples.

Advanced requests

Use Request for endpoints without a service method, RequestAll for paginated results, and RequestRaw to stream a response. WithResponseInto gives a call's request ID, rate limit and idempotency replay. See advanced requests.

Testing your code

Point a client at an httptest.Server with WithBaseURL and disable retries with WithMaxRetries(0). See the testing example.

For complete programs, see runnable examples: webhook handling, CSV contact imports, and partner workspace iteration. Run them from the repository root.

Compatibility

  • Go: 1.24 or later. The SDK uses range-over-function iterators and JSON omitzero.
  • API: targets /v1. Unknown enum values and error codes are preserved; use IsKnown() where available to check whether your SDK recognizes a value. Email blocks keep properties this SDK has no field for in Extra, so a design you decode, edit and send back loses nothing.
  • Releases: before 1.0, minor releases may include breaking changes. Review the changelog when upgrading.

Help

For SDK bugs or feature requests, open an issue. Include your SDK and Go versions, a minimal reproduction, and the request ID when available. Remove API keys, tokens, and personal data before sharing logs.

For integration help, start with the Go guide, API reference, or usage guide.

Development

From the repository root, run:

go test ./...

See the development guide for OpenAPI code generation and the CI workflow for the full set of checks.

License

MIT

Documentation

Overview

Package kirora is a client for the Kirora API. Use it to manage contacts and lists, track events, send campaigns and transactional messages, look up messages and suppressions, verify webhooks, and manage partner workspaces.

Create a Client with NewClient, then call the API through its services:

client, err := kirora.NewClient("") // reads KIRORA_API_KEY
if err != nil {
	log.Fatal(err)
}
contact, err := client.Contacts.Get(ctx, kirora.ContactExternalID("user-123"))

API errors are returned as *Error; see IsErrorCode. Failed requests are retried with backoff where a retry can't cause a duplicate; see WithMaxRetries.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	// With an empty key, NewClient reads it from KIRORA_API_KEY.
	client, err := kirora.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	me, err := client.Me(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Connected to %s with the %s key %q\n", me.Workspace.Name, me.APIKey.Kind, me.APIKey.Name)
}

Index

Examples

Constants

View Source
const DefaultBaseURL = "https://api.kirora.io"

DefaultBaseURL is the API host a Client talks to unless WithBaseURL or KIRORA_BASE_URL sets another.

View Source
const DefaultUserTokenLifetime = time.Hour

DefaultUserTokenLifetime is the usual lifetime to pass to CreateUserToken.

View Source
const DefaultWebhookTolerance = 5 * time.Minute

DefaultWebhookTolerance is how far a webhook's timestamp may be from now before the webhook is rejected as a replay. Change it with WebhookOptions.Tolerance.

View Source
const Version = "0.2.0"

Version is the version of this SDK, sent in the User-Agent header.

Variables

This section is empty.

Functions

func CreateUserToken

func CreateUserToken(tokenSecret, userID string, expiresIn time.Duration) (string, error)

CreateUserToken creates a token that signs a user in to Kirora's web and mobile SDKs. Serve it from a route on your server that only the signed-in user can call.

tokenSecret is the SDK token secret from Developer → SDK in the dashboard; never expose it to the browser. userID is your own id for the user (their contact's externalId). expiresIn is how long the token lasts: a whole number of seconds from 1s to 24 hours, such as DefaultUserTokenLifetime. It returns an error if tokenSecret or userID is empty, or expiresIn is invalid, rather than signing a token.

http.HandleFunc("/kirora-token", func(w http.ResponseWriter, r *http.Request) {
	token, err := kirora.CreateUserToken(os.Getenv("KIRORA_SDK_TOKEN_SECRET"), currentUser(r).ID, kirora.DefaultUserTokenLifetime)
	...
})
Example
package main

import (
	"fmt"
	"net/http"
	"os"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	// Serve the token only to the signed-in user it names; 0 gives the default lifetime.
	http.HandleFunc("/kirora-token", func(w http.ResponseWriter, r *http.Request) {
		token, err := kirora.CreateUserToken(os.Getenv("KIRORA_SDK_TOKEN_SECRET"), "user-1", kirora.DefaultUserTokenLifetime)
		if err != nil {
			http.Error(w, "", http.StatusInternalServerError)
			return
		}
		fmt.Fprint(w, token)
	})
}

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

IsErrorCode reports whether err is, or wraps, an *Error with the given code.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v, for the optional fields of params, as in kirora.Ptr(100) or kirora.Ptr(true).

func RequestAll

func RequestAll[T any](ctx context.Context, c *Client, path string, query url.Values, opts ...CallOption) iter.Seq2[T, error]

RequestAll iterates over every item of an endpoint that has no method in this SDK, fetching pages as it goes, as the services' All methods do.

for segment, err := range kirora.RequestAll[Segment](ctx, client, "/v1/segments", nil) {
	if err != nil {
		return err
	}
	fmt.Println(segment.Name)
}

func VerifyWebhookSignature

func VerifyWebhookSignature(secret string, rawBody []byte, signature, timestamp string, opts *WebhookOptions) error

VerifyWebhookSignature checks that signature, as sent in a webhook's headers, signs rawBody and timestamp with secret, and that timestamp is within tolerance. rawBody must be the body exactly as received, before any parsing. signature may list several signatures separated by commas; one match is enough. Get signature and timestamp from ReadWebhookHeaders, or use VerifyWebhook to read and check a request in one step.

A webhook that fails verification gets a *WebhookVerificationError; an empty secret or invalid opts get a plain error.

Types

type APICaller

type APICaller struct {
	// The workspace the request acts in.
	Workspace APICallerWorkspace `json:"workspace"`
	// The key making the request.
	APIKey APICallerAPIKey `json:"apiKey"`
}

APICaller is defined by the Kirora API.

type APICallerAPIKey

type APICallerAPIKey struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// `agent` keys cannot send; see the agents guide.
	Kind APIKeyKind `json:"kind"`
	// The integration the key was made for, if any.
	Source *APIKeySource `json:"source"`
	// What the key may do.
	Scopes []APIKeyScope `json:"scopes"`
}

APICallerAPIKey: The key making the request.

type APICallerWorkspace

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

APICallerWorkspace: The workspace the request acts in.

type APIKeyKind

type APIKeyKind string

APIKeyKind: `agent` keys cannot send; see the agents guide.

const (
	APIKeyKindIntegration APIKeyKind = "integration"
	APIKeyKindAgent       APIKeyKind = "agent"
	APIKeyKindPartner     APIKeyKind = "partner"
)

func (APIKeyKind) IsKnown

func (v APIKeyKind) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type APIKeyScope

type APIKeyScope string

APIKeyScope: Values other than these constants may be added to the API at any time.

const (
	APIKeyScopeCampaignsRead        APIKeyScope = "campaigns:read"
	APIKeyScopeCampaignsSend        APIKeyScope = "campaigns:send"
	APIKeyScopeCampaignsWrite       APIKeyScope = "campaigns:write"
	APIKeyScopeContactsRead         APIKeyScope = "contacts:read"
	APIKeyScopeContactsWrite        APIKeyScope = "contacts:write"
	APIKeyScopeContactsDelete       APIKeyScope = "contacts:delete"
	APIKeyScopeConversionGoalsRead  APIKeyScope = "conversion-goals:read"
	APIKeyScopeConversionGoalsWrite APIKeyScope = "conversion-goals:write"
	APIKeyScopeDomainsRead          APIKeyScope = "domains:read"
	APIKeyScopeDomainsWrite         APIKeyScope = "domains:write"
	APIKeyScopeEventsWrite          APIKeyScope = "events:write"
	APIKeyScopeEventsDelete         APIKeyScope = "events:delete"
	APIKeyScopeFormsRead            APIKeyScope = "forms:read"
	APIKeyScopeFormsWrite           APIKeyScope = "forms:write"
	APIKeyScopeListsRead            APIKeyScope = "lists:read"
	APIKeyScopeListsWrite           APIKeyScope = "lists:write"
	APIKeyScopeJourneysActivate     APIKeyScope = "journeys:activate"
	APIKeyScopeJourneysRead         APIKeyScope = "journeys:read"
	APIKeyScopeJourneysWrite        APIKeyScope = "journeys:write"
	APIKeyScopeReportsRead          APIKeyScope = "reports:read"
	APIKeyScopeSegmentsRead         APIKeyScope = "segments:read"
	APIKeyScopeSegmentsWrite        APIKeyScope = "segments:write"
	APIKeyScopeTagsRead             APIKeyScope = "tags:read"
	APIKeyScopeTagsWrite            APIKeyScope = "tags:write"
	APIKeyScopeTemplatesRead        APIKeyScope = "templates:read"
	APIKeyScopeTemplatesWrite       APIKeyScope = "templates:write"
	APIKeyScopeTransactionalSend    APIKeyScope = "transactional:send"
	APIKeyScopeAttributesRead       APIKeyScope = "attributes:read"
	APIKeyScopeAttributesWrite      APIKeyScope = "attributes:write"
	APIKeyScopeEventsRead           APIKeyScope = "events:read"
	APIKeyScopeMessagesRead         APIKeyScope = "messages:read"
	APIKeyScopeSuppressionsRead     APIKeyScope = "suppressions:read"
	APIKeyScopeSuppressionsWrite    APIKeyScope = "suppressions:write"
	APIKeyScopeTopicsRead           APIKeyScope = "topics:read"
	APIKeyScopeTopicsWrite          APIKeyScope = "topics:write"
	APIKeyScopePushRead             APIKeyScope = "push:read"
	APIKeyScopeWorkspacesManage     APIKeyScope = "workspaces:manage"
	APIKeyScopeEmbedWrite           APIKeyScope = "embed:write"
	APIKeyScopeWebhooksRead         APIKeyScope = "webhooks:read"
	APIKeyScopeWebhooksWrite        APIKeyScope = "webhooks:write"
)

func (APIKeyScope) IsKnown

func (v APIKeyScope) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type APIKeySource

type APIKeySource string

APIKeySource: The integration the key was made for, if any.

const (
	APIKeySourceZapier  APIKeySource = "zapier"
	APIKeySourceMake    APIKeySource = "make"
	APIKeySourceN8n     APIKeySource = "n8n"
	APIKeySourceSegment APIKeySource = "segment"
	APIKeySourceHTTPAPI APIKeySource = "http_api"
)

func (APIKeySource) IsKnown

func (v APIKeySource) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type AbTestSettingsInput

type AbTestSettingsInput struct {
	// Versions 2 to 4. Version 1 is the campaign's own `content`.
	Versions []AbTestSettingsInputVersion `json:"versions"`
	// The share of the audience, in percent, the versions go to, split evenly between them.
	// The rest get the winner.
	TestPercent int `json:"testPercent"`
	// How the winner is picked: the version with the highest click or open rate over its
	// delivered messages (as the campaign's own rates; over sent until any version has a
	// delivery), or the highest share of its sent messages that reached the campaign's
	// conversion goal (`conversionGoalId`). Opens overcount: machine opens (Apple Mail
	// Privacy Protection, Gmail's prefetch, mail scanners) count unread email as opened. A
	// push test is decided by clicks (a tap the app reports with a link to follow, so the
	// push needs an `actionUrl`) or conversions, not opens. A tie goes to the lower version.
	WinnerBy *AbTestWinnerBy `json:"winnerBy,omitempty"`
	// The campaign's conversion goal that decides; required when `winnerBy` is
	// `conversions`.
	ConversionGoalID *string `json:"conversionGoalId,omitempty"`
	// How long after the test went out to pick the winner and send it to the rest, from 1 to
	// 72 hours; `null` to pick it by hand.
	DecideAfter *DurationInput `json:"decideAfter"`
}

AbTestSettingsInput is defined by the Kirora API.

type AbTestSettingsInputVersion

type AbTestSettingsInputVersion struct {
	// Subject, preview text, sender and design; any left out are version 1's. A subject test
	// sets only `subject`. `from` may change the sender's name, not the address.
	Email *AbTestSettingsInputVersionEmail `json:"email,omitempty"`
	// On a push campaign: the title, body and image; any left out are version 1's.
	Push *CampaignAbTestVersionPush `json:"push,omitempty"`
}

AbTestSettingsInputVersion is defined by the Kirora API.

type AbTestSettingsInputVersionEmail

type AbTestSettingsInputVersionEmail struct {
	// The subject line. Merge tags are allowed.
	Subject *string `json:"subject,omitempty"`
	// Shown by inboxes after the subject. Merge tags are allowed; keep it near 100
	// characters.
	PreviewText *string `json:"previewText,omitempty"`
	// The sender address, on a verified sending domain.
	From *string `json:"from,omitempty"`
	// This version's design; left out, it uses version 1's.
	TemplateSnapshot *TemplateSnapshotInput `json:"templateSnapshot,omitempty"`
}

AbTestSettingsInputVersionEmail: Subject, preview text, sender and design; any left out are version 1's. A subject test sets only `subject`. `from` may change the sender's name, not the address.

type AbTestWinnerBy

type AbTestWinnerBy string

AbTestWinnerBy: How the winner is picked: the version with the highest click or open rate over its delivered messages (as the campaign's own rates; over sent until any version has a delivery), or the highest share of its sent messages that reached the campaign's conversion goal (`conversionGoalId`). Opens overcount: machine opens (Apple Mail Privacy Protection, Gmail's prefetch, mail scanners) count unread email as opened. A push test is decided by clicks (a tap the app reports with a link to follow, so the push needs an `actionUrl`) or conversions, not opens. A tie goes to the lower version.

const (
	AbTestWinnerByClicks      AbTestWinnerBy = "clicks"
	AbTestWinnerByOpens       AbTestWinnerBy = "opens"
	AbTestWinnerByConversions AbTestWinnerBy = "conversions"
)

func (AbTestWinnerBy) IsKnown

func (v AbTestWinnerBy) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ActivityCondition

type ActivityCondition struct {
	// `notOpened` and `notClicked`: sent, and not opened or clicked. Opens include machine
	// opens (see `openedByMachine`).
	Activity ActivityConditionActivity `json:"activity"`
	// How many messages had this activity; defaults to at least one. Not with `notSent`.
	Count *ActivityConditionCount `json:"count,omitempty"`
	// With `clicked` or `notClicked`: only clicks on a link whose address contains this
	// text, ignoring case.
	Link *string `json:"link,omitempty"`
	// Only messages on this channel (opened a push, not an email); any when left out.
	Channel *Channel `json:"channel,omitempty"`
	// Only messages of this campaign.
	CampaignID *string `json:"campaignId,omitempty"`
	// Only messages of campaigns or journeys carrying this tag, as they are tagged when the
	// rule is evaluated.
	TagID *string `json:"tagId,omitempty"`
	// Inside a journey only: the message sent by the step with this id in the contact's
	// current enrollment. Matches nobody outside a journey.
	JourneyStepID *string `json:"journeyStepId,omitempty"`
	// Only activity from the last `within`. For `notOpened` and `notClicked` it is a waiting
	// time instead: only messages sent at least this long ago count, so each has had that
	// long to be opened or clicked.
	Within *Duration `json:"within,omitempty"`
}

ActivityCondition is defined by the Kirora API.

func (ActivityCondition) MarshalJSON

func (v ActivityCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "activity", which identifies a ActivityCondition.

type ActivityConditionActivity

type ActivityConditionActivity string

ActivityConditionActivity: `notOpened` and `notClicked`: sent, and not opened or clicked. Opens include machine opens (see `openedByMachine`).

const (
	ActivityConditionActivitySent       ActivityConditionActivity = "sent"
	ActivityConditionActivityNotSent    ActivityConditionActivity = "notSent"
	ActivityConditionActivityOpened     ActivityConditionActivity = "opened"
	ActivityConditionActivityClicked    ActivityConditionActivity = "clicked"
	ActivityConditionActivityNotOpened  ActivityConditionActivity = "notOpened"
	ActivityConditionActivityNotClicked ActivityConditionActivity = "notClicked"
	ActivityConditionActivityBounced    ActivityConditionActivity = "bounced"
)

func (ActivityConditionActivity) IsKnown

func (v ActivityConditionActivity) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ActivityConditionCount

type ActivityConditionCount struct {
	// At least, exactly or at most.
	Operator CountOperator `json:"operator"`
	Value    int           `json:"value"`
}

ActivityConditionCount: How many messages had this activity; defaults to at least one. Not with `notSent`.

type ActivityConditionInput

type ActivityConditionInput = ActivityCondition

ActivityConditionInput is defined by the Kirora API.

type AddSuppressionsInput

type AddSuppressionsInput struct {
	// Email addresses to block, up to 10,000; trimmed and lowercased.
	Emails []string `json:"emails"`
}

AddSuppressionsInput is defined by the Kirora API.

type AddedListContacts

type AddedListContacts struct {
	// Contacts newly added to the list.
	AddedCount int `json:"addedCount"`
	// Identifiers as sent (emails normalised) that name no contact in the workspace.
	NotFound []string `json:"notFound"`
}

AddedListContacts is defined by the Kirora API.

type AddedSuppressions

type AddedSuppressions struct {
	// Newly blocked addresses.
	AddedCount int `json:"addedCount"`
	// Already blocked, for any reason; their reason is left as it was.
	AlreadySuppressedCount int `json:"alreadySuppressedCount"`
	// Entries that are not an email address, exactly as sent.
	Invalid []string `json:"invalid"`
}

AddedSuppressions is defined by the Kirora API.

type Align

type Align string

Align: When unset, headings, text, buttons and boxed text start from the reading side (left, or right in a right-to-left language); other blocks centre.

const (
	AlignLeft   Align = "left"
	AlignCenter Align = "center"
	AlignRight  Align = "right"
)

func (Align) IsKnown

func (v Align) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type AttributeCondition

type AttributeCondition struct {
	// `attributes.<key>`, e.g. `attributes.plan`.
	Field string `json:"field"`
	// How to compare. Text comparisons (`equals`, `notEquals`, `contains`, `notContains`,
	// `startsWith`, `in`) ignore case and accents ("jose" matches "José"). `notEquals` and
	// `notContains` also match contacts without the value. Date operators (`before`,
	// `after`, `withinLastDays`, `moreThanDaysAgo`) compare as dates and times in UTC: a
	// stored ISO-8601 date is the start of that day, `before` means earlier than the given
	// day and `after` later than it, and a value that is not an ISO-8601 date or date and
	// time never matches. `inNextDays` is a date from today to that many days ahead.
	// `anniversaryInNextDays` (0 = today) and `anniversaryThisMonth` ignore the year, so
	// they suit birthdays, and also read a yearless `--MM-DD`; a 29 February counts on 28
	// February in other years. Days are UTC days; these three are for attributes and dates,
	// not contact fields.
	Operator AttributeConditionOperator `json:"operator"`
	// What to compare with, always as text: `"pro"`, `"3"`, `"true"`. Equality compares the
	// stored value as text, so a stored 5 matches `"5"`. An ISO date for `before` and
	// `after`; a number for `gt`, `gte`, `lt` and `lte`; a whole number of days (1 to 3650)
	// for `withinLastDays`, `moreThanDaysAgo` and `inNextDays`, and 0 to 365 for
	// `anniversaryInNextDays`. Omit for `in`, `exists`, `notExists` and
	// `anniversaryThisMonth`.
	Value *string `json:"value,omitempty"`
	// For `in` only: up to 100 values, each as text, any of which matches.
	Values []string `json:"values,omitzero"`
}

AttributeCondition is defined by the Kirora API.

func (AttributeCondition) MarshalJSON

func (v AttributeCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "attribute", which identifies a AttributeCondition.

type AttributeConditionInput

type AttributeConditionInput = AttributeCondition

AttributeConditionInput is defined by the Kirora API.

type AttributeConditionOperator

type AttributeConditionOperator string

AttributeConditionOperator: How to compare. Text comparisons (`equals`, `notEquals`, `contains`, `notContains`, `startsWith`, `in`) ignore case and accents ("jose" matches "José"). `notEquals` and `notContains` also match contacts without the value. Date operators (`before`, `after`, `withinLastDays`, `moreThanDaysAgo`) compare as dates and times in UTC: a stored ISO-8601 date is the start of that day, `before` means earlier than the given day and `after` later than it, and a value that is not an ISO-8601 date or date and time never matches. `inNextDays` is a date from today to that many days ahead. `anniversaryInNextDays` (0 = today) and `anniversaryThisMonth` ignore the year, so they suit birthdays, and also read a yearless `--MM-DD`; a 29 February counts on 28 February in other years. Days are UTC days; these three are for attributes and dates, not contact fields.

const (
	AttributeConditionOperatorEquals                AttributeConditionOperator = "equals"
	AttributeConditionOperatorNotEquals             AttributeConditionOperator = "notEquals"
	AttributeConditionOperatorContains              AttributeConditionOperator = "contains"
	AttributeConditionOperatorNotContains           AttributeConditionOperator = "notContains"
	AttributeConditionOperatorStartsWith            AttributeConditionOperator = "startsWith"
	AttributeConditionOperatorExists                AttributeConditionOperator = "exists"
	AttributeConditionOperatorNotExists             AttributeConditionOperator = "notExists"
	AttributeConditionOperatorBefore                AttributeConditionOperator = "before"
	AttributeConditionOperatorAfter                 AttributeConditionOperator = "after"
	AttributeConditionOperatorGt                    AttributeConditionOperator = "gt"
	AttributeConditionOperatorGte                   AttributeConditionOperator = "gte"
	AttributeConditionOperatorLt                    AttributeConditionOperator = "lt"
	AttributeConditionOperatorLte                   AttributeConditionOperator = "lte"
	AttributeConditionOperatorIn                    AttributeConditionOperator = "in"
	AttributeConditionOperatorWithinLastDays        AttributeConditionOperator = "withinLastDays"
	AttributeConditionOperatorMoreThanDaysAgo       AttributeConditionOperator = "moreThanDaysAgo"
	AttributeConditionOperatorInNextDays            AttributeConditionOperator = "inNextDays"
	AttributeConditionOperatorAnniversaryInNextDays AttributeConditionOperator = "anniversaryInNextDays"
	AttributeConditionOperatorAnniversaryThisMonth  AttributeConditionOperator = "anniversaryThisMonth"
)

func (AttributeConditionOperator) IsKnown

func (v AttributeConditionOperator) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type BatchError

type BatchError struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
	// Each field the request got wrong: on `VALIDATION_ERROR` and `DRAFT_INCOMPLETE`.
	Errors []FieldError `json:"errors,omitzero"`
	// What else the error carries, by `code`: see that code's description.
	Details   any     `json:"details,omitzero"`
	RequestID *string `json:"requestId,omitempty"`
}

BatchError is defined by the Kirora API.

type BoxedBlock

type BoxedBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

BoxedBlock is defined by the Kirora API.

func (BoxedBlock) MarshalJSON

func (v BoxedBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "boxed", which identifies a BoxedBlock, and the properties in Extra.

func (*BoxedBlock) UnmarshalJSON

func (v *BoxedBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type BoxedBlockInput

type BoxedBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

BoxedBlockInput is defined by the Kirora API.

func (BoxedBlockInput) MarshalJSON

func (v BoxedBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "boxed", which identifies a BoxedBlockInput, and the properties in Extra.

func (*BoxedBlockInput) UnmarshalJSON

func (v *BoxedBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ButtonBlock

type ButtonBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align     *Align `json:"align,omitempty"`
	FullWidth *bool  `json:"fullWidth,omitempty"`
	// A hex colour, or a theme reference: `accent`, `canvas`, or `accent-tint` /
	// `canvas-tint` (a light tint of it), which follows the theme.
	Color *EmailBlockStyleBackgroundColor `json:"color,omitempty"`
	// This button's style, in place of the theme's.
	ButtonStyle *ButtonBlockButtonStyle `json:"buttonStyle,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ButtonBlock is defined by the Kirora API.

func (ButtonBlock) MarshalJSON

func (v ButtonBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "button", which identifies a ButtonBlock, and the properties in Extra.

func (*ButtonBlock) UnmarshalJSON

func (v *ButtonBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ButtonBlockButtonStyle

type ButtonBlockButtonStyle string

ButtonBlockButtonStyle: This button's style, in place of the theme's.

const (
	ButtonBlockButtonStyleSolid   ButtonBlockButtonStyle = "solid"
	ButtonBlockButtonStyleOutline ButtonBlockButtonStyle = "outline"
)

func (ButtonBlockButtonStyle) IsKnown

func (v ButtonBlockButtonStyle) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ButtonBlockInput

type ButtonBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align     *Align `json:"align,omitempty"`
	FullWidth *bool  `json:"fullWidth,omitempty"`
	// A hex colour, or a theme reference: `accent`, `canvas`, or `accent-tint` /
	// `canvas-tint` (a light tint of it), which follows the theme.
	Color *EmailBlockStyleBackgroundColor `json:"color,omitempty"`
	// This button's style, in place of the theme's.
	ButtonStyle *ButtonBlockButtonStyle `json:"buttonStyle,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ButtonBlockInput is defined by the Kirora API.

func (ButtonBlockInput) MarshalJSON

func (v ButtonBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "button", which identifies a ButtonBlockInput, and the properties in Extra.

func (*ButtonBlockInput) UnmarshalJSON

func (v *ButtonBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type CallOption

type CallOption interface {
	// contains filtered or unexported methods
}

CallOption configures a single call, overriding the client's setting for that call. Every Option is one, as are WithIdempotencyKey and WithResponseInto.

func WithIdempotencyKey

func WithIdempotencyKey(key string) CallOption

WithIdempotencyKey sets the call's idempotency key. On an endpoint that takes one, the API runs the operation at most once however often it is retried, by the SDK or by you. Reuse a key only for the same operation and body: the API refuses a key reused with a different body (ErrorCodeIdempotencyKeyReused). Without one, the SDK makes a key per call where the endpoint takes one, which covers its own retries only. On an endpoint this SDK doesn't know, called with Client.Request, a key also lets writes be retried. The key must not be empty.

func WithResponseInto

func WithResponseInto(r *Response) CallOption

WithResponseInto stores the details of the call's last HTTP response in r, including when the response was an API error. r is left unchanged if no response arrived.

type Campaign

type Campaign struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// The channels it sends on.
	Channels []Channel `json:"channels"`
	// Whether it goes to all contacts: everyone its channels reach, with consent and
	// suppressions applied as on any send.
	AllContacts bool `json:"allContacts"`
	// The lists it goes to, if any: a member of any of them receives it once.
	ListIDs []string `json:"listIds"`
	// The segment it goes to, if any.
	SegmentID *string `json:"segmentId"`
	// The names of the lists or the segment it went to, once one of them has been deleted
	// (the list leaves `listIds`, or `segmentId` becomes `null`). Only a sent or cancelled
	// campaign can lose its audience this way.
	AudienceName *string `json:"audienceName"`
	// Inline rules choosing the audience, if any. At most one audience is set.
	AudienceRules *SegmentRules `json:"audienceRules"`
	// Lists and segments left out of its audience ("don't send to"); `null` for none.
	Exclusions *CampaignExclusions `json:"exclusions"`
	// Sends only to contacts the topic reaches; `null` sends to everyone with consent.
	TopicID       *string         `json:"topicId"`
	MessageLimits MessageLimitUse `json:"messageLimits"`
	// UTM parameters added to the links in the email.
	UTM     *CampaignUTM    `json:"utm"`
	Content CampaignContent `json:"content"`
	// Its A/B test, if it has one; `null` sends one version to everyone.
	AbTest *CampaignAbTest `json:"abTest"`
	// Where the campaign is in its lifecycle. `testing`: an A/B test went out and the rest
	// of the audience waits for the winner. `sent`: every message was created and queued; it
	// says nothing about delivery, which `GET /v1/campaigns/{id}/metrics` reports (some may
	// still be queued, skipped or failed).
	Status CampaignStatus `json:"status"`
	// When it sends: `fixed`, everyone at one instant, or `local_time`, each contact at a
	// time on their own clock. Set while it is `scheduled`; a local-time schedule stays set
	// once sending starts, since each contact's time still decides when theirs goes. `null`
	// otherwise.
	Schedule *CampaignSchedule `json:"schedule"`
	// When sending started; set from `sending` on (testing, sent, cancelled), `null` before.
	// A local-time campaign starts in the earliest timezone.
	SentAt *time.Time `json:"sentAt"`
	// How fast it goes out, and until when; frozen with its content at send.
	Delivery CampaignDelivery `json:"delivery"`
	// An agent key authored or edited it and it is still a draft, so it waits in the agent
	// review queue: sending needs a person's approval.
	PendingAgentReview bool `json:"pendingAgentReview"`
	// The latest request, from a member in the dashboard, that an admin send it while the
	// workspace keeps sending to admins; kept after it sends, cleared by any edit before
	// then.
	SendApprovalRequest *CampaignSendApprovalRequest `json:"sendApprovalRequest"`
	// When it was archived; archived campaigns are left out of the list by default.
	ArchivedAt *time.Time `json:"archivedAt"`
	// Tag names, sorted without case.
	Tags []string `json:"tags"`
	// Raised by every edit. Send it back as `expectedRevision` on the update so a change
	// made since you read it is refused instead of overwritten.
	Revision  int       `json:"revision"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Campaign is defined by the Kirora API.

type CampaignAbTest

type CampaignAbTest struct {
	// Versions 2 onward; version 1 is the campaign's own content.
	Versions []CampaignAbTestVersion `json:"versions"`
	// The share of the audience, in percent, the versions go to, split evenly between them.
	// The rest get the winner.
	TestPercent int `json:"testPercent"`
	// How the winner is picked: the version with the highest click or open rate over its
	// delivered messages (as the campaign's own rates; over sent until any version has a
	// delivery), or the highest share of its sent messages that reached the campaign's
	// conversion goal (`conversionGoalId`). Opens overcount: machine opens (Apple Mail
	// Privacy Protection, Gmail's prefetch, mail scanners) count unread email as opened. A
	// push test is decided by clicks (a tap the app reports with a link to follow, so the
	// push needs an `actionUrl`) or conversions, not opens. A tie goes to the lower version.
	WinnerBy AbTestWinnerBy `json:"winnerBy"`
	// The conversion goal that decides, when `winnerBy` is `conversions`.
	ConversionGoalID *string `json:"conversionGoalId"`
	// How long after the test went out to pick the winner and send it to the rest, from 1 to
	// 72 hours; `null` to pick it by hand.
	DecideAfter *Duration `json:"decideAfter"`
	// The winning version, once picked.
	Winner *int `json:"winner"`
	// When every test message was queued.
	TestSentAt *time.Time `json:"testSentAt"`
	// When the winner was picked.
	DecidedAt *time.Time `json:"decidedAt"`
}

CampaignAbTest is defined by the Kirora API.

type CampaignAbTestVersion

type CampaignAbTestVersion struct {
	// This version's email fields and design; any left out are version 1's.
	Email *CampaignContentEmail `json:"email,omitempty"`
	// This version's push title, body and image; any left out are version 1's.
	Push *CampaignAbTestVersionPush `json:"push,omitempty"`
}

CampaignAbTestVersion is defined by the Kirora API.

type CampaignAbTestVersionPush

type CampaignAbTestVersionPush struct {
	// The notification title (up to 100 characters).
	Title *string `json:"title,omitempty"`
	// The notification text (up to 500 characters).
	Body *string `json:"body,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
}

CampaignAbTestVersionPush: This version's push title, body and image; any left out are version 1's.

type CampaignBlocker

type CampaignBlocker struct {
	// What blocks it, for code to branch on.
	Code CampaignBlockerCode `json:"code"`
	// What to do about it, for the person or agent fixing it.
	Message string `json:"message"`
	// With `draft_incomplete`: the field still missing, such as `subject`.
	Field *string `json:"field,omitempty"`
}

CampaignBlocker is defined by the Kirora API.

type CampaignBlockerCode

type CampaignBlockerCode string

CampaignBlockerCode: What blocks it, for code to branch on.

const (
	CampaignBlockerCodeCampaignNotDraft              CampaignBlockerCode = "campaign_not_draft"
	CampaignBlockerCodeUnsupportedChannels           CampaignBlockerCode = "unsupported_channels"
	CampaignBlockerCodeDraftIncomplete               CampaignBlockerCode = "draft_incomplete"
	CampaignBlockerCodeEmptyAudience                 CampaignBlockerCode = "empty_audience"
	CampaignBlockerCodeMarketingContactsLimitReached CampaignBlockerCode = "marketing_contacts_limit_reached"
)

func (CampaignBlockerCode) IsKnown

func (v CampaignBlockerCode) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignContent

type CampaignContent struct {
	// The email fields and design; any may be missing on a draft.
	Email *CampaignContentEmail `json:"email,omitempty"`
	// The notification content.
	Push *CampaignContentPush `json:"push,omitempty"`
}

CampaignContent is defined by the Kirora API.

type CampaignContentEmail

type CampaignContentEmail struct {
	// The subject line. Merge tags are allowed.
	Subject *string `json:"subject,omitempty"`
	// Shown by inboxes after the subject. Merge tags are allowed; keep it near 100
	// characters.
	PreviewText *string `json:"previewText,omitempty"`
	// The HTML body. Rendered from the design when one is set.
	HTML *string `json:"html,omitempty"`
	// The plain-text alternative.
	Text *string `json:"text,omitempty"`
	// The sender address, on a verified sending domain.
	From *string `json:"from,omitempty"`
	// Where replies go; the part before the @ must be ASCII.
	ReplyTo *string `json:"replyTo,omitempty"`
	// The email design or HTML, copied into the campaign so later template edits do not
	// change it.
	TemplateSnapshot *CampaignContentEmailTemplateSnapshot `json:"templateSnapshot,omitempty"`
}

CampaignContentEmail: The email fields and design; any may be missing on a draft.

type CampaignContentEmailTemplateSnapshot

type CampaignContentEmailTemplateSnapshot struct {
	Kind          *CampaignContentEmailTemplateSnapshotKind `json:"kind,omitempty"`
	SchemaVersion *int                                      `json:"schemaVersion,omitempty"`
	// The blocks, rendered top to bottom: at most 200 across the whole tree and five levels
	// including the root. The footer stays at the root.
	Blocks []EmailBlock `json:"blocks,omitzero"`
	Theme  *EmailTheme  `json:"theme,omitempty"`
	// The language the email is written in, as a BCP 47 tag ("en", "fr-BE", "ar"). It sets
	// the HTML `lang` and the reading direction: Arabic, Hebrew, Persian, Urdu and other
	// right-to-left languages render right to left. Defaults to "en".
	Language *string `json:"language,omitempty"`
	// Plain text sent instead of the version generated from the design or HTML.
	PlainTextOverride Nullable[string] `json:"plainTextOverride,omitzero"`
	HTML              *string          `json:"html,omitempty"`
}

CampaignContentEmailTemplateSnapshot: The email design or HTML, copied into the campaign so later template edits do not change it.

type CampaignContentEmailTemplateSnapshotKind

type CampaignContentEmailTemplateSnapshotKind string

CampaignContentEmailTemplateSnapshotKind: Values other than these constants may be added to the API at any time.

const (
	CampaignContentEmailTemplateSnapshotKindDesign CampaignContentEmailTemplateSnapshotKind = "design"
	CampaignContentEmailTemplateSnapshotKindHTML   CampaignContentEmailTemplateSnapshotKind = "html"
)

func (CampaignContentEmailTemplateSnapshotKind) IsKnown

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignContentPush

type CampaignContentPush struct {
	// The notification title (up to 100 characters).
	Title *string `json:"title,omitempty"`
	// The notification text (up to 500 characters).
	Body *string `json:"body,omitempty"`
	// The HTTPS page opened when the notification is tapped.
	ActionURL *string `json:"actionUrl,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
	// Web only; iOS and Android show the app's own notification icon.
	IconURL *string `json:"iconUrl,omitempty"`
	// Up to 10 string key-value pairs passed to the app untouched, for deep links and in-app
	// routing.
	Data map[string]string `json:"data,omitzero"`
	// Up to 2 action buttons.
	Buttons []CampaignContentPushButton `json:"buttons,omitzero"`
	// A newer notification with the same key replaces the older one on the device.
	CollapseKey *string `json:"collapseKey,omitempty"`
	// The name of a sound the app ships; the device's default if unset.
	Sound *string `json:"sound,omitempty"`
	// The number shown on the iOS app icon.
	Badge *int `json:"badge,omitempty"`
	// How long a provider keeps trying an offline device, up to 28 days; zero delivers now
	// or never. Defaults to one day.
	TTL *DurationOrZero `json:"ttl,omitempty"`
	// `high` asks the push service to deliver promptly, even to a sleeping device; `normal`
	// lets it wait for a good moment to save battery. Device settings and the app still
	// decide whether and how it is shown. Unset, a transactional push is `high` and any
	// other `normal`.
	Urgency *PushUrgency `json:"urgency,omitempty"`
	// Fields that differ on one platform, each replacing the shared one there (a whole
	// `data` map, not merged key by key). On iOS and Android `actionUrl` may be an app link
	// such as `myapp://orders`; the shared one and the web one must be HTTPS.
	Overrides *CampaignContentPushOverrides `json:"overrides,omitempty"`
	// The push project it goes out through. Needed to send.
	PushProjectID *string `json:"pushProjectId,omitempty"`
}

CampaignContentPush: The notification content.

type CampaignContentPushButton

type CampaignContentPushButton struct {
	// The button label.
	Title string `json:"title"`
	// The HTTPS page the button opens.
	URL string `json:"url"`
}

CampaignContentPushButton is defined by the Kirora API.

type CampaignContentPushOverrides

type CampaignContentPushOverrides struct {
	// Replaces shared fields on iOS.
	IOS *CampaignContentPushOverridesIOS `json:"ios,omitempty"`
	// Replaces shared fields on Android.
	Android *CampaignContentPushOverridesAndroid `json:"android,omitempty"`
	// Replaces shared fields on web.
	Web *CampaignContentPushOverridesWeb `json:"web,omitempty"`
}

CampaignContentPushOverrides: Fields that differ on one platform, each replacing the shared one there (a whole `data` map, not merged key by key). On iOS and Android `actionUrl` may be an app link such as `myapp://orders`; the shared one and the web one must be HTTPS.

type CampaignContentPushOverridesAndroid

type CampaignContentPushOverridesAndroid struct {
	// The notification title (up to 100 characters).
	Title *string `json:"title,omitempty"`
	// The notification text (up to 500 characters).
	Body      *string `json:"body,omitempty"`
	ActionURL *string `json:"actionUrl,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
	// Web only; iOS and Android show the app's own notification icon.
	IconURL *string `json:"iconUrl,omitempty"`
	// Up to 10 string key-value pairs passed to the app untouched, for deep links and in-app
	// routing.
	Data map[string]string `json:"data,omitzero"`
	// Up to 2 action buttons.
	Buttons []CampaignContentPushButton `json:"buttons,omitzero"`
	// A newer notification with the same key replaces the older one on the device.
	CollapseKey *string `json:"collapseKey,omitempty"`
	// The name of a sound the app ships; the device's default if unset.
	Sound *string `json:"sound,omitempty"`
	// The number shown on the iOS app icon.
	Badge *int `json:"badge,omitempty"`
	// How long a provider keeps trying an offline device, up to 28 days; zero delivers now
	// or never. Defaults to one day.
	TTL *DurationOrZero `json:"ttl,omitempty"`
	// `high` asks the push service to deliver promptly, even to a sleeping device; `normal`
	// lets it wait for a good moment to save battery. Device settings and the app still
	// decide whether and how it is shown. Unset, a transactional push is `high` and any
	// other `normal`.
	Urgency *PushUrgency `json:"urgency,omitempty"`
	// The Android notification channel to post in, which the app creates; it sets the sound
	// and importance a person can tune, e.g. one for offers and one for orders.
	ChannelID *string `json:"channelId,omitempty"`
}

CampaignContentPushOverridesAndroid: Replaces shared fields on Android.

type CampaignContentPushOverridesIOS

type CampaignContentPushOverridesIOS struct {
	// The notification title (up to 100 characters).
	Title *string `json:"title,omitempty"`
	// The notification text (up to 500 characters).
	Body      *string `json:"body,omitempty"`
	ActionURL *string `json:"actionUrl,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
	// Web only; iOS and Android show the app's own notification icon.
	IconURL *string `json:"iconUrl,omitempty"`
	// Up to 10 string key-value pairs passed to the app untouched, for deep links and in-app
	// routing.
	Data map[string]string `json:"data,omitzero"`
	// Up to 2 action buttons.
	Buttons []CampaignContentPushButton `json:"buttons,omitzero"`
	// A newer notification with the same key replaces the older one on the device.
	CollapseKey *string `json:"collapseKey,omitempty"`
	// The name of a sound the app ships; the device's default if unset.
	Sound *string `json:"sound,omitempty"`
	// The number shown on the iOS app icon.
	Badge *int `json:"badge,omitempty"`
	// How long a provider keeps trying an offline device, up to 28 days; zero delivers now
	// or never. Defaults to one day.
	TTL *DurationOrZero `json:"ttl,omitempty"`
	// `high` asks the push service to deliver promptly, even to a sleeping device; `normal`
	// lets it wait for a good moment to save battery. Device settings and the app still
	// decide whether and how it is shown. Unset, a transactional push is `high` and any
	// other `normal`.
	Urgency *PushUrgency `json:"urgency,omitempty"`
	// How iOS presents it: `passive` arrives silently, `time-sensitive` can break through
	// Focus when the user allows it, and needs the app's Time Sensitive Notifications
	// capability.
	InterruptionLevel *InterruptionLevel `json:"interruptionLevel,omitempty"`
	// Notifications with the same thread are grouped together in Notification Center.
	ThreadID *string `json:"threadId,omitempty"`
}

CampaignContentPushOverridesIOS: Replaces shared fields on iOS.

type CampaignContentPushOverridesWeb

type CampaignContentPushOverridesWeb struct {
	// The notification title (up to 100 characters).
	Title *string `json:"title,omitempty"`
	// The notification text (up to 500 characters).
	Body *string `json:"body,omitempty"`
	// The HTTPS page opened when the notification is tapped.
	ActionURL *string `json:"actionUrl,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
	// Web only; iOS and Android show the app's own notification icon.
	IconURL *string `json:"iconUrl,omitempty"`
	// Up to 10 string key-value pairs passed to the app untouched, for deep links and in-app
	// routing.
	Data map[string]string `json:"data,omitzero"`
	// Up to 2 action buttons.
	Buttons []CampaignContentPushButton `json:"buttons,omitzero"`
	// A newer notification with the same key replaces the older one on the device.
	CollapseKey *string `json:"collapseKey,omitempty"`
	// The name of a sound the app ships; the device's default if unset.
	Sound *string `json:"sound,omitempty"`
	// The number shown on the iOS app icon.
	Badge *int `json:"badge,omitempty"`
	// How long a provider keeps trying an offline device, up to 28 days; zero delivers now
	// or never. Defaults to one day.
	TTL *DurationOrZero `json:"ttl,omitempty"`
	// `high` asks the push service to deliver promptly, even to a sleeping device; `normal`
	// lets it wait for a good moment to save battery. Device settings and the app still
	// decide whether and how it is shown. Unset, a transactional push is `high` and any
	// other `normal`.
	Urgency *PushUrgency `json:"urgency,omitempty"`
}

CampaignContentPushOverridesWeb: Replaces shared fields on web.

type CampaignDelivery

type CampaignDelivery struct {
	// How fast it goes out; `null` as fast as the plan allows. The plan's own send rate
	// still applies, so a campaign can only slow a send down.
	RateLimit *CampaignRateLimit `json:"rateLimit"`
	// From when sending starts, from 1 to 720 hours: recipients not yet sent when it passes
	// are skipped with reason `expired`. A rate-limited send always expires, after 720 hours
	// unless set. With an A/B test it must outlast `abTest.decideAfter`. `null`: no expiry.
	ExpiresAfter *Duration `json:"expiresAfter"`
}

CampaignDelivery is defined by the Kirora API.

type CampaignDeliveryInput

type CampaignDeliveryInput = CampaignDelivery

CampaignDeliveryInput is defined by the Kirora API.

type CampaignEligibility

type CampaignEligibility struct {
	CampaignID string `json:"campaignId"`
	// When the check ran.
	CheckedAt time.Time `json:"checkedAt"`
	// No blockers anywhere: the campaign's, or any channel's.
	CanSend bool `json:"canSend"`
	// Contacts in the audience, before any channel's exclusions; members of the campaign's
	// `exclusions` are already left out.
	AudienceCount int `json:"audienceCount"`
	// Contacts in the campaign's list or segment left out because they are in one of its
	// `exclusions`.
	ExcludedByExclusions int `json:"excludedByExclusions"`
	// What stops the campaign as a whole: each missing field outside a channel's content is
	// a `draft_incomplete` with its `field`, exactly as sending would refuse it.
	Blockers []CampaignBlocker `json:"blockers"`
	// One entry per selected channel.
	Channels []ChannelEligibility `json:"channels"`
	// Cautions about the email's own content that never block it: `mostly_images` (under 250
	// characters of text beside images), `link_shortener`, `mismatched_link_text` (a link's
	// text shows another domain), `shouting_subject` (mostly capitals or `!!`),
	// `heavy_images` (uploaded images over 1 MB, or more than 15 images). There is no spam
	// score: placement depends mostly on the sender's reputation.
	ContentWarnings []CampaignEligibilityContentWarning `json:"contentWarnings"`
	// The A/B test's expected split of the eligible recipients of the tested channel; `null`
	// without a test. A version that reaches nobody scores 0, a tie goes to the lowest
	// version, and the winner is sent to the rest even when the test reached nobody (version
	// 1 then).
	AbTestSplit *CampaignEligibilityAbTestSplit `json:"abTestSplit"`
	// Cautions about the A/B test that do not stop it: `empty_versions`, under one eligible
	// recipient expected per version, so a version will likely reach nobody (always returned
	// with `small_versions`, which it implies: show the stronger one); `small_versions`,
	// fewer than 1,000 eligible recipients per version, too few for a reliable winner;
	// `opens_measure`, opens decide, and machine opens (Apple Mail Privacy Protection,
	// Gmail's prefetch, mail scanners) count unread email as opened.
	AbTestWarnings []CampaignEligibilityAbTestWarning `json:"abTestWarnings"`
}

CampaignEligibility is defined by the Kirora API.

type CampaignEligibilityAbTestSplit

type CampaignEligibilityAbTestSplit struct {
	// Eligible recipients each version is expected to reach in the test: the test share
	// split evenly. Each contact is drawn on its own, so the real count varies around it,
	// and a version can reach nobody: likely under 1, possible at a few.
	ExpectedPerVersion float64 `json:"expectedPerVersion"`
	// Eligible recipients expected to wait for the winner: an expectation, like
	// `expectedPerVersion`, drawn the same way.
	ExpectedRest float64 `json:"expectedRest"`
}

CampaignEligibilityAbTestSplit: The A/B test's expected split of the eligible recipients of the tested channel; `null` without a test. A version that reaches nobody scores 0, a tie goes to the lowest version, and the winner is sent to the rest even when the test reached nobody (version 1 then).

type CampaignEligibilityAbTestWarning

type CampaignEligibilityAbTestWarning string

CampaignEligibilityAbTestWarning: Values other than these constants may be added to the API at any time.

const (
	CampaignEligibilityAbTestWarningEmptyVersions CampaignEligibilityAbTestWarning = "empty_versions"
	CampaignEligibilityAbTestWarningSmallVersions CampaignEligibilityAbTestWarning = "small_versions"
	CampaignEligibilityAbTestWarningOpensMeasure  CampaignEligibilityAbTestWarning = "opens_measure"
)

func (CampaignEligibilityAbTestWarning) IsKnown

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignEligibilityContentWarning

type CampaignEligibilityContentWarning struct {
	Code CampaignEligibilityContentWarningCode `json:"code"`
	// What to change, in plain words.
	Message string `json:"message"`
}

CampaignEligibilityContentWarning is defined by the Kirora API.

type CampaignEligibilityContentWarningCode

type CampaignEligibilityContentWarningCode string

CampaignEligibilityContentWarningCode: Values other than these constants may be added to the API at any time.

const (
	CampaignEligibilityContentWarningCodeMostlyImages       CampaignEligibilityContentWarningCode = "mostly_images"
	CampaignEligibilityContentWarningCodeLinkShortener      CampaignEligibilityContentWarningCode = "link_shortener"
	CampaignEligibilityContentWarningCodeMismatchedLinkText CampaignEligibilityContentWarningCode = "mismatched_link_text"
	CampaignEligibilityContentWarningCodeShoutingSubject    CampaignEligibilityContentWarningCode = "shouting_subject"
	CampaignEligibilityContentWarningCodeHeavyImages        CampaignEligibilityContentWarningCode = "heavy_images"
)

func (CampaignEligibilityContentWarningCode) IsKnown

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignExclusions

type CampaignExclusions struct {
	// Lists whose members are left out.
	ListIDs []string `json:"listIds"`
	// Segments whose members are left out, by the segment's rules at send.
	SegmentIDs []string `json:"segmentIds"`
}

CampaignExclusions is defined by the Kirora API.

type CampaignExclusionsInput

type CampaignExclusionsInput struct {
	// Lists whose members are left out.
	ListIDs []string `json:"listIds,omitzero"`
	// Segments whose members are left out, by the segment's rules at send.
	SegmentIDs []string `json:"segmentIds,omitzero"`
}

CampaignExclusionsInput is defined by the Kirora API.

type CampaignListItem

type CampaignListItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// The channels it sends on.
	Channels []Channel `json:"channels"`
	// Whether it goes to all contacts: everyone its channels reach, with consent and
	// suppressions applied as on any send.
	AllContacts bool `json:"allContacts"`
	// The lists it goes to, if any: a member of any of them receives it once.
	ListIDs []string `json:"listIds"`
	// The segment it goes to, if any.
	SegmentID *string `json:"segmentId"`
	// The names of the lists or the segment it went to, once one of them has been deleted
	// (the list leaves `listIds`, or `segmentId` becomes `null`). Only a sent or cancelled
	// campaign can lose its audience this way.
	AudienceName *string `json:"audienceName"`
	// Inline rules choosing the audience, if any. At most one audience is set.
	AudienceRules *SegmentRules `json:"audienceRules"`
	// Lists and segments left out of its audience ("don't send to"); `null` for none.
	Exclusions *CampaignExclusions `json:"exclusions"`
	// Sends only to contacts the topic reaches; `null` sends to everyone with consent.
	TopicID *string `json:"topicId"`
	// Where the campaign is in its lifecycle. `testing`: an A/B test went out and the rest
	// of the audience waits for the winner. `sent`: every message was created and queued; it
	// says nothing about delivery, which `GET /v1/campaigns/{id}/metrics` reports (some may
	// still be queued, skipped or failed).
	Status CampaignStatus `json:"status"`
	// When it sends: `fixed`, everyone at one instant, or `local_time`, each contact at a
	// time on their own clock. Set while it is `scheduled`; a local-time schedule stays set
	// once sending starts, since each contact's time still decides when theirs goes. `null`
	// otherwise.
	Schedule *CampaignSchedule `json:"schedule"`
	// When sending started; set from `sending` on (testing, sent, cancelled), `null` before.
	// A local-time campaign starts in the earliest timezone.
	SentAt *time.Time `json:"sentAt"`
	// An agent key authored or edited it and it is still a draft, so it waits in the agent
	// review queue: sending needs a person's approval.
	PendingAgentReview bool `json:"pendingAgentReview"`
	// The latest request, from a member in the dashboard, that an admin send it while the
	// workspace keeps sending to admins; kept after it sends, cleared by any edit before
	// then.
	SendApprovalRequest *CampaignSendApprovalRequest `json:"sendApprovalRequest"`
	// When it was archived; archived campaigns are left out of the list by default.
	ArchivedAt *time.Time `json:"archivedAt"`
	// Tag names, sorted without case.
	Tags      []string  `json:"tags"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

CampaignListItem is defined by the Kirora API.

type CampaignRateLimit

type CampaignRateLimit struct {
	// At most this many recipients per `per`, spread evenly across it. Counts people, so one
	// person's email and push go together.
	Recipients int `json:"recipients"`
	// The period the limit counts over.
	Per CampaignRateLimitPer `json:"per"`
}

CampaignRateLimit is defined by the Kirora API.

type CampaignRateLimitInput

type CampaignRateLimitInput = CampaignRateLimit

CampaignRateLimitInput is defined by the Kirora API.

type CampaignRateLimitPer

type CampaignRateLimitPer string

CampaignRateLimitPer: The period the limit counts over.

const (
	CampaignRateLimitPerMinute CampaignRateLimitPer = "minute"
	CampaignRateLimitPerHour   CampaignRateLimitPer = "hour"
	CampaignRateLimitPerDay    CampaignRateLimitPer = "day"
)

func (CampaignRateLimitPer) IsKnown

func (v CampaignRateLimitPer) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignRecipientInput

type CampaignRecipientInput struct {
	// Kirora's id for the contact.
	ContactID *string `json:"contactId,omitempty"`
	// This person's values; each key overrides the trigger's shared `data`.
	Data map[string]any `json:"data,omitzero"`
	// Your own id for the contact, as set with identify.
	ExternalID *string `json:"externalId,omitempty"`
	// The contact's email address, matched trimmed and without case.
	Email *string `json:"email,omitempty"`
}

CampaignRecipientInput is defined by the Kirora API.

type CampaignSchedule

type CampaignSchedule struct {
	Type CampaignScheduleType `json:"type"`
	// The instant everyone receives it at.
	SendAt *time.Time `json:"sendAt,omitempty"`
	// The wall-clock time (`YYYY-MM-DDTHH:MM`, no timezone) each contact receives it at on
	// their own clock. It may already have passed in some timezones, not in all.
	LocalDateTime *string `json:"localDateTime,omitempty"`
	// The IANA timezone for contacts without one; `null`: the workspace's.
	TimezoneIfUnknown Nullable[string] `json:"timezoneIfUnknown,omitzero"`
	// Where the time has already gone when it is scheduled: `send_now` sends there at once,
	// `next_day` at the same time the next day, and `skip` leaves those contacts out
	// (skipped with `local_time_passed`).
	IfTimeHasPassed *IfTimeHasPassed `json:"ifTimeHasPassed,omitempty"`
	// When sending starts: the earliest timezone reaching `localDateTime`.
	StartsAt *time.Time `json:"startsAt,omitempty"`
}

CampaignSchedule is defined by the Kirora API.

type CampaignScheduleType

type CampaignScheduleType string

CampaignScheduleType: Values other than these constants may be added to the API at any time.

const (
	CampaignScheduleTypeFixed     CampaignScheduleType = "fixed"
	CampaignScheduleTypeLocalTime CampaignScheduleType = "local_time"
)

func (CampaignScheduleType) IsKnown

func (v CampaignScheduleType) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignSendApprovalRequest

type CampaignSendApprovalRequest struct {
	// The member who asked.
	UserID      string    `json:"userId"`
	RequestedAt time.Time `json:"requestedAt"`
	Note        *string   `json:"note"`
}

CampaignSendApprovalRequest: The latest request, from a member in the dashboard, that an admin send it while the workspace keeps sending to admins; kept after it sends, cleared by any edit before then.

type CampaignStatus

type CampaignStatus string

CampaignStatus: Where the campaign is in its lifecycle. `testing`: an A/B test went out and the rest of the audience waits for the winner. `sent`: every message was created and queued; it says nothing about delivery, which `GET /v1/campaigns/{id}/metrics` reports (some may still be queued, skipped or failed).

const (
	CampaignStatusDraft     CampaignStatus = "draft"
	CampaignStatusScheduled CampaignStatus = "scheduled"
	CampaignStatusSending   CampaignStatus = "sending"
	CampaignStatusTesting   CampaignStatus = "testing"
	CampaignStatusSent      CampaignStatus = "sent"
	CampaignStatusCancelled CampaignStatus = "cancelled"
)

func (CampaignStatus) IsKnown

func (v CampaignStatus) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type CampaignUTM

type CampaignUTM struct {
	Enabled  bool    `json:"enabled"`
	Source   *string `json:"source,omitempty"`
	Medium   *string `json:"medium,omitempty"`
	Campaign *string `json:"campaign,omitempty"`
	Content  *string `json:"content,omitempty"`
	Term     *string `json:"term,omitempty"`
}

CampaignUTM is defined by the Kirora API.

type CampaignUTMInput

type CampaignUTMInput = CampaignUTM

CampaignUTMInput is defined by the Kirora API.

type CampaignsPage

type CampaignsPage = Page[CampaignListItem, CursorPaginationMeta]

CampaignsPage is a page of campaigns.

type CampaignsService

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

CampaignsService manages and sends campaigns.

func (*CampaignsService) All

All iterates over every campaign, fetching pages as it goes (listCampaigns).

func (*CampaignsService) Create

func (s *CampaignsService) Create(ctx context.Context, params *CreateCampaignInput, opts ...CallOption) (*Campaign, error)

Create creates a draft campaign (createCampaign). Retries reuse one idempotency key, so they never create two.

func (*CampaignsService) Eligibility

func (s *CampaignsService) Eligibility(ctx context.Context, campaignID string, opts ...CallOption) (*CampaignEligibility, error)

Eligibility lists anything that would block sending a campaign, without sending it (getCampaignEligibility).

func (*CampaignsService) Get

func (s *CampaignsService) Get(ctx context.Context, campaignID string, opts ...CallOption) (*Campaign, error)

Get fetches a campaign (getCampaign).

func (*CampaignsService) List

List fetches a page of campaigns (listCampaigns). See All for every campaign.

func (*CampaignsService) Schedule

func (s *CampaignsService) Schedule(ctx context.Context, campaignID string, params *ScheduleCampaignInput, opts ...CallOption) (*Campaign, error)

Schedule schedules a draft campaign, or reschedules one that hasn't started sending (scheduleCampaign). Type CampaignScheduleTypeFixed sends at SendAt for everyone; CampaignScheduleTypeLocalTime at LocalDateTime on each contact's own clock. A key is made for the call, so a retry replays the result rather than failing once the send has started.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	eligibility, err := client.Campaigns.Eligibility(ctx, "campaign-id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(eligibility.CanSend)

	sendAt := time.Now().Add(time.Hour)
	_, err = client.Campaigns.Schedule(ctx, "campaign-id", &kirora.ScheduleCampaignInput{
		Type:   kirora.CampaignScheduleTypeFixed,
		SendAt: &sendAt,
	})
	if err != nil {
		log.Fatal(err)
	}
}

func (*CampaignsService) Send

func (s *CampaignsService) Send(ctx context.Context, campaignID string, opts ...CallOption) (*Campaign, error)

Send sends a campaign now (sendCampaign). A campaign is only ever sent once, so Send and Schedule are alternatives. A key is made for the call, so a retry replays the result rather than failing once the send has started.

func (*CampaignsService) Trigger

func (s *CampaignsService) Trigger(ctx context.Context, campaignID string, params *TriggerCampaignInput, opts ...CallOption) (*TriggeredCampaign, error)

Trigger sends a campaign to the given contacts, each with its own Data, instead of its saved audience (triggerCampaign).

type Channel

type Channel string

Channel: Values other than these constants may be added to the API at any time.

const (
	ChannelEmail Channel = "email"
	ChannelPush  Channel = "push"
)

func (Channel) IsKnown

func (v Channel) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ChannelEligibility

type ChannelEligibility struct {
	Value ChannelEligibilityValue
}

ChannelEligibility is one of the following, told apart by "channel": EmailEligibility ("email"), PushEligibility ("push").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (ChannelEligibility) MarshalJSON

func (u ChannelEligibility) MarshalJSON() ([]byte, error)

func (*ChannelEligibility) UnmarshalJSON

func (u *ChannelEligibility) UnmarshalJSON(data []byte) error

type ChannelEligibilityValue

type ChannelEligibilityValue interface {
	// contains filtered or unexported methods
}

ChannelEligibilityValue is implemented by each kind of ChannelEligibility, and by Unknown.

type ChannelInput

type ChannelInput = Channel

ChannelInput is defined by the Kirora API.

type Client

type Client struct {
	Contacts      *ContactsService
	Lists         *ListsService
	Campaigns     *CampaignsService
	Transactional *TransactionalService
	Events        *EventsService
	Messages      *MessagesService
	Suppressions  *SuppressionsService

	// Workspaces manages a partner key's tenant workspaces. See Client.ForWorkspace to
	// act inside one.
	Workspaces *WorkspacesService

	EmbedSessions *EmbedSessionsService
	// contains filtered or unexported fields
}

Client calls the Kirora API. Each field is a service grouping the API's operations on one resource. A Client is safe for concurrent use. Create one with NewClient.

func NewClient

func NewClient(apiKey string, opts ...ClientOption) (*Client, error)

NewClient returns a Client that authenticates with apiKey. An empty apiKey is read from the KIRORA_API_KEY environment variable instead, and KIRORA_BASE_URL, when set, is used as with WithBaseURL; opts override both. Surrounding spaces and quotes around the key are ignored, as from a pasted .env value. It returns an error if there is no key (a key of "undefined" or "null" counts as none) or an option is invalid.

func (*Client) ForWorkspace

func (c *Client) ForWorkspace(externalID string) *Client

ForWorkspace returns a copy of c whose calls act in the partner workspace with the given externalId, as WithWorkspace does. c itself is unchanged. If externalID is empty, every call on the returned Client fails rather than acting in the key's own workspace.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	_, err := client.Workspaces.Create(ctx, &kirora.CreateWorkspaceInput{Name: "Acme", ExternalID: "tenant-42", Country: "GB"})
	if err != nil {
		log.Fatal(err)
	}
	// ForWorkspace acts in the tenant's workspace, named by the externalId given above.
	session, err := client.ForWorkspace("tenant-42").EmbedSessions.Create(ctx, &kirora.CreateEmbedSessionInput{
		Components: []kirora.EmbedComponent{kirora.EmbedComponentEmailBuilder},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(session.Token)
}

func (*Client) Me

func (c *Client) Me(ctx context.Context, opts ...CallOption) (*APICaller, error)

Me returns the workspace and API key that the client's requests act as.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body, out any, opts ...CallOption) error

Request calls an endpoint that has no method in this SDK, with the same authentication, retries and errors as the methods. path starts with /v1 and may end in a query string. A non-nil body is sent as JSON, and out, unless nil, receives the whole JSON response body, envelope included.

An endpoint this version of the SDK knows is retried as its method would be. On a newer one, a POST or PATCH is retried after a network error or 5xx only if the call has an idempotency key; see WithIdempotencyKey. API errors are returned as *Error, failures to get a response as *ConnectionError, and responses that aren't JSON as *ResponseError.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"net/http"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	type Segment struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	}
	var resp struct {
		Data Segment `json:"data"`
	}
	if err := client.Request(ctx, http.MethodGet, "/v1/segments/segment-id", nil, &resp); err != nil {
		log.Fatal(err)
	}
	// RequestAll pages through a list endpoint as the All methods do.
	for segment, err := range kirora.RequestAll[Segment](ctx, client, "/v1/segments", nil) {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(segment.Name)
	}
}

func (*Client) RequestRaw

func (c *Client) RequestRaw(ctx context.Context, method, path string, body any, opts ...CallOption) (*http.Response, error)

RequestRaw calls an endpoint as Request does, but returns a successful response with its body unread, such as a large export to stream to a file. Close the body when done. The timeout from WithTimeout ends once the headers arrive, so it doesn't limit reading the body; cancelling ctx still stops it. An error response is returned as an *Error, as from Request.

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption configures a Client in NewClient. Every Option is one.

func WithAppInfo

func WithAppInfo(name, version string) ClientOption

WithAppInfo adds your app to the User-Agent header, as name or name/version, after the SDK's own. version may be empty. Each can only have letters, digits, ".", "-" and "_"; NewClient returns an error otherwise. NewClient takes it, not a method.

type Columns3Block

type Columns3Block struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Each column's share of the row in percent, left to right, one per column and adding up
	// to 100, such as [33, 67]. Omit for equal columns.
	Widths []int `json:"widths,omitzero"`
	// Where shorter columns sit against the tallest one.
	Valign *VerticalAlign `json:"valign,omitempty"`
	// False keeps the columns side by side on phones too, such as a two-across product grid;
	// by default they stack.
	StackOnMobile *bool `json:"stackOnMobile,omitempty"`
	// The child blocks of each column, left to right: exactly 3 arrays.
	Columns [][]EmailBlock `json:"columns"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

Columns3Block is defined by the Kirora API.

func (Columns3Block) MarshalJSON

func (v Columns3Block) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "columns3", which identifies a Columns3Block, and the properties in Extra.

func (*Columns3Block) UnmarshalJSON

func (v *Columns3Block) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type Columns3BlockInput

type Columns3BlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Each column's share of the row in percent, left to right, one per column and adding up
	// to 100, such as [33, 67]. Omit for equal columns.
	Widths []int `json:"widths,omitzero"`
	// Where shorter columns sit against the tallest one.
	Valign *VerticalAlign `json:"valign,omitempty"`
	// False keeps the columns side by side on phones too, such as a two-across product grid;
	// by default they stack.
	StackOnMobile *bool `json:"stackOnMobile,omitempty"`
	// The child blocks of each column, left to right: exactly 3 arrays.
	Columns [][]EmailBlockInput `json:"columns"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

Columns3BlockInput is defined by the Kirora API.

func (Columns3BlockInput) MarshalJSON

func (v Columns3BlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "columns3", which identifies a Columns3BlockInput, and the properties in Extra.

func (*Columns3BlockInput) UnmarshalJSON

func (v *Columns3BlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ColumnsBlock

type ColumnsBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Each column's share of the row in percent, left to right, one per column and adding up
	// to 100, such as [33, 67]. Omit for equal columns.
	Widths []int `json:"widths,omitzero"`
	// Where shorter columns sit against the tallest one.
	Valign *VerticalAlign `json:"valign,omitempty"`
	// False keeps the columns side by side on phones too, such as a two-across product grid;
	// by default they stack.
	StackOnMobile *bool `json:"stackOnMobile,omitempty"`
	// The child blocks of each column, left to right: exactly 2 arrays.
	Columns [][]EmailBlock `json:"columns"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ColumnsBlock is defined by the Kirora API.

func (ColumnsBlock) MarshalJSON

func (v ColumnsBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "columns", which identifies a ColumnsBlock, and the properties in Extra.

func (*ColumnsBlock) UnmarshalJSON

func (v *ColumnsBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ColumnsBlockInput

type ColumnsBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Each column's share of the row in percent, left to right, one per column and adding up
	// to 100, such as [33, 67]. Omit for equal columns.
	Widths []int `json:"widths,omitzero"`
	// Where shorter columns sit against the tallest one.
	Valign *VerticalAlign `json:"valign,omitempty"`
	// False keeps the columns side by side on phones too, such as a two-across product grid;
	// by default they stack.
	StackOnMobile *bool `json:"stackOnMobile,omitempty"`
	// The child blocks of each column, left to right: exactly 2 arrays.
	Columns [][]EmailBlockInput `json:"columns"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ColumnsBlockInput is defined by the Kirora API.

func (ColumnsBlockInput) MarshalJSON

func (v ColumnsBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "columns", which identifies a ColumnsBlockInput, and the properties in Extra.

func (*ColumnsBlockInput) UnmarshalJSON

func (v *ColumnsBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ConnectionError

type ConnectionError struct {
	// Op is the request's method and path.
	Op  string
	Err error
	// contains filtered or unexported fields
}

ConnectionError is returned when no complete response arrived, such as after a network error, a timeout, or the connection dropping while the body was read.

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

func (*ConnectionError) Timeout

func (e *ConnectionError) Timeout() bool

Timeout reports whether the attempt took longer than its timeout (see WithTimeout), or Err reports a timeout of its own.

func (*ConnectionError) Unwrap

func (e *ConnectionError) Unwrap() error

type ConsentActorType

type ConsentActorType string

ConsentActorType: Values other than these constants may be added to the API at any time.

const (
	ConsentActorTypeUser    ConsentActorType = "user"
	ConsentActorTypeAPIKey  ConsentActorType = "api_key"
	ConsentActorTypeContact ConsentActorType = "contact"
	ConsentActorTypeSystem  ConsentActorType = "system"
)

func (ConsentActorType) IsKnown

func (v ConsentActorType) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ConsentBasis

type ConsentBasis string

ConsentBasis: How the person agreed, as the workspace stated it; null when nobody did.

const (
	ConsentBasisOptedIn          ConsentBasis = "opted_in"
	ConsentBasisExistingCustomer ConsentBasis = "existing_customer"
)

func (ConsentBasis) IsKnown

func (v ConsentBasis) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ConsentSource

type ConsentSource string

ConsentSource: Values other than these constants may be added to the API at any time.

const (
	ConsentSourceDashboard   ConsentSource = "dashboard"
	ConsentSourceAPI         ConsentSource = "api"
	ConsentSourceImport      ConsentSource = "import"
	ConsentSourceForm        ConsentSource = "form"
	ConsentSourceUnsubscribe ConsentSource = "unsubscribe"
	ConsentSourceSystem      ConsentSource = "system"
	ConsentSourceSDK         ConsentSource = "sdk"
)

func (ConsentSource) IsKnown

func (v ConsentSource) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ConsentStatementInput

type ConsentStatementInput struct {
	// The legal basis the contacts agreed under.
	Basis ConsentBasis `json:"basis"`
	// Where and how they agreed, e.g. "Checkout opt-in on shop.example.com".
	Evidence string `json:"evidence"`
	// When they agreed, if before now: a signup imported or synced later. Omitted, it is
	// when Kirora records the grant.
	ConsentedAt *time.Time `json:"consentedAt,omitempty"`
	// The words they agreed to, e.g. the checkbox label they ticked.
	Wording *string `json:"wording,omitempty"`
}

ConsentStatementInput is defined by the Kirora API.

type ContactConsent

type ContactConsent struct {
	// Whether the contact has consented to email.
	Email bool `json:"email"`
	// Whether the contact has consented to push.
	Push bool `json:"push"`
}

ContactConsent is defined by the Kirora API.

type ContactDataExport

type ContactDataExport struct {
	// When this export was produced.
	ExportedAt      time.Time                         `json:"exportedAt"`
	Contact         ContactDetail                     `json:"contact"`
	ConsentChanges  []ContactDataExportConsentChange  `json:"consentChanges"`
	Events          []ContactDataExportEvent          `json:"events"`
	Messages        []ContactDataExportMessage        `json:"messages"`
	Lists           []ContactDataExportList           `json:"lists"`
	Segments        []ContactDataExportSegment        `json:"segments"`
	Topics          []ContactDataExportTopic          `json:"topics"`
	Journeys        []ContactDataExportJourney        `json:"journeys"`
	PushDevices     []ContactDataExportPushDevice     `json:"pushDevices"`
	FormSubmissions []ContactDataExportFormSubmission `json:"formSubmissions"`
	Conversions     []ContactDataExportConversion     `json:"conversions"`
	Suppressions    []ContactDataExportSuppression    `json:"suppressions"`
}

ContactDataExport is defined by the Kirora API.

type ContactDataExportConsentChange

type ContactDataExportConsentChange struct {
	ID string `json:"id"`
	// The channel consented to. With `topicId` null: consent to the channel; with both set:
	// a per-channel topic choice.
	Channel *Channel `json:"channel"`
	// The topic consented to, if any.
	TopicID *string `json:"topicId"`
	// True for a grant, false for a withdrawal.
	Granted bool          `json:"granted"`
	Source  ConsentSource `json:"source"`
	// The form, when `source` is `form`.
	SourceID  *string          `json:"sourceId"`
	ActorType ConsentActorType `json:"actorType"`
	// Member or API key id; null for the contact themselves and the system.
	ActorID *string `json:"actorId"`
	// IP address the change came from.
	IP *string `json:"ip"`
	// Why it changed, when one was given.
	Reason *string `json:"reason"`
	// How the person agreed, as the workspace stated it; null when nobody did.
	Basis *ConsentBasis `json:"basis"`
	// Where and how they agreed, as stated.
	Evidence *string `json:"evidence"`
	// When they agreed, as stated; null means at `occurredAt`.
	ConsentedAt *time.Time `json:"consentedAt"`
	// The words they agreed to, as stated.
	Wording    *string   `json:"wording"`
	OccurredAt time.Time `json:"occurredAt"`
}

ContactDataExportConsentChange is defined by the Kirora API.

type ContactDataExportConversion

type ContactDataExportConversion struct {
	ConversionGoalID string `json:"conversionGoalId"`
	// Value recorded with the conversion, in its conversion goal's currency, if any.
	Value       *Money    `json:"value"`
	ConvertedAt time.Time `json:"convertedAt"`
}

ContactDataExportConversion is defined by the Kirora API.

type ContactDataExportEvent

type ContactDataExportEvent struct {
	ID         string         `json:"id"`
	EventName  string         `json:"eventName"`
	Properties map[string]any `json:"properties"`
	OccurredAt time.Time      `json:"occurredAt"`
}

ContactDataExportEvent is defined by the Kirora API.

type ContactDataExportFormSubmission

type ContactDataExportFormSubmission struct {
	FormID      string                `json:"formId"`
	FormName    string                `json:"formName"`
	Outcome     FormSubmissionOutcome `json:"outcome"`
	CreatedAt   time.Time             `json:"createdAt"`
	ConfirmedAt *time.Time            `json:"confirmedAt"`
	// What an unconfirmed signup entered, held until confirmed or for 7 days.
	PendingContact map[string]any `json:"pendingContact"`
}

ContactDataExportFormSubmission is defined by the Kirora API.

type ContactDataExportJourney

type ContactDataExportJourney struct {
	// Null once the journey has been deleted.
	JourneyID *string `json:"journeyId"`
	// Null once the journey has been deleted.
	JourneyName *string       `json:"journeyName"`
	Status      JourneyStatus `json:"status"`
	EnteredAt   time.Time     `json:"enteredAt"`
	EndedAt     *time.Time    `json:"endedAt"`
}

ContactDataExportJourney is defined by the Kirora API.

type ContactDataExportList

type ContactDataExportList struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	AddedAt time.Time `json:"addedAt"`
}

ContactDataExportList is defined by the Kirora API.

type ContactDataExportMessage

type ContactDataExportMessage struct {
	ID          string        `json:"id"`
	CampaignID  *string       `json:"campaignId"`
	Channel     Channel       `json:"channel"`
	MessageType MessageType   `json:"messageType"`
	Status      MessageStatus `json:"status"`
	// The email address it went to; `null` for push.
	RecipientEmail *string    `json:"recipientEmail"`
	SentAt         *time.Time `json:"sentAt"`
	DeliveredAt    *time.Time `json:"deliveredAt"`
	OpenedAt       *time.Time `json:"openedAt"`
	ClickedAt      *time.Time `json:"clickedAt"`
	UnsubscribedAt *time.Time `json:"unsubscribedAt"`
	CreatedAt      time.Time  `json:"createdAt"`
}

ContactDataExportMessage is defined by the Kirora API.

type ContactDataExportPushDevice

type ContactDataExportPushDevice struct {
	Kind PushTargetKind `json:"kind"`
	// Notification permission on the device.
	Permission PushPermission `json:"permission"`
	// Whether the device can still receive push.
	Active     bool      `json:"active"`
	LastSeenAt time.Time `json:"lastSeenAt"`
	CreatedAt  time.Time `json:"createdAt"`
}

ContactDataExportPushDevice is defined by the Kirora API.

type ContactDataExportSegment

type ContactDataExportSegment struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	EnteredAt time.Time `json:"enteredAt"`
}

ContactDataExportSegment is defined by the Kirora API.

type ContactDataExportSuppression

type ContactDataExportSuppression struct {
	Channel Channel `json:"channel"`
	// Set when the block is on the address itself, not the contact.
	Address *string `json:"address"`
	// Why the channel is blocked.
	Reason    string    `json:"reason"`
	CreatedAt time.Time `json:"createdAt"`
}

ContactDataExportSuppression is defined by the Kirora API.

type ContactDataExportTopic

type ContactDataExportTopic struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Whether the contact is subscribed to the topic.
	Subscribed bool      `json:"subscribed"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

ContactDataExportTopic is defined by the Kirora API.

type ContactDatesInput

type ContactDatesInput = map[string]*string

ContactDatesInput is defined by the Kirora API.

type ContactDetail

type ContactDetail struct {
	ID string `json:"id"`
	// Your own id for the contact, if set.
	ExternalID *string `json:"externalId"`
	Email      *string `json:"email"`
	FirstName  *string `json:"firstName"`
	LastName   *string `json:"lastName"`
	// Phone number in E.164 format.
	Phone *string `json:"phone"`
	// IANA timezone, e.g. `Europe/London`.
	Timezone *string `json:"timezone"`
	// ISO 3166-1 alpha-2 code: as written, or inferred from the phone, else the timezone.
	Country *string `json:"country"`
	// BCP 47 tag (`fr`, `fr-CA`): the language the contact reads (its first subtag), and how
	// merge tags format numbers, dates and money for them.
	Locale *string `json:"locale"`
	// The contact's RFM (recency, frequency and monetary value) group among the workspace's
	// customers, from its purchase events (the workspace's `purchaseEvent`: an order, a paid
	// invoice, a booking, a donation), each score from 1 to 5 (a fifth of the customers
	// each; 5 is the most recent, most frequent or highest spend), and their purchase
	// totals. Spend counts only purchases in the workspace's main currency; when the
	// purchase carries no amount, `monetary` follows frequency. Recomputed daily, so a
	// purchase today shows tomorrow; `null` for someone who has never purchased.
	RFM           *ContactRFM           `json:"rfm"`
	PurchaseCycle *ContactPurchaseCycle `json:"purchaseCycle"`
	// Named calendar dates, e.g. `birthday`, as `YYYY-MM-DD` or `--MM-DD`.
	Dates map[string]string `json:"dates"`
	// Custom attributes, keyed by attribute name.
	Attributes map[string]any `json:"attributes"`
	// Consent on each channel.
	Consent          ContactConsent                `json:"consent"`
	CreatedAt        time.Time                     `json:"createdAt"`
	UpdatedAt        time.Time                     `json:"updatedAt"`
	EmailSuppression ContactDetailEmailSuppression `json:"emailSuppression"`
	// Ids of the lists the contact is in.
	ListIDs []string `json:"listIds"`
}

ContactDetail is defined by the Kirora API.

type ContactDetailEmailSuppression

type ContactDetailEmailSuppression struct {
	// Whether email to this contact is blocked.
	Suppressed bool `json:"suppressed"`
	// Why email to this contact is suppressed: `bounced`, `complained`,
	// `complained_transactional`, `unsubscribed`, `manual`, `imported`, or `other_workspace`
	// (a bounce or complaint in another workspace with the same owner or partner).
	Reason *string `json:"reason"`
}

ContactDetailEmailSuppression is defined by the Kirora API.

type ContactFieldCondition

type ContactFieldCondition struct {
	// The contact column to test. Each takes these operators, and is refused with others:
	// `email`: equals, notEquals, contains, startsWith, exists, notExists, in; `firstName`:
	// equals, notEquals, contains, startsWith, exists, notExists, in; `lastName`: equals,
	// notEquals, contains, startsWith, exists, notExists, in; `phone`: equals, notEquals,
	// contains, startsWith, exists, notExists, in; `timezone`: equals, notEquals, contains,
	// startsWith, exists, notExists, in; `externalId`: equals, notEquals, contains,
	// startsWith, exists, notExists, in; `consent.email`: equals; `consent.push`: equals;
	// `country`: equals, notEquals, in, exists, notExists; `locale`: equals, notEquals,
	// startsWith, in, exists, notExists; `createdAt`: before, after, withinLastDays,
	// moreThanDaysAgo; `rfmGroup`: equals, notEquals, in, exists, notExists; `rfmRecency`:
	// equals, notEquals, in, exists, notExists, gt, gte, lt, lte; `rfmFrequency`: equals,
	// notEquals, in, exists, notExists, gt, gte, lt, lte; `rfmMonetary`: equals, notEquals,
	// in, exists, notExists, gt, gte, lt, lte; `purchaseCount`: equals, gt, gte, lt, lte;
	// `totalSpent`: equals, gt, gte, lt, lte; `lastPurchasedAt`: before, after,
	// withinLastDays, moreThanDaysAgo, exists, notExists; `daysBetweenPurchases`: gt, gte,
	// lt, lte, exists, notExists; `purchaseOverdueRatio`: gt, gte, lt, lte, exists,
	// notExists; `purchaseCycleStatus`: equals, notEquals, in, exists, notExists. `phone`
	// holds +country numbers: write `equals`, `notEquals` and `in` values with their country
	// code. Consent takes `"true"` or `"false"`.
	//
	// Purchases: `purchaseCount`, `totalSpent` (in the main currency) and `lastPurchasedAt`
	// are a customer's totals of the workspace's purchase event (`purchaseEvent` in
	// workspace settings: an order, a paid invoice, a booking), recomputed daily; the
	// contact's stored `totalSpent` is null when the workspace's purchases carry no amount.
	// In comparisons on `purchaseCount` and `totalSpent` a missing count or spend is 0, so
	// someone who never purchased has 0 purchases and 0 spent.
	//
	// RFM: `rfmGroup` and its scores `rfmRecency`, `rfmFrequency` and `rfmMonetary`
	// (monetary value: how much they spend) come from the same daily pass. A score is a
	// whole number from 1 to 5, written as text (`"5"`; `values` of them for `in`), 5 being
	// the most recent, most frequent or highest spending; any other value is refused with
	// 400. Someone who never purchased has no `rfmGroup` or scores: on those four fields
	// they match only `notExists` and `notEquals`. So `rfmRecency` `notEquals` 5 includes
	// everyone who never purchased; add an `exists` rule on the same field to leave them out
	// (bought, but not recently).
	//
	// Purchase cycle: `daysBetweenPurchases` is a regular buyer's usual (median) days
	// between purchase days; `purchaseOverdueRatio` the days since their last purchase over
	// that (1.5 is half a cycle late), worked out when the rule runs; `purchaseCycleStatus`
	// its label: `overdue` from 1.5×, `lapsed` from 2×, `dormant` from 3×, else
	// `on_track`. Only a contact with 4 or more purchase days and a regular pattern has
	// them: anyone else matches only `notExists` and `notEquals`, and is never called
	// overdue. These three are on plans that include Kiro: elsewhere a rule on them is
	// refused with 403 `PLAN_FEATURE_UNAVAILABLE`.
	Field ContactFieldConditionField `json:"field"`
	// How to compare. Text comparisons (`equals`, `notEquals`, `contains`, `notContains`,
	// `startsWith`, `in`) ignore case and accents ("jose" matches "José"). `notEquals` and
	// `notContains` also match contacts without the value. Date operators (`before`,
	// `after`, `withinLastDays`, `moreThanDaysAgo`) compare as dates and times in UTC: a
	// stored ISO-8601 date is the start of that day, `before` means earlier than the given
	// day and `after` later than it, and a value that is not an ISO-8601 date or date and
	// time never matches. `inNextDays` is a date from today to that many days ahead.
	// `anniversaryInNextDays` (0 = today) and `anniversaryThisMonth` ignore the year, so
	// they suit birthdays, and also read a yearless `--MM-DD`; a 29 February counts on 28
	// February in other years. Days are UTC days; these three are for attributes and dates,
	// not contact fields.
	Operator AttributeConditionOperator `json:"operator"`
	// What to compare with, always as text: `"pro"`, `"3"`, `"true"`. Equality compares the
	// stored value as text, so a stored 5 matches `"5"`. An ISO date for `before` and
	// `after`; a number for `gt`, `gte`, `lt` and `lte`; a whole number of days (1 to 3650)
	// for `withinLastDays`, `moreThanDaysAgo` and `inNextDays`, and 0 to 365 for
	// `anniversaryInNextDays`. Omit for `in`, `exists`, `notExists` and
	// `anniversaryThisMonth`.
	Value *string `json:"value,omitempty"`
	// For `in` only: up to 100 values, each as text, any of which matches.
	Values []string `json:"values,omitzero"`
}

ContactFieldCondition is defined by the Kirora API.

func (ContactFieldCondition) MarshalJSON

func (v ContactFieldCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "contact", which identifies a ContactFieldCondition.

type ContactFieldConditionField

type ContactFieldConditionField string

ContactFieldConditionField: The contact column to test. Each takes these operators, and is refused with others: `email`: equals, notEquals, contains, startsWith, exists, notExists, in; `firstName`: equals, notEquals, contains, startsWith, exists, notExists, in; `lastName`: equals, notEquals, contains, startsWith, exists, notExists, in; `phone`: equals, notEquals, contains, startsWith, exists, notExists, in; `timezone`: equals, notEquals, contains, startsWith, exists, notExists, in; `externalId`: equals, notEquals, contains, startsWith, exists, notExists, in; `consent.email`: equals; `consent.push`: equals; `country`: equals, notEquals, in, exists, notExists; `locale`: equals, notEquals, startsWith, in, exists, notExists; `createdAt`: before, after, withinLastDays, moreThanDaysAgo; `rfmGroup`: equals, notEquals, in, exists, notExists; `rfmRecency`: equals, notEquals, in, exists, notExists, gt, gte, lt, lte; `rfmFrequency`: equals, notEquals, in, exists, notExists, gt, gte, lt, lte; `rfmMonetary`: equals, notEquals, in, exists, notExists, gt, gte, lt, lte; `purchaseCount`: equals, gt, gte, lt, lte; `totalSpent`: equals, gt, gte, lt, lte; `lastPurchasedAt`: before, after, withinLastDays, moreThanDaysAgo, exists, notExists; `daysBetweenPurchases`: gt, gte, lt, lte, exists, notExists; `purchaseOverdueRatio`: gt, gte, lt, lte, exists, notExists; `purchaseCycleStatus`: equals, notEquals, in, exists, notExists. `phone` holds +country numbers: write `equals`, `notEquals` and `in` values with their country code. Consent takes `"true"` or `"false"`.

Purchases: `purchaseCount`, `totalSpent` (in the main currency) and `lastPurchasedAt` are a customer's totals of the workspace's purchase event (`purchaseEvent` in workspace settings: an order, a paid invoice, a booking), recomputed daily; the contact's stored `totalSpent` is null when the workspace's purchases carry no amount. In comparisons on `purchaseCount` and `totalSpent` a missing count or spend is 0, so someone who never purchased has 0 purchases and 0 spent.

RFM: `rfmGroup` and its scores `rfmRecency`, `rfmFrequency` and `rfmMonetary` (monetary value: how much they spend) come from the same daily pass. A score is a whole number from 1 to 5, written as text (`"5"`; `values` of them for `in`), 5 being the most recent, most frequent or highest spending; any other value is refused with 400. Someone who never purchased has no `rfmGroup` or scores: on those four fields they match only `notExists` and `notEquals`. So `rfmRecency` `notEquals` 5 includes everyone who never purchased; add an `exists` rule on the same field to leave them out (bought, but not recently).

Purchase cycle: `daysBetweenPurchases` is a regular buyer's usual (median) days between purchase days; `purchaseOverdueRatio` the days since their last purchase over that (1.5 is half a cycle late), worked out when the rule runs; `purchaseCycleStatus` its label: `overdue` from 1.5×, `lapsed` from 2×, `dormant` from 3×, else `on_track`. Only a contact with 4 or more purchase days and a regular pattern has them: anyone else matches only `notExists` and `notEquals`, and is never called overdue. These three are on plans that include Kiro: elsewhere a rule on them is refused with 403 `PLAN_FEATURE_UNAVAILABLE`.

const (
	ContactFieldConditionFieldEmail                ContactFieldConditionField = "email"
	ContactFieldConditionFieldFirstName            ContactFieldConditionField = "firstName"
	ContactFieldConditionFieldLastName             ContactFieldConditionField = "lastName"
	ContactFieldConditionFieldPhone                ContactFieldConditionField = "phone"
	ContactFieldConditionFieldTimezone             ContactFieldConditionField = "timezone"
	ContactFieldConditionFieldExternalID           ContactFieldConditionField = "externalId"
	ContactFieldConditionFieldConsentEmail         ContactFieldConditionField = "consent.email"
	ContactFieldConditionFieldConsentPush          ContactFieldConditionField = "consent.push"
	ContactFieldConditionFieldCountry              ContactFieldConditionField = "country"
	ContactFieldConditionFieldLocale               ContactFieldConditionField = "locale"
	ContactFieldConditionFieldCreatedAt            ContactFieldConditionField = "createdAt"
	ContactFieldConditionFieldRFMGroup             ContactFieldConditionField = "rfmGroup"
	ContactFieldConditionFieldRFMRecency           ContactFieldConditionField = "rfmRecency"
	ContactFieldConditionFieldRFMFrequency         ContactFieldConditionField = "rfmFrequency"
	ContactFieldConditionFieldRFMMonetary          ContactFieldConditionField = "rfmMonetary"
	ContactFieldConditionFieldPurchaseCount        ContactFieldConditionField = "purchaseCount"
	ContactFieldConditionFieldTotalSpent           ContactFieldConditionField = "totalSpent"
	ContactFieldConditionFieldLastPurchasedAt      ContactFieldConditionField = "lastPurchasedAt"
	ContactFieldConditionFieldDaysBetweenPurchases ContactFieldConditionField = "daysBetweenPurchases"
	ContactFieldConditionFieldPurchaseOverdueRatio ContactFieldConditionField = "purchaseOverdueRatio"
	ContactFieldConditionFieldPurchaseCycleStatus  ContactFieldConditionField = "purchaseCycleStatus"
)

func (ContactFieldConditionField) IsKnown

func (v ContactFieldConditionField) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ContactFieldConditionInput

type ContactFieldConditionInput = ContactFieldCondition

ContactFieldConditionInput is defined by the Kirora API.

type ContactIdentifier

type ContactIdentifier struct {
	// Kirora's id for the contact.
	ContactID *string `json:"contactId,omitempty"`
	// Your own id for the contact, as set with identify.
	ExternalID *string `json:"externalId,omitempty"`
	// The contact's email address, matched trimmed and without case.
	Email *string `json:"email,omitempty"`
}

ContactIdentifier is defined by the Kirora API.

type ContactIdentifierInput

type ContactIdentifierInput = ContactIdentifier

ContactIdentifierInput is defined by the Kirora API.

type ContactListMembership

type ContactListMembership struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	// When the contact joined the list.
	AddedAt time.Time `json:"addedAt"`
}

ContactListMembership is defined by the Kirora API.

type ContactListMeta

type ContactListMeta struct {
	Pagination Pagination `json:"pagination"`
	// Contacts matching the filters, counted up to 10000; the cap when there are more. Null
	// after the first page: it does not change between pages.
	Count *int `json:"count"`
	// False when `count` is the cap and more contacts match; null with it.
	CountExact *bool `json:"countExact"`
}

ContactListMeta is defined by the Kirora API.

type ContactListsPage

type ContactListsPage = Page[ContactListMembership, CursorPaginationMeta]

ContactListsPage is a page of the lists a contact belongs to.

type ContactPurchaseCycle added in v0.2.0

type ContactPurchaseCycle struct {
	// `regular`: their usual time between purchases is known; `not_enough_history`: fewer
	// than 4 purchase days; `irregular`: no regular pattern. Only a regular buyer is ever
	// overdue.
	Pattern ContactPurchaseCyclePattern `json:"pattern"`
	// The median number of days between purchase days; null unless `regular`.
	UsualDaysBetweenPurchases *float64 `json:"usualDaysBetweenPurchases"`
	// The last purchase day, in UTC.
	LastPurchasedOn string `json:"lastPurchasedOn"`
	// The last purchase day plus the usual time between purchases; null unless `regular`.
	ExpectedNextPurchaseOn *string `json:"expectedNextPurchaseOn"`
	DaysSinceLastPurchase  int     `json:"daysSinceLastPurchase"`
	// Days since the last purchase over the usual time between purchases: 1 is due today,
	// 1.5 half a cycle late. Null unless `regular`.
	OverdueRatio *float64 `json:"overdueRatio"`
	// `overdue` from 1.5× the usual time between purchases, `lapsed` from 2×, `dormant`
	// from 3×, else `on_track`; null unless `regular`.
	CycleStatus *ContactPurchaseCycleCycleStatus `json:"cycleStatus"`
	// Why, in plain words: "Usually buys every 30 days; it's been 52."
	Reason string `json:"reason"`
}

ContactPurchaseCycle: The contact's purchase cycle from the workspace's purchase event, worked out daily; null for someone who never purchased, and on plans that do not include Kiro.

type ContactPurchaseCycleCycleStatus added in v0.2.0

type ContactPurchaseCycleCycleStatus string

ContactPurchaseCycleCycleStatus: `overdue` from 1.5× the usual time between purchases, `lapsed` from 2×, `dormant` from 3×, else `on_track`; null unless `regular`.

const (
	ContactPurchaseCycleCycleStatusOnTrack ContactPurchaseCycleCycleStatus = "on_track"
	ContactPurchaseCycleCycleStatusOverdue ContactPurchaseCycleCycleStatus = "overdue"
	ContactPurchaseCycleCycleStatusLapsed  ContactPurchaseCycleCycleStatus = "lapsed"
	ContactPurchaseCycleCycleStatusDormant ContactPurchaseCycleCycleStatus = "dormant"
)

func (ContactPurchaseCycleCycleStatus) IsKnown added in v0.2.0

IsKnown is false for a value added to the API after this version of the SDK.

type ContactPurchaseCyclePattern added in v0.2.0

type ContactPurchaseCyclePattern string

ContactPurchaseCyclePattern: `regular`: their usual time between purchases is known; `not_enough_history`: fewer than 4 purchase days; `irregular`: no regular pattern. Only a regular buyer is ever overdue.

const (
	ContactPurchaseCyclePatternRegular          ContactPurchaseCyclePattern = "regular"
	ContactPurchaseCyclePatternNotEnoughHistory ContactPurchaseCyclePattern = "not_enough_history"
	ContactPurchaseCyclePatternIrregular        ContactPurchaseCyclePattern = "irregular"
)

func (ContactPurchaseCyclePattern) IsKnown added in v0.2.0

func (v ContactPurchaseCyclePattern) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ContactRFM

type ContactRFM struct {
	Group     ContactRFMGroup `json:"group"`
	Recency   int             `json:"recency"`
	Frequency int             `json:"frequency"`
	Monetary  int             `json:"monetary"`
	// Their purchase events (the workspace's `purchaseEvent`), in any currency.
	PurchaseCount int `json:"purchaseCount"`
	// What their purchases' amounts (`purchaseValueProperty`) add up to, in the workspace's
	// main currency (`currency` on `GET /v1/reports/rfm`); purchases in other currencies and
	// refunds are left out. `null` when the purchase carries no amount.
	TotalSpent *Money `json:"totalSpent"`
	// When their latest purchase happened.
	LastPurchasedAt time.Time `json:"lastPurchasedAt"`
}

ContactRFM is defined by the Kirora API.

type ContactRFMGroup

type ContactRFMGroup string

ContactRFMGroup: Values other than these constants may be added to the API at any time.

const (
	ContactRFMGroupChampions          ContactRFMGroup = "champions"
	ContactRFMGroupLoyal              ContactRFMGroup = "loyal"
	ContactRFMGroupCantLoseThem       ContactRFMGroup = "cant_lose_them"
	ContactRFMGroupPotentialLoyalists ContactRFMGroup = "potential_loyalists"
	ContactRFMGroupNewCustomers       ContactRFMGroup = "new_customers"
	ContactRFMGroupNeedAttention      ContactRFMGroup = "need_attention"
	ContactRFMGroupAboutToSleep       ContactRFMGroup = "about_to_sleep"
	ContactRFMGroupAtRisk             ContactRFMGroup = "at_risk"
	ContactRFMGroupHibernating        ContactRFMGroup = "hibernating"
	ContactRFMGroupLost               ContactRFMGroup = "lost"
)

func (ContactRFMGroup) IsKnown

func (v ContactRFMGroup) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ContactRef

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

ContactRef names a contact by Kirora's id, its externalId or its email address. Make one with ContactID, ContactExternalID or ContactEmail.

func ContactEmail

func ContactEmail(email string) ContactRef

ContactEmail names a contact by its email address.

func ContactExternalID

func ContactExternalID(externalID string) ContactRef

ContactExternalID names a contact by your own id for it.

func ContactID

func ContactID(id string) ContactRef

ContactID names a contact by Kirora's id for it.

type ContactTopic

type ContactTopic struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	// `opt_out` reaches everyone who has not left; `opt_in` only those who joined.
	Mode      ContactTopicMode `json:"mode"`
	CreatedAt time.Time        `json:"createdAt"`
	UpdatedAt time.Time        `json:"updatedAt"`
	// Whether campaigns and journey steps on this topic reach the contact.
	Subscribed bool `json:"subscribed"`
	// The same per channel: a channel's own choice wins over `subscribed` there.
	Channels ContactConsent `json:"channels"`
}

ContactTopic is defined by the Kirora API.

type ContactTopicMode

type ContactTopicMode string

ContactTopicMode: `opt_out` reaches everyone who has not left; `opt_in` only those who joined.

const (
	ContactTopicModeOptOut ContactTopicMode = "opt_out"
	ContactTopicModeOptIn  ContactTopicMode = "opt_in"
)

func (ContactTopicMode) IsKnown

func (v ContactTopicMode) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ContactsPage

type ContactsPage = Page[ContactDetail, ContactListMeta]

ContactsPage is a page of contacts. Its first page also has the total Meta.Count.

type ContactsService

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

ContactsService manages contacts.

func (*ContactsService) All

All iterates over every contact, fetching pages as it goes (listContacts). Break whenever you've had enough; no further pages are fetched.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	for contact, err := range client.Contacts.All(ctx, &kirora.ListContactsParams{Query: kirora.Ptr("ada")}) {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(contact.ID)
	}

	// List fetches one page, for when you want the total count or to hold the cursor
	// yourself.
	page, err := client.Contacts.List(ctx, &kirora.ListContactsParams{Query: kirora.Ptr("ada")})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(*page.Meta.Count, len(page.Data))
	if cursor := page.Meta.Pagination.NextCursor; cursor != nil {
		next, _ := client.Contacts.List(ctx, &kirora.ListContactsParams{Query: kirora.Ptr("ada"), Cursor: cursor})
		fmt.Println(len(next.Data))
	}
}

func (*ContactsService) AllInstallations

func (s *ContactsService) AllInstallations(ctx context.Context, contact ContactRef, params *ListPushInstallationsParams, opts ...CallOption) iter.Seq2[PushInstallation, error]

AllInstallations iterates over every device and browser the contact has registered for push (listPushInstallations).

func (*ContactsService) AllLists

AllLists iterates over every list a contact belongs to (listContactLists).

func (*ContactsService) Delete

func (s *ContactsService) Delete(ctx context.Context, contact ContactRef, opts ...CallOption) error

Delete deletes a contact for good (deleteContact). Safe to retry: a retry that finds it already deleted succeeds.

func (*ContactsService) DeleteBatch

func (s *ContactsService) DeleteBatch(ctx context.Context, params *DeleteContactsInput, opts ...CallOption) (*DeleteContactsResult, error)

DeleteBatch deletes up to 100 contacts, each named by id, externalId or email (deleteContacts). A key is made for the call, so a retry replays the first result rather than reporting the contacts it deleted as not found.

func (*ContactsService) DeleteInstallation

func (s *ContactsService) DeleteInstallation(ctx context.Context, contact ContactRef, externalInstallationID string, opts ...CallOption) error

DeleteInstallation removes a device or browser (deletePushInstallation). Safe to retry: a retry that finds it already removed succeeds.

func (*ContactsService) Export

func (s *ContactsService) Export(ctx context.Context, contact ContactRef, opts ...CallOption) (*ContactDataExport, error)

Export returns everything stored about a contact, for a data request (getContactExport).

func (*ContactsService) Get

func (s *ContactsService) Get(ctx context.Context, contact ContactRef, opts ...CallOption) (*ContactDetail, error)

Get fetches a contact (getContact).

func (*ContactsService) Identify

func (s *ContactsService) Identify(ctx context.Context, params *IdentifyContactInput, opts ...CallOption) (*ContactDetail, error)

Identify creates or updates a contact, matched by externalId, then email, then phone, at least one of which is required (identifyContact). A key is made for the call, so a retry replays the first result, including whether it created the contact.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	contact, err := client.Contacts.Identify(ctx, &kirora.IdentifyContactInput{
		ExternalID: kirora.Value("user-1"),
		Email:      kirora.Value("ada@example.com"),
	})
	if err != nil {
		log.Fatal(err)
	}
	_, err = client.Contacts.Update(ctx, kirora.ContactID(contact.ID), &kirora.UpdateContactInput{
		FirstName: kirora.Value("Ada"),
		// Null clears the last name; a field left out keeps its value.
		LastName: kirora.Null[string](),
	})
	if err != nil {
		log.Fatal(err)
	}
	ada, err := client.Contacts.Get(ctx, kirora.ContactEmail("ada@example.com"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(ada.ID)
}

func (*ContactsService) IdentifyBatch

IdentifyBatch identifies up to 100 contacts, each as Identify does (identifyContactsBatch). Each entry in Results, in the order sent, has either the contact or an Error. A key is made for the call, so a retry replays the first result.

Example
package main

import (
	"context"
	"log"
	"slices"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	var contacts []kirora.IdentifyContactInput
	for _, u := range []struct{ ID, Email string }{{"user-1", "ada@example.com"}, {"user-2", "alan@example.com"}} {
		contacts = append(contacts, kirora.IdentifyContactInput{ExternalID: kirora.Value(u.ID), Email: kirora.Value(u.Email)})
	}

	// IdentifyBatch takes up to 100 contacts a call.
	for batch := range slices.Chunk(contacts, 100) {
		result, err := client.Contacts.IdentifyBatch(ctx, &kirora.IdentifyContactsBatchInput{Contacts: batch})
		if err != nil {
			log.Fatal(err)
		}
		// Results are in the order sent, and one contact refused doesn't fail the rest.
		for i, entry := range result.Results {
			if entry.Error != nil {
				id, _ := batch[i].ExternalID.Get()
				log.Printf("%s not identified: %s", id, entry.Error.Message)
			}
		}
	}
}

func (*ContactsService) List

func (s *ContactsService) List(ctx context.Context, params *ListContactsParams, opts ...CallOption) (*ContactsPage, error)

List fetches a page of contacts (listContacts). See All for every contact.

func (*ContactsService) ListInstallations

func (s *ContactsService) ListInstallations(ctx context.Context, contact ContactRef, params *ListPushInstallationsParams, opts ...CallOption) (*PushInstallationsPage, error)

ListInstallations fetches a page of the contact's devices and browsers registered for push (listPushInstallations).

func (*ContactsService) ListLists

func (s *ContactsService) ListLists(ctx context.Context, contact ContactRef, params *ListContactListsParams, opts ...CallOption) (*ContactListsPage, error)

ListLists fetches a page of the lists a contact belongs to (listContactLists).

func (*ContactsService) ListTopics

func (s *ContactsService) ListTopics(ctx context.Context, contact ContactRef, opts ...CallOption) ([]ContactTopic, error)

ListTopics returns the contact's choice on every topic, all at once (listContactTopics).

func (*ContactsService) Merge

func (s *ContactsService) Merge(ctx context.Context, contact ContactRef, params *MergeContactInput, opts ...CallOption) (*ContactDetail, error)

Merge merges a contact into params.Keep and deletes it (mergeContacts). A key is made for the call, so a retry after it succeeded replays the result rather than failing on the contact that's gone.

func (*ContactsService) RegisterInstallation

func (s *ContactsService) RegisterInstallation(ctx context.Context, contact ContactRef, params *RegisterPushInstallationInput, opts ...CallOption) (*PushInstallation, error)

RegisterInstallation creates or updates a device or browser by its ExternalInstallationID (registerPushInstallation). A key is made for the call, so a retry replays the first result.

func (*ContactsService) SetTopic

func (s *ContactsService) SetTopic(ctx context.Context, contact ContactRef, topicID string, params *SetContactTopicInput, opts ...CallOption) (*ContactTopic, error)

SetTopic joins or leaves a topic, on every channel or per channel; joining needs a consent Statement (setContactTopic). Safe to retry.

func (*ContactsService) Update

func (s *ContactsService) Update(ctx context.Context, contact ContactRef, params *UpdateContactInput, opts ...CallOption) (*ContactDetail, error)

Update changes a contact's fields (updateContact). Safe to retry, since applying the same change twice is a no-op, unless it changes the email or externalId the contact is named by: a retry after it succeeded would look for the old one, so it isn't retried.

type CountOperator

type CountOperator string

CountOperator: At least, exactly or at most.

const (
	CountOperatorGte    CountOperator = "gte"
	CountOperatorEquals CountOperator = "equals"
	CountOperatorLte    CountOperator = "lte"
)

func (CountOperator) IsKnown

func (v CountOperator) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type CreateCampaignInput

type CreateCampaignInput struct {
	Name string `json:"name"`
	// The channels to send on; each needs its own content. Defaults to `email`.
	Channels []ChannelInput `json:"channels,omitzero"`
	// Send to all contacts: everyone its channels reach, with consent and suppressions
	// applied as on any send. Choose at most one audience.
	AllContacts *bool `json:"allContacts,omitempty"`
	// Send to these lists, up to 20: a member of any of them receives it once. Choose at
	// most one audience.
	ListIDs []string `json:"listIds,omitzero"`
	// Send to this segment. Choose at most one audience.
	SegmentID *string `json:"segmentId,omitempty"`
	// Send to contacts matching these rules. Choose at most one audience.
	AudienceRules *SegmentRulesInput `json:"audienceRules,omitempty"`
	// Leave out the members of these lists and segments ("don't send to"); beside all
	// contacts, lists or a segment, not rules, as rules exclude within themselves.
	Exclusions Nullable[CampaignExclusionsInput] `json:"exclusions,omitzero"`
	// Send only to contacts the topic reaches. Omit to reach everyone with consent.
	TopicID       Nullable[string]      `json:"topicId,omitzero"`
	MessageLimits *MessageLimitUseInput `json:"messageLimits,omitempty"`
	// UTM parameters added to the links in the email.
	UTM Nullable[CampaignUTMInput] `json:"utm,omitzero"`
	// The content for each selected channel. A draft may leave parts out.
	Content *CreateCampaignInputContent `json:"content,omitempty"`
	// Test 2 to 4 versions of the email or push on part of the audience, then send the
	// winner to the rest. Email-only or push-only campaigns; not with a trigger. With a
	// local-time schedule the winner is picked `decideAfter` after the test has reached
	// every timezone (with `next_day`, after the next-day sends too).
	AbTest *AbTestSettingsInput `json:"abTest,omitempty"`
	// How fast it goes out, and until when. Omit to send as fast as the plan allows.
	Delivery Nullable[CampaignDeliveryInput] `json:"delivery,omitzero"`
	// Tag names, up to 20, matched without case; a tag the workspace lacks is created. On
	// update, replaces the tags whole: `[]` removes them all.
	Tags []string `json:"tags,omitzero"`
}

CreateCampaignInput is defined by the Kirora API.

type CreateCampaignInputContent

type CreateCampaignInputContent struct {
	// Subject, preview text, sender and design. Needed to send once `channels` has `email`.
	Email *CreateCampaignInputContentEmail `json:"email,omitempty"`
	// The notification content. Needed to send once `channels` has `push`.
	Push *CreateCampaignInputContentPush `json:"push,omitempty"`
}

CreateCampaignInputContent: The content for each selected channel. A draft may leave parts out.

type CreateCampaignInputContentEmail

type CreateCampaignInputContentEmail struct {
	// The subject line. Merge tags are allowed.
	Subject *string `json:"subject,omitempty"`
	// Shown by inboxes after the subject. Merge tags are allowed; keep it near 100
	// characters.
	PreviewText *string `json:"previewText,omitempty"`
	// The sender address, on a verified sending domain.
	From *string `json:"from,omitempty"`
	// Where replies go; the part before the @ must be ASCII.
	ReplyTo *string `json:"replyTo,omitempty"`
	// The email design. Needed to send.
	TemplateSnapshot *TemplateSnapshotInput `json:"templateSnapshot,omitempty"`
}

CreateCampaignInputContentEmail: Subject, preview text, sender and design. Needed to send once `channels` has `email`.

type CreateCampaignInputContentPush

type CreateCampaignInputContentPush = CampaignContentPush

CreateCampaignInputContentPush: The notification content. Needed to send once `channels` has `push`.

type CreateCampaignInputContentPushOverrides

type CreateCampaignInputContentPushOverrides = CampaignContentPushOverrides

CreateCampaignInputContentPushOverrides: Fields that differ on one platform, each replacing the shared one there (a whole `data` map, not merged key by key). On iOS and Android `actionUrl` may be an app link such as `myapp://orders`; the shared one and the web one must be HTTPS.

type CreateCampaignInputContentPushOverridesAndroid

type CreateCampaignInputContentPushOverridesAndroid = CampaignContentPushOverridesAndroid

CreateCampaignInputContentPushOverridesAndroid: Replaces shared fields on Android.

type CreateCampaignInputContentPushOverridesIOS

type CreateCampaignInputContentPushOverridesIOS = CampaignContentPushOverridesIOS

CreateCampaignInputContentPushOverridesIOS: Replaces shared fields on iOS.

type CreateCampaignInputContentPushOverridesWeb

type CreateCampaignInputContentPushOverridesWeb = CampaignContentPushOverridesWeb

CreateCampaignInputContentPushOverridesWeb: Replaces shared fields on web.

type CreateEmbedSessionInput

type CreateEmbedSessionInput struct {
	// The builders the browser may load; each opens only the routes it needs.
	Components []EmbedComponent `json:"components"`
	// Lets the session read attribute values and event property samples, for value
	// suggestions. Off by default: they are the workspace's customer data.
	IncludeAttributeValues *bool `json:"includeAttributeValues,omitempty"`
	// Up to 5 addresses the email builder may send a test to, such as your signed-in user's.
	// Defaults to none, which hides test sending. The builder can send to no other address.
	TestSendTo []string `json:"testSendTo,omitzero"`
}

CreateEmbedSessionInput is defined by the Kirora API.

type CreateListInput

type CreateListInput struct {
	// Unique within the workspace, ignoring case.
	Name        string           `json:"name"`
	Description Nullable[string] `json:"description,omitzero"`
}

CreateListInput is defined by the Kirora API.

type CreateWorkspaceInput

type CreateWorkspaceInput struct {
	Name string `json:"name"`
	// Your own id for the tenant (up to 128 letters, digits, `.`, `:`, `_`, `-`); unique
	// among your workspaces.
	ExternalID string `json:"externalId"`
	// Two-letter ISO 3166-1 country code.
	Country string `json:"country"`
	// IANA timezone, such as `Europe/Berlin`.
	Timezone *string `json:"timezone,omitempty"`
	// The business's website.
	Website Nullable[string] `json:"website,omitzero"`
	// What the workspace sends.
	MailKind Nullable[WorkspaceMailKind] `json:"mailKind,omitzero"`
	// How its contacts agreed to hear from it: a signup form, checkout, an app.
	ContactOptIn Nullable[string] `json:"contactOptIn,omitzero"`
}

CreateWorkspaceInput is defined by the Kirora API.

type CursorPaginationMeta

type CursorPaginationMeta struct {
	Pagination Pagination `json:"pagination"`
}

CursorPaginationMeta is defined by the Kirora API.

type DeleteContactsInput

type DeleteContactsInput struct {
	Contacts []ContactIdentifierInput `json:"contacts"`
}

DeleteContactsInput is defined by the Kirora API.

type DeleteContactsOutcome

type DeleteContactsOutcome string

DeleteContactsOutcome: `send_in_progress`: a message is being handed to the provider; retry shortly.

const (
	DeleteContactsOutcomeDeleted        DeleteContactsOutcome = "deleted"
	DeleteContactsOutcomeNotFound       DeleteContactsOutcome = "not_found"
	DeleteContactsOutcomeSendInProgress DeleteContactsOutcome = "send_in_progress"
)

func (DeleteContactsOutcome) IsKnown

func (v DeleteContactsOutcome) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type DeleteContactsResult

type DeleteContactsResult struct {
	Results []DeleteContactsResultEntry `json:"results"`
}

DeleteContactsResult is defined by the Kirora API.

type DeleteContactsResultEntry

type DeleteContactsResultEntry struct {
	// The contact as named in the request.
	Contact ContactIdentifier `json:"contact"`
	// `send_in_progress`: a message is being handed to the provider; retry shortly.
	Outcome DeleteContactsOutcome `json:"outcome"`
}

DeleteContactsResultEntry is defined by the Kirora API.

type DeleteSuppressionsInput

type DeleteSuppressionsInput = AddSuppressionsInput

DeleteSuppressionsInput is defined by the Kirora API.

type DeletedListContacts

type DeletedListContacts struct {
	// Contacts taken out of the list.
	DeletedCount int `json:"deletedCount"`
	// Identifiers as sent (emails normalised) that name no contact in the workspace.
	NotFound []string `json:"notFound"`
}

DeletedListContacts is defined by the Kirora API.

type DeletedSuppressions

type DeletedSuppressions struct {
	// Addresses unblocked.
	DeletedCount int `json:"deletedCount"`
	// Addresses blocked by a bounce, complaint or unsubscribe, which stay blocked.
	NotRemovable []string `json:"notRemovable"`
	// Addresses this workspace does not block itself.
	NotFound []string `json:"notFound"`
}

DeletedSuppressions is defined by the Kirora API.

type DesignSnapshotInput

type DesignSnapshotInput struct {
	// The block format version; use the current one, 1.
	SchemaVersion int `json:"schemaVersion"`
	// The blocks, rendered top to bottom: at most 200 across the whole tree and five levels
	// including the root. The footer stays at the root.
	Blocks []EmailBlockInput `json:"blocks"`
	// Theme values this email overrides.
	Theme EmailThemeInput `json:"theme"`
	// The language the email is written in, as a BCP 47 tag ("en", "fr-BE", "ar"). It sets
	// the HTML `lang` and the reading direction: Arabic, Hebrew, Persian, Urdu and other
	// right-to-left languages render right to left. Defaults to "en".
	Language *string `json:"language,omitempty"`
	// Plain text sent instead of the version generated from the blocks.
	PlainTextOverride Nullable[string] `json:"plainTextOverride,omitzero"`
}

DesignSnapshotInput is defined by the Kirora API.

func (DesignSnapshotInput) MarshalJSON

func (v DesignSnapshotInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "kind": "design", which identifies a DesignSnapshotInput.

type DividerBlock

type DividerBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Line weight in px.
	Thickness *int `json:"thickness,omitempty"`
	// A hex colour, or a theme reference: `accent`, `canvas`, or `accent-tint` /
	// `canvas-tint` (a light tint of it), which follows the theme.
	Color     *EmailBlockStyleBackgroundColor `json:"color,omitempty"`
	LineStyle *EmailBlockStyleBorderStyle     `json:"lineStyle,omitempty"`
	// How much of the row the line spans.
	Width *DividerBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

DividerBlock is defined by the Kirora API.

func (DividerBlock) MarshalJSON

func (v DividerBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "divider", which identifies a DividerBlock, and the properties in Extra.

func (*DividerBlock) UnmarshalJSON

func (v *DividerBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type DividerBlockInput

type DividerBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// Line weight in px.
	Thickness *int `json:"thickness,omitempty"`
	// A hex colour, or a theme reference: `accent`, `canvas`, or `accent-tint` /
	// `canvas-tint` (a light tint of it), which follows the theme.
	Color     *EmailBlockStyleBackgroundColor `json:"color,omitempty"`
	LineStyle *EmailBlockStyleBorderStyle     `json:"lineStyle,omitempty"`
	// How much of the row the line spans.
	Width *DividerBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

DividerBlockInput is defined by the Kirora API.

func (DividerBlockInput) MarshalJSON

func (v DividerBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "divider", which identifies a DividerBlockInput, and the properties in Extra.

func (*DividerBlockInput) UnmarshalJSON

func (v *DividerBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type DividerBlockWidth

type DividerBlockWidth string

DividerBlockWidth: How much of the row the line spans.

const (
	DividerBlockWidth100 DividerBlockWidth = "100%"
	DividerBlockWidth75  DividerBlockWidth = "75%"
	DividerBlockWidth50  DividerBlockWidth = "50%"
	DividerBlockWidth25  DividerBlockWidth = "25%"
)

func (DividerBlockWidth) IsKnown

func (v DividerBlockWidth) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type Duration

type Duration struct {
	Value int          `json:"value"`
	Unit  DurationUnit `json:"unit"`
}

Duration is defined by the Kirora API.

type DurationInput

type DurationInput = Duration

DurationInput is defined by the Kirora API.

type DurationOrZero

type DurationOrZero = Duration

DurationOrZero is defined by the Kirora API.

type DurationOrZeroInput

type DurationOrZeroInput = Duration

DurationOrZeroInput is defined by the Kirora API.

type DurationUnit

type DurationUnit string

DurationUnit: Values other than these constants may be added to the API at any time.

const (
	DurationUnitSeconds DurationUnit = "seconds"
	DurationUnitMinutes DurationUnit = "minutes"
	DurationUnitHours   DurationUnit = "hours"
	DurationUnitDays    DurationUnit = "days"
)

func (DurationUnit) IsKnown

func (v DurationUnit) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailAttachmentInput

type EmailAttachmentInput struct {
	// Its extension sets the type it is sent as.
	Filename string `json:"filename"`
	// The file, base64-encoded.
	Content string `json:"content"`
	// Shows an image inside the body instead of attaching it: the HTML refers to it as `<img
	// src="cid:<contentId>">`.
	ContentID *string `json:"contentId,omitempty"`
}

EmailAttachmentInput is defined by the Kirora API.

type EmailBlock

type EmailBlock struct {
	Value EmailBlockValue
}

EmailBlock is one of the following, told apart by "type": HeaderBlock ("header"), HeadingBlock ("heading"), TextBlock ("text"), ImageBlock ("image"), ButtonBlock ("button"), DividerBlock ("divider"), SpacerBlock ("spacer"), ColumnsBlock ("columns"), Columns3Block ("columns3"), ImageTextBlock ("imagetext"), ImageGroupBlock ("imagegroup"), BoxedBlock ("boxed"), QuoteBlock ("quote"), ListBlock ("list"), ProductBlock ("product"), VideoBlock ("video"), SocialBlock ("social"), MenuBlock ("menu"), HTMLBlock ("html"), SectionBlock ("section"), FooterBlock ("footer"), RepeatBlock ("repeat"), SharedBlockReference ("shared").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (EmailBlock) MarshalJSON

func (u EmailBlock) MarshalJSON() ([]byte, error)

func (*EmailBlock) UnmarshalJSON

func (u *EmailBlock) UnmarshalJSON(data []byte) error

type EmailBlockInput

type EmailBlockInput struct {
	Value EmailBlockInputValue
}

EmailBlockInput is one of the following, told apart by "type": HeaderBlockInput ("header"), HeadingBlockInput ("heading"), TextBlockInput ("text"), ImageBlockInput ("image"), ButtonBlockInput ("button"), DividerBlockInput ("divider"), SpacerBlockInput ("spacer"), ColumnsBlockInput ("columns"), Columns3BlockInput ("columns3"), ImageTextBlockInput ("imagetext"), ImageGroupBlockInput ("imagegroup"), BoxedBlockInput ("boxed"), QuoteBlockInput ("quote"), ListBlockInput ("list"), ProductBlockInput ("product"), VideoBlockInput ("video"), SocialBlockInput ("social"), MenuBlockInput ("menu"), HTMLBlockInput ("html"), SectionBlockInput ("section"), FooterBlockInput ("footer"), RepeatBlockInput ("repeat"), SharedBlockReferenceInput ("shared").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (EmailBlockInput) MarshalJSON

func (u EmailBlockInput) MarshalJSON() ([]byte, error)

func (*EmailBlockInput) UnmarshalJSON

func (u *EmailBlockInput) UnmarshalJSON(data []byte) error

type EmailBlockInputValue

type EmailBlockInputValue interface {
	// contains filtered or unexported methods
}

EmailBlockInputValue is implemented by each kind of EmailBlockInput, and by Unknown.

type EmailBlockStyle

type EmailBlockStyle struct {
	// Fill behind the block.
	BackgroundColor *EmailBlockStyleBackgroundColor `json:"backgroundColor,omitempty"`
	// A font id: one every client has (arial, verdana, georgia, tahoma, times-new-roman,
	// courier-new), or a web font, which shows where the client loads it and falls back to a
	// safe font elsewhere. Form themes use the same ids.
	FontFamily *EmailFont `json:"fontFamily,omitempty"`
	// Text size in px, 12 to 72.
	FontSize *int `json:"fontSize,omitempty"`
	// Text size in px on phones (screens up to 620px), 12 to 72. Email apps that ignore
	// mobile styles use `fontSize`.
	MobileFontSize *int `json:"mobileFontSize,omitempty"`
	// Space inside the block in px, 0 to 100 per side; omitted sides keep their default.
	Padding *EmailBlockStylePadding `json:"padding,omitempty"`
	// Space inside the block in px on phones (screens up to 620px), 0 to 100 per side;
	// omitted sides keep the block's `padding` (or its default). Email apps that ignore
	// mobile styles use `padding`.
	MobilePadding *EmailBlockStylePadding `json:"mobilePadding,omitempty"`
	// Border thickness in px; 0 for none.
	BorderWidth *int `json:"borderWidth,omitempty"`
	// Border line style.
	BorderStyle *EmailBlockStyleBorderStyle `json:"borderStyle,omitempty"`
	// Border colour.
	BorderColor *EmailBlockStyleBackgroundColor `json:"borderColor,omitempty"`
	// Corner rounding in px, 0 to 100.
	BorderRadius *int `json:"borderRadius,omitempty"`
	// Text colour.
	TextColor *EmailBlockStyleBackgroundColor `json:"textColor,omitempty"`
	// Colour of links in the text.
	LinkColor *EmailBlockStyleBackgroundColor `json:"linkColor,omitempty"`
	// Set to false for links without an underline, such as a row of rating numbers or stars.
	LinkUnderline *bool `json:"linkUnderline,omitempty"`
	// Space between letters in px, such as 3 for a spaced-out eyebrow line.
	LetterSpacing *float64 `json:"letterSpacing,omitempty"`
	// Set to `uppercase` to capitalise all text.
	TextTransform *EmailBlockStyleTextTransform `json:"textTransform,omitempty"`
	// A multiple of the font size.
	LineHeight *float64 `json:"lineHeight,omitempty"`
	// Text weight.
	FontWeight *EmailBlockStyleFontWeight `json:"fontWeight,omitempty"`
	// Text style.
	FontStyle *EmailBlockStyleFontStyle `json:"fontStyle,omitempty"`
	// Draw the background and border as a box within the content width, not across the whole
	// row.
	Inset *bool `json:"inset,omitempty"`
}

EmailBlockStyle is defined by the Kirora API.

type EmailBlockStyleBackgroundColor

type EmailBlockStyleBackgroundColor string

EmailBlockStyleBackgroundColor: Fill behind the block.

const (
	EmailBlockStyleBackgroundColorAccent     EmailBlockStyleBackgroundColor = "accent"
	EmailBlockStyleBackgroundColorCanvas     EmailBlockStyleBackgroundColor = "canvas"
	EmailBlockStyleBackgroundColorAccentTint EmailBlockStyleBackgroundColor = "accent-tint"
	EmailBlockStyleBackgroundColorCanvasTint EmailBlockStyleBackgroundColor = "canvas-tint"
)

func (EmailBlockStyleBackgroundColor) IsKnown

IsKnown is false for a value added to the API after this version of the SDK.

type EmailBlockStyleBorderStyle

type EmailBlockStyleBorderStyle string

EmailBlockStyleBorderStyle: Border line style.

const (
	EmailBlockStyleBorderStyleSolid  EmailBlockStyleBorderStyle = "solid"
	EmailBlockStyleBorderStyleDashed EmailBlockStyleBorderStyle = "dashed"
	EmailBlockStyleBorderStyleDotted EmailBlockStyleBorderStyle = "dotted"
)

func (EmailBlockStyleBorderStyle) IsKnown

func (v EmailBlockStyleBorderStyle) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailBlockStyleFontStyle

type EmailBlockStyleFontStyle string

EmailBlockStyleFontStyle: Text style.

const (
	EmailBlockStyleFontStyleNormal EmailBlockStyleFontStyle = "normal"
	EmailBlockStyleFontStyleItalic EmailBlockStyleFontStyle = "italic"
)

func (EmailBlockStyleFontStyle) IsKnown

func (v EmailBlockStyleFontStyle) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailBlockStyleFontWeight

type EmailBlockStyleFontWeight string

EmailBlockStyleFontWeight: Text weight.

const (
	EmailBlockStyleFontWeightRegular EmailBlockStyleFontWeight = "regular"
	EmailBlockStyleFontWeightBold    EmailBlockStyleFontWeight = "bold"
)

func (EmailBlockStyleFontWeight) IsKnown

func (v EmailBlockStyleFontWeight) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailBlockStyleInput

type EmailBlockStyleInput = EmailBlockStyle

EmailBlockStyleInput is defined by the Kirora API.

type EmailBlockStylePadding

type EmailBlockStylePadding struct {
	Top    *int `json:"top,omitempty"`
	Right  *int `json:"right,omitempty"`
	Bottom *int `json:"bottom,omitempty"`
	Left   *int `json:"left,omitempty"`
}

EmailBlockStylePadding: Space inside the block in px, 0 to 100 per side; omitted sides keep their default.

type EmailBlockStyleTextTransform

type EmailBlockStyleTextTransform string

EmailBlockStyleTextTransform: Set to `uppercase` to capitalise all text.

const (
	EmailBlockStyleTextTransformNone      EmailBlockStyleTextTransform = "none"
	EmailBlockStyleTextTransformUppercase EmailBlockStyleTextTransform = "uppercase"
)

func (EmailBlockStyleTextTransform) IsKnown

func (v EmailBlockStyleTextTransform) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailBlockValue

type EmailBlockValue interface {
	// contains filtered or unexported methods
}

EmailBlockValue is implemented by each kind of EmailBlock, and by Unknown.

type EmailBlocker

type EmailBlocker struct {
	// What blocks it, for code to branch on.
	Code EmailBlockerCode `json:"code"`
	// What to do about it, for the person or agent fixing it.
	Message string `json:"message"`
	// With `draft_incomplete`: the field still missing, such as `subject`.
	Field *string `json:"field,omitempty"`
}

EmailBlocker is defined by the Kirora API.

type EmailBlockerCode

type EmailBlockerCode string

EmailBlockerCode: What blocks it, for code to branch on.

const (
	EmailBlockerCodeDraftIncomplete       EmailBlockerCode = "draft_incomplete"
	EmailBlockerCodeSenderUnverified      EmailBlockerCode = "sender_unverified"
	EmailBlockerCodeDMARCMissing          EmailBlockerCode = "dmarc_missing"
	EmailBlockerCodePostalAddressMissing  EmailBlockerCode = "postal_address_missing"
	EmailBlockerCodeNoEligibleRecipients  EmailBlockerCode = "no_eligible_recipients"
	EmailBlockerCodePlanLimitReached      EmailBlockerCode = "plan_limit_reached"
	EmailBlockerCodeNewAccountDailyLimit  EmailBlockerCode = "new_account_daily_limit"
	EmailBlockerCodeSendingReviewRequired EmailBlockerCode = "sending_review_required"
)

func (EmailBlockerCode) IsKnown

func (v EmailBlockerCode) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailEligibility

type EmailEligibility struct {
	// Contacts reachable on this channel after the exclusions: the number a send is sized
	// by.
	EligibleRecipientCount int `json:"eligibleRecipientCount"`
	// What stops the email channel sending.
	Blockers []EmailBlocker `json:"blockers"`
	// Contacts left out of the audience, by reason.
	Excluded EmailEligibilityExcluded `json:"excluded"`
	// Sending skips a contact (`missing_merge_tag`) when a contact tag in the email has no
	// value for them and no default (`{{ contact.firstName | default: "there" }}`). These
	// contacts are still in `eligibleRecipientCount`. Tags inside a repeat or conditional
	// block are not counted, since the block may not show.
	MergeTagSkipped EmailEligibilityMergeTagSkipped `json:"mergeTagSkipped"`
	// Whether the sender domain is verified.
	SenderVerified bool `json:"senderVerified"`
}

EmailEligibility is defined by the Kirora API.

func (EmailEligibility) MarshalJSON

func (v EmailEligibility) MarshalJSON() ([]byte, error)

MarshalJSON adds "channel": "email", which identifies a EmailEligibility.

type EmailEligibilityExcluded

type EmailEligibilityExcluded struct {
	// Contacts without email consent.
	ConsentMissing int `json:"consentMissing"`
	// Consented, but the campaign's topic does not reach them.
	TopicUnsubscribed int `json:"topicUnsubscribed"`
	// Contacts whose address is blocked, for example after a bounce.
	Suppressed int `json:"suppressed"`
	// Contacts with no email address.
	MissingEmail int `json:"missingEmail"`
}

EmailEligibilityExcluded: Contacts left out of the audience, by reason.

type EmailEligibilityMergeTagSkipped

type EmailEligibilityMergeTagSkipped struct {
	// Eligible recipients a merge tag would skip, counted once however many tags they lack.
	Count int `json:"count"`
	// Each tag that would skip someone, with how many.
	ByTag []EmailEligibilityMergeTagSkippedByTagItem `json:"byTag"`
}

EmailEligibilityMergeTagSkipped: Sending skips a contact (`missing_merge_tag`) when a contact tag in the email has no value for them and no default (`{{ contact.firstName | default: "there" }}`). These contacts are still in `eligibleRecipientCount`. Tags inside a repeat or conditional block are not counted, since the block may not show.

type EmailEligibilityMergeTagSkippedByTagItem

type EmailEligibilityMergeTagSkippedByTagItem struct {
	// The tag, as the skip reason names it: `contact.firstName`.
	Tag string `json:"tag"`
	// Eligible recipients without a value for it.
	Count int `json:"count"`
}

EmailEligibilityMergeTagSkippedByTagItem is defined by the Kirora API.

type EmailFont

type EmailFont string

EmailFont: Values other than these constants may be added to the API at any time.

const (
	EmailFontArial              EmailFont = "arial"
	EmailFontVerdana            EmailFont = "verdana"
	EmailFontGeorgia            EmailFont = "georgia"
	EmailFontTahoma             EmailFont = "tahoma"
	EmailFontTimesNewRoman      EmailFont = "times-new-roman"
	EmailFontCourierNew         EmailFont = "courier-new"
	EmailFontInter              EmailFont = "inter"
	EmailFontRoboto             EmailFont = "roboto"
	EmailFontOpenSans           EmailFont = "open-sans"
	EmailFontLato               EmailFont = "lato"
	EmailFontMontserrat         EmailFont = "montserrat"
	EmailFontPoppins            EmailFont = "poppins"
	EmailFontDmSans             EmailFont = "dm-sans"
	EmailFontNunito             EmailFont = "nunito"
	EmailFontWorkSans           EmailFont = "work-sans"
	EmailFontOswald             EmailFont = "oswald"
	EmailFontUbuntu             EmailFont = "ubuntu"
	EmailFontMulish             EmailFont = "mulish"
	EmailFontManrope            EmailFont = "manrope"
	EmailFontQuicksand          EmailFont = "quicksand"
	EmailFontRubik              EmailFont = "rubik"
	EmailFontJosefinSans        EmailFont = "josefin-sans"
	EmailFontEpilogue           EmailFont = "epilogue"
	EmailFontNotoSans           EmailFont = "noto-sans"
	EmailFontSpaceGrotesk       EmailFont = "space-grotesk"
	EmailFontPlusJakartaSans    EmailFont = "plus-jakarta-sans"
	EmailFontOutfit             EmailFont = "outfit"
	EmailFontBricolageGrotesque EmailFont = "bricolage-grotesque"
	EmailFontSora               EmailFont = "sora"
	EmailFontIbmPlexSans        EmailFont = "ibm-plex-sans"
	EmailFontGeist              EmailFont = "geist"
	EmailFontSpaceMono          EmailFont = "space-mono"
	EmailFontPlayfairDisplay    EmailFont = "playfair-display"
	EmailFontMerriweather       EmailFont = "merriweather"
	EmailFontLora               EmailFont = "lora"
	EmailFontLibreBaskerville   EmailFont = "libre-baskerville"
	EmailFontEbGaramond         EmailFont = "eb-garamond"
	EmailFontFraunces           EmailFont = "fraunces"
	EmailFontSourceSerif4       EmailFont = "source-serif-4"
	EmailFontCormorantGaramond  EmailFont = "cormorant-garamond"
)

func (EmailFont) IsKnown

func (v EmailFont) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailFontInput

type EmailFontInput = EmailFont

EmailFontInput is defined by the Kirora API.

type EmailTheme

type EmailTheme struct {
	// Body font stack, such as `Inter, sans-serif`.
	BodyFontFamily *string `json:"bodyFontFamily,omitempty"`
	// Heading font stack.
	HeadingFontFamily *string `json:"headingFontFamily,omitempty"`
	// Background of the email card, as hex.
	CardBackgroundColor *string `json:"cardBackgroundColor,omitempty"`
	// Background behind the card, as hex.
	CanvasBackgroundColor *string `json:"canvasBackgroundColor,omitempty"`
	// Default text colour, as hex.
	TextColor *string `json:"textColor,omitempty"`
	// Brand colour for buttons and highlights, as hex.
	AccentColor *string `json:"accentColor,omitempty"`
	// Link colour, as hex.
	LinkColor *string `json:"linkColor,omitempty"`
	// Heading colour, as hex; unset, headings take `textColor`.
	HeadingColor *string `json:"headingColor,omitempty"`
	// Label colour of solid buttons in `accentColor`, as hex; unset, white or near-black,
	// whichever reads on it.
	ButtonTextColor *string `json:"buttonTextColor,omitempty"`
	// Body text size; headings and buttons scale with it. Unset is `16px`.
	BaseFontSize *EmailThemeBaseFontSize `json:"baseFontSize,omitempty"`
	// Width of the email card on wide screens.
	CardWidth *EmailThemeCardWidth `json:"cardWidth,omitempty"`
	// Corner rounding of the email's card.
	CardBorderRadius *EmailThemeCardBorderRadius `json:"cardBorderRadius,omitempty"`
	// Button corners; `cardBorderRadius` rounds the email's card and, when this is unset,
	// buttons.
	ButtonBorderRadius *EmailThemeCardBorderRadius `json:"buttonBorderRadius,omitempty"`
	// Button style.
	ButtonStyle *ButtonBlockButtonStyle `json:"buttonStyle,omitempty"`
}

EmailTheme is defined by the Kirora API.

type EmailThemeBaseFontSize

type EmailThemeBaseFontSize string

EmailThemeBaseFontSize: Body text size; headings and buttons scale with it. Unset is `16px`.

const (
	EmailThemeBaseFontSize14px EmailThemeBaseFontSize = "14px"
	EmailThemeBaseFontSize15px EmailThemeBaseFontSize = "15px"
	EmailThemeBaseFontSize16px EmailThemeBaseFontSize = "16px"
	EmailThemeBaseFontSize17px EmailThemeBaseFontSize = "17px"
	EmailThemeBaseFontSize18px EmailThemeBaseFontSize = "18px"
)

func (EmailThemeBaseFontSize) IsKnown

func (v EmailThemeBaseFontSize) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailThemeCardBorderRadius

type EmailThemeCardBorderRadius string

EmailThemeCardBorderRadius: Corner rounding of the email's card.

const (
	EmailThemeCardBorderRadius0px   EmailThemeCardBorderRadius = "0px"
	EmailThemeCardBorderRadius6px   EmailThemeCardBorderRadius = "6px"
	EmailThemeCardBorderRadius12px  EmailThemeCardBorderRadius = "12px"
	EmailThemeCardBorderRadius16px  EmailThemeCardBorderRadius = "16px"
	EmailThemeCardBorderRadius24px  EmailThemeCardBorderRadius = "24px"
	EmailThemeCardBorderRadius999px EmailThemeCardBorderRadius = "999px"
)

func (EmailThemeCardBorderRadius) IsKnown

func (v EmailThemeCardBorderRadius) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailThemeCardWidth

type EmailThemeCardWidth string

EmailThemeCardWidth: Width of the email card on wide screens.

const (
	EmailThemeCardWidth560px EmailThemeCardWidth = "560px"
	EmailThemeCardWidth600px EmailThemeCardWidth = "600px"
	EmailThemeCardWidth680px EmailThemeCardWidth = "680px"
)

func (EmailThemeCardWidth) IsKnown

func (v EmailThemeCardWidth) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmailThemeInput

type EmailThemeInput = EmailTheme

EmailThemeInput is defined by the Kirora API.

type EmailThreadingInput

type EmailThreadingInput struct {
	// The `Message-ID` of the email being replied to, angle brackets included.
	InReplyTo string `json:"inReplyTo"`
	// The `Message-ID`s earlier in the conversation, oldest first (up to 20).
	References []string `json:"references,omitzero"`
}

EmailThreadingInput is defined by the Kirora API.

type EmbedComponent

type EmbedComponent string

EmbedComponent: Values other than these constants may be added to the API at any time.

const (
	EmbedComponentSegmentBuilder EmbedComponent = "segment_builder"
	EmbedComponentEmailBuilder   EmbedComponent = "email_builder"
)

func (EmbedComponent) IsKnown

func (v EmbedComponent) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EmbedSession

type EmbedSession struct {
	// For Kirora's hosted builder, which sends it as `Authorization: Bearer <token>`; it
	// works only inside a page whose origin the partner key allows.
	Token string `json:"token"`
	// When the token stops working (15 minutes).
	ExpiresAt time.Time `json:"expiresAt"`
	// The API's base URL, for `KiroraProvider`'s `apiUrl`.
	APIURL string `json:"apiUrl"`
	// The hosted builders' base address; `@kirora/react` opens each builder under it.
	BuilderURL string `json:"builderUrl"`
	// The addresses the builder may send a test to, as the request named them; empty hides
	// test sending.
	TestSendTo []string `json:"testSendTo"`
}

EmbedSession is defined by the Kirora API.

type EmbedSessionsService

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

EmbedSessionsService creates sessions for embedding Kirora's builders in your own app, for partner keys only.

func (*EmbedSessionsService) Create

Create creates a session for one tenant, so call it on Client.ForWorkspace (createEmbedSession). Its token lasts 15 minutes; give it to the embedded builders from your server. A key you pass must be new per session, since reusing one returns the first session.

type Error

type Error struct {
	// Code is always set: when the response has none, it is derived from StatusCode. A
	// code added to the API after this version of the SDK comes through as is.
	Code ErrorCode
	// Message describes the error. It is "HTTP <status>" when the response has none.
	Message    string
	StatusCode int

	// Errors lists each field the request got wrong, with a message to show beside it.
	// It is set on ErrorCodeValidationError and ErrorCodeDraftIncomplete.
	Errors []FieldError

	// Details is any further detail the API gave, as raw JSON.
	Details json.RawMessage

	// RequestID identifies the request to Kirora support.
	RequestID string

	// RetryAfter is how long the API asked the caller to wait before retrying, or 0.
	RetryAfter time.Duration

	// RateLimit is nil when the response has no valid rate limit headers.
	RateLimit *RateLimit
	// contains filtered or unexported fields
}

Error is an error response from the API. Branch on Code, or use IsErrorCode.

Example
package main

import (
	"context"
	"errors"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	_, err := client.Contacts.Get(ctx, kirora.ContactExternalID("user-1"))
	var apiErr *kirora.Error
	switch {
	case kirora.IsErrorCode(err, kirora.ErrorCodeNotFound):
		fmt.Println("never identified")
	case errors.As(err, &apiErr) && apiErr.Code == kirora.ErrorCodeValidationError:
		for _, fe := range apiErr.Errors {
			fmt.Println(fe.Field, fe.Message)
		}
	case err != nil:
		log.Fatal(err)
	}
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Retryable

func (e *Error) Retryable() bool

Retryable reports whether the request may succeed if sent again: after a rate limit, a server error, or ErrorCodeIdempotencyKeyInUse, while an earlier request with the same key is still running. It doesn't say whether repeating the request is safe from duplicates.

type ErrorCode

type ErrorCode string

ErrorCode: ErrorCode is the code of an error from the Kirora API. Branch on it rather than on the message.

const (
	ErrorCodeBadRequest                    ErrorCode = "BAD_REQUEST"
	ErrorCodeAlreadyExists                 ErrorCode = "ALREADY_EXISTS"
	ErrorCodeConflict                      ErrorCode = "CONFLICT"
	ErrorCodeInUse                         ErrorCode = "IN_USE"
	ErrorCodeForbidden                     ErrorCode = "FORBIDDEN"
	ErrorCodeScopeMissing                  ErrorCode = "SCOPE_MISSING"
	ErrorCodeAgentKeyRefused               ErrorCode = "AGENT_KEY_REFUSED"
	ErrorCodeInternalError                 ErrorCode = "INTERNAL_ERROR"
	ErrorCodeNotFound                      ErrorCode = "NOT_FOUND"
	ErrorCodeMethodNotAllowed              ErrorCode = "METHOD_NOT_ALLOWED"
	ErrorCodePayloadTooLarge               ErrorCode = "PAYLOAD_TOO_LARGE"
	ErrorCodeUnsupportedMediaType          ErrorCode = "UNSUPPORTED_MEDIA_TYPE"
	ErrorCodeRateLimited                   ErrorCode = "RATE_LIMITED"
	ErrorCodeRevisionConflict              ErrorCode = "REVISION_CONFLICT"
	ErrorCodeServiceUnavailable            ErrorCode = "SERVICE_UNAVAILABLE"
	ErrorCodeUnauthorized                  ErrorCode = "UNAUTHORIZED"
	ErrorCodeValidationError               ErrorCode = "VALIDATION_ERROR"
	ErrorCodeAPIKeyIPNotAllowed            ErrorCode = "API_KEY_IP_NOT_ALLOWED"
	ErrorCodeAgentConfirmationRequired     ErrorCode = "AGENT_CONFIRMATION_REQUIRED"
	ErrorCodeEmbedBuilderUnavailable       ErrorCode = "EMBED_BUILDER_UNAVAILABLE"
	ErrorCodeEmbedOriginNotAllowed         ErrorCode = "EMBED_ORIGIN_NOT_ALLOWED"
	ErrorCodeWorkspaceSuspended            ErrorCode = "WORKSPACE_SUSPENDED"
	ErrorCodeWorkspaceDeletionPending      ErrorCode = "WORKSPACE_DELETION_PENDING"
	ErrorCodeContactSendInProgress         ErrorCode = "CONTACT_SEND_IN_PROGRESS"
	ErrorCodeExportUnavailable             ErrorCode = "EXPORT_UNAVAILABLE"
	ErrorCodeNothingToExport               ErrorCode = "NOTHING_TO_EXPORT"
	ErrorCodeEventNameLimitReached         ErrorCode = "EVENT_NAME_LIMIT_REACHED"
	ErrorCodePlanLimitReached              ErrorCode = "PLAN_LIMIT_REACHED"
	ErrorCodeSendingReviewRequired         ErrorCode = "SENDING_REVIEW_REQUIRED"
	ErrorCodePlanFeatureUnavailable        ErrorCode = "PLAN_FEATURE_UNAVAILABLE"
	ErrorCodeCampaignAudienceConflict      ErrorCode = "CAMPAIGN_AUDIENCE_CONFLICT"
	ErrorCodeEmptyAudience                 ErrorCode = "EMPTY_AUDIENCE"
	ErrorCodeDraftIncomplete               ErrorCode = "DRAFT_INCOMPLETE"
	ErrorCodeInvalidSchedule               ErrorCode = "INVALID_SCHEDULE"
	ErrorCodeUnsupportedChannel            ErrorCode = "UNSUPPORTED_CHANNEL"
	ErrorCodePostalAddressMissing          ErrorCode = "POSTAL_ADDRESS_MISSING"
	ErrorCodeConsentMissing                ErrorCode = "CONSENT_MISSING"
	ErrorCodeSuppressed                    ErrorCode = "SUPPRESSED"
	ErrorCodeTopicUnsubscribed             ErrorCode = "TOPIC_UNSUBSCRIBED"
	ErrorCodeSignupBlocked                 ErrorCode = "SIGNUP_BLOCKED"
	ErrorCodeInvalidSenderAddress          ErrorCode = "INVALID_SENDER_ADDRESS"
	ErrorCodeSendingDomainDMARCMissing     ErrorCode = "SENDING_DOMAIN_DMARC_MISSING"
	ErrorCodeSendingDomainIdentityConflict ErrorCode = "SENDING_DOMAIN_IDENTITY_CONFLICT"
	ErrorCodeTestSendOutcomeUnknown        ErrorCode = "TEST_SEND_OUTCOME_UNKNOWN"
	ErrorCodeTestSendRouteNotReady         ErrorCode = "TEST_SEND_ROUTE_NOT_READY"
	ErrorCodeTestSendUnavailable           ErrorCode = "TEST_SEND_UNAVAILABLE"
	ErrorCodeSendingDomainUnverified       ErrorCode = "SENDING_DOMAIN_UNVERIFIED"
	ErrorCodeIdempotencyKeyReused          ErrorCode = "IDEMPOTENCY_KEY_REUSED"
	ErrorCodeIdempotencyKeyInUse           ErrorCode = "IDEMPOTENCY_KEY_IN_USE"
	ErrorCodeIdempotencyKeyOutcomeUnknown  ErrorCode = "IDEMPOTENCY_KEY_OUTCOME_UNKNOWN"
	ErrorCodeContentNotRetained            ErrorCode = "CONTENT_NOT_RETAINED"
	ErrorCodeRecipientEmailMissing         ErrorCode = "RECIPIENT_EMAIL_MISSING"
	ErrorCodeRecipientEmailUnsupported     ErrorCode = "RECIPIENT_EMAIL_UNSUPPORTED"
	ErrorCodeTemplateNotPublished          ErrorCode = "TEMPLATE_NOT_PUBLISHED"
	ErrorCodeTemplateEnvelopeIncomplete    ErrorCode = "TEMPLATE_ENVELOPE_INCOMPLETE"
	ErrorCodePushAppNotReady               ErrorCode = "PUSH_APP_NOT_READY"
	ErrorCodePushDestinationMissing        ErrorCode = "PUSH_DESTINATION_MISSING"
	ErrorCodeFormClosed                    ErrorCode = "FORM_CLOSED"
)

func (ErrorCode) IsKnown

func (v ErrorCode) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type EventCondition

type EventCondition struct {
	// The event name.
	Name string `json:"name"`
	// Only events from the last `within`.
	Within *Duration `json:"within,omitempty"`
	// Only when this event name did not follow it afterwards.
	NotFollowedBy *string `json:"notFollowedBy,omitempty"`
	// How often; defaults to at least once. `{ operator: equals, value: 0 }` is "has not
	// done".
	Count *ActivityConditionCount `json:"count,omitempty"`
	// Property conditions the event must meet, up to 5; `count` counts only events meeting
	// all of them.
	Where []EventConditionWhereItem `json:"where,omitzero"`
}

EventCondition is defined by the Kirora API.

func (EventCondition) MarshalJSON

func (v EventCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "event", which identifies a EventCondition.

type EventConditionInput

type EventConditionInput = EventCondition

EventConditionInput is defined by the Kirora API.

type EventConditionWhereItem

type EventConditionWhereItem struct {
	// The event property key.
	Property string `json:"property"`
	// `notEquals` also matches an event without the property. `equals` and `notEquals`
	// ignore case and accents in text. The date operators read the property as a date, as
	// attribute conditions do: UTC days, an ISO-8601 date is the start of that day, and a
	// property that is missing or not an ISO-8601 date or date and time never matches. They
	// read the property's own date; `within` limits when the event happened. Membership
	// moves with the calendar: a contact enters when the date comes into range, with no new
	// event, and a journey triggered by entering the segment then starts for them.
	Operator WhereOperator `json:"operator"`
	// What to compare with, as text: as for the other operators, an ISO date for `before`
	// and `after`, and a whole number of days, `"1"` to `"3650"`, for `withinLastDays`,
	// `moreThanDaysAgo` and `inNextDays`.
	Value string `json:"value"`
}

EventConditionWhereItem is defined by the Kirora API.

type EventContextInput

type EventContextInput struct {
	// The visit, from the SDK.
	SessionID *string `json:"sessionId,omitempty"`
	// As BCP 47, `en-GB`.
	Locale *string `json:"locale,omitempty"`
	// As IANA, `Europe/Berlin`.
	Timezone *string `json:"timezone,omitempty"`
	// Web: the page as visited: query strings kept, fragments removed. A longer value is
	// cut, not refused: `url`, `search` and `referrer` at 8192 characters, `path` at 2048,
	// `title` at 256.
	Page *EventContextInputPage `json:"page,omitempty"`
	// Web: the `utm_*` parameters of the page, each cut to 256 characters.
	Campaign  *EventContextInputCampaign `json:"campaign,omitempty"`
	Device    *EventContextInputDevice   `json:"device,omitempty"`
	Library   *EventContextInputLibrary  `json:"library,omitempty"`
	IP        *string                    `json:"ip,omitempty"`
	UserAgent *string                    `json:"userAgent,omitempty"`
}

EventContextInput is defined by the Kirora API.

type EventContextInputCampaign

type EventContextInputCampaign struct {
	Source  *string `json:"source,omitempty"`
	Medium  *string `json:"medium,omitempty"`
	Name    *string `json:"name,omitempty"`
	Term    *string `json:"term,omitempty"`
	Content *string `json:"content,omitempty"`
}

EventContextInputCampaign: Web: the `utm_*` parameters of the page, each cut to 256 characters.

type EventContextInputDevice

type EventContextInputDevice struct {
	// A random id the SDK keeps on the device; never a hardware id.
	ID *string `json:"id,omitempty"`
}

EventContextInputDevice is defined by the Kirora API.

type EventContextInputLibrary

type EventContextInputLibrary struct {
	Name    *string `json:"name,omitempty"`
	Version *string `json:"version,omitempty"`
}

EventContextInputLibrary is defined by the Kirora API.

type EventContextInputPage

type EventContextInputPage struct {
	// The canonical URL if the page has one, with the page's query string added unless it
	// has its own; else the page's address.
	URL  *string `json:"url,omitempty"`
	Path *string `json:"path,omitempty"`
	// The visited address's query string, `?plan=pro`; empty or absent when it has none.
	Search   *string `json:"search,omitempty"`
	Title    *string `json:"title,omitempty"`
	Referrer *string `json:"referrer,omitempty"`
}

EventContextInputPage: Web: the page as visited: query strings kept, fragments removed. A longer value is cut, not refused: `url`, `search` and `referrer` at 8192 characters, `path` at 2048, `title` at 256.

type EventsService

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

EventsService records what contacts do.

func (*EventsService) Track

func (s *EventsService) Track(ctx context.Context, params *TrackEventInput, opts ...CallOption) (*TrackedEvent, error)

Track records an event (trackEvent). Retries reuse one idempotency key, so they never record it twice.

Example
package main

import (
	"context"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	// A key derived from the order makes sending it again safe: the event is recorded once.
	_, err := client.Events.Track(ctx, &kirora.TrackEventInput{
		ExternalID: kirora.Ptr("user-1"),
		Name:       "Order Completed",
		Properties: map[string]any{"total": 49.99, "currency": "GBP"},
	}, kirora.WithIdempotencyKey("order-1234-completed"))
	if err != nil {
		log.Fatal(err)
	}
}

func (*EventsService) TrackBatch

TrackBatch records up to 100 events, each with its own IdempotencyKey (trackEventsBatch). One event refused doesn't stop the rest: each entry in Results, in the order sent, has either the event or an Error. An error from TrackBatch itself means the whole batch was refused.

An entry without its own key gets one per call, which covers the SDK's retries only.

Example
package main

import (
	"context"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	result, err := client.Events.TrackBatch(ctx, &kirora.TrackEventsBatchInput{
		Events: []kirora.TrackEventsBatchEntry{{
			IdempotencyKey: kirora.Ptr("order-1234-completed"),
			Event:          kirora.TrackEventInput{ExternalID: kirora.Ptr("user-1"), Name: "Order Completed"},
		}},
	})
	if err != nil {
		log.Fatal(err)
	}
	// One event refused doesn't fail the batch, so check each result.
	for i, entry := range result.Results {
		if entry.Error != nil {
			log.Printf("event %d not tracked: %s", i, entry.Error.Code)
		}
	}
}

type FieldError

type FieldError struct {
	// The part of the request the field is in, when known.
	In *FieldErrorIn `json:"in,omitempty"`
	// Dotted path to the field (`blocks.0.text`); empty for the whole part.
	Field string `json:"field"`
	// The rule that failed (`too_big`, `invalid_type`, `custom`, …).
	Code *string `json:"code,omitempty"`
	// Plain words, meant to be shown beside the field.
	Message string `json:"message"`
	// The bound a `too_small` rule set.
	Minimum *float64 `json:"minimum,omitempty"`
	// The bound a `too_big` rule set.
	Maximum *float64 `json:"maximum,omitempty"`
}

FieldError is defined by the Kirora API.

type FieldErrorIn

type FieldErrorIn string

FieldErrorIn: The part of the request the field is in, when known.

const (
	FieldErrorInBody    FieldErrorIn = "body"
	FieldErrorInQuery   FieldErrorIn = "query"
	FieldErrorInParams  FieldErrorIn = "params"
	FieldErrorInHeaders FieldErrorIn = "headers"
)

func (FieldErrorIn) IsKnown

func (v FieldErrorIn) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type FooterBlock

type FooterBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style  *EmailBlockStyle `json:"style,omitempty"`
	Text   *string          `json:"text,omitempty"`
	Locked *bool            `json:"locked,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// False leaves out the unsubscribe link, for a transactional email (a receipt, a sign-in
	// code). A marketing send adds the sender's own link anyway.
	UnsubscribeLink *bool `json:"unsubscribeLink,omitempty"`
	// The words of the unsubscribe link, "Unsubscribe" by default. The link opens a page
	// that also manages topic preferences, so "Unsubscribe or manage preferences" is
	// accurate.
	UnsubscribeLabel *string `json:"unsubscribeLabel,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

FooterBlock is defined by the Kirora API.

func (FooterBlock) MarshalJSON

func (v FooterBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "footer", which identifies a FooterBlock, and the properties in Extra.

func (*FooterBlock) UnmarshalJSON

func (v *FooterBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type FooterBlockInput

type FooterBlockInput = FooterBlock

FooterBlockInput is defined by the Kirora API.

type FormSubmissionOutcome

type FormSubmissionOutcome string

FormSubmissionOutcome: Values other than these constants may be added to the API at any time.

const (
	FormSubmissionOutcomeCreated  FormSubmissionOutcome = "created"
	FormSubmissionOutcomeUpdated  FormSubmissionOutcome = "updated"
	FormSubmissionOutcomeHoneypot FormSubmissionOutcome = "honeypot"
	FormSubmissionOutcomePending  FormSubmissionOutcome = "pending"
	FormSubmissionOutcomeExpired  FormSubmissionOutcome = "expired"
)

func (FormSubmissionOutcome) IsKnown

func (v FormSubmissionOutcome) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type HTMLBlock

type HTMLBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HTMLBlock is defined by the Kirora API.

func (HTMLBlock) MarshalJSON

func (v HTMLBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "html", which identifies a HTMLBlock, and the properties in Extra.

func (*HTMLBlock) UnmarshalJSON

func (v *HTMLBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HTMLBlockInput

type HTMLBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HTMLBlockInput is defined by the Kirora API.

func (HTMLBlockInput) MarshalJSON

func (v HTMLBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "html", which identifies a HTMLBlockInput, and the properties in Extra.

func (*HTMLBlockInput) UnmarshalJSON

func (v *HTMLBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HTMLSnapshotInput

type HTMLSnapshotInput struct {
	// The whole email as HTML. Merge tags work as in a design; `{{unsubscribe_url}}` as a
	// link's href places the unsubscribe link, which marketing sends otherwise get below the
	// email, with the workspace postal address when the email does not show it.
	HTML string `json:"html"`
	// Plain text sent instead of the version generated from the HTML.
	PlainTextOverride Nullable[string] `json:"plainTextOverride,omitzero"`
}

HTMLSnapshotInput is defined by the Kirora API.

func (HTMLSnapshotInput) MarshalJSON

func (v HTMLSnapshotInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "kind": "html", which identifies a HTMLSnapshotInput.

type HeaderBlock

type HeaderBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The logo image's URL; without one, the brand kit's logo.
	Src *string `json:"src,omitempty"`
	// The logo's alt text. Without `src` or a brand kit logo, it shows as a wordmark in the
	// heading font; gallery samples set it to `{{ org.name }}`.
	Alt *string `json:"alt,omitempty"`
	// A share of the row ("100%", "66%", "50%"), or a fixed width from "16px" to "600px",
	// such as "120px" for a logo. Never wider than the row.
	Width *HeaderBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HeaderBlock is defined by the Kirora API.

func (HeaderBlock) MarshalJSON

func (v HeaderBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "header", which identifies a HeaderBlock, and the properties in Extra.

func (*HeaderBlock) UnmarshalJSON

func (v *HeaderBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HeaderBlockInput

type HeaderBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The logo image's URL; without one, the brand kit's logo.
	Src *string `json:"src,omitempty"`
	// The logo's alt text. Without `src` or a brand kit logo, it shows as a wordmark in the
	// heading font; gallery samples set it to `{{ org.name }}`.
	Alt *string `json:"alt,omitempty"`
	// A share of the row ("100%", "66%", "50%"), or a fixed width from "16px" to "600px",
	// such as "120px" for a logo. Never wider than the row.
	Width *HeaderBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HeaderBlockInput is defined by the Kirora API.

func (HeaderBlockInput) MarshalJSON

func (v HeaderBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "header", which identifies a HeaderBlockInput, and the properties in Extra.

func (*HeaderBlockInput) UnmarshalJSON

func (v *HeaderBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HeaderBlockWidth

type HeaderBlockWidth string

HeaderBlockWidth: A share of the row ("100%", "66%", "50%"), or a fixed width from "16px" to "600px", such as "120px" for a logo. Never wider than the row.

const (
	HeaderBlockWidth100 HeaderBlockWidth = "100%"
	HeaderBlockWidth66  HeaderBlockWidth = "66%"
	HeaderBlockWidth50  HeaderBlockWidth = "50%"
)

func (HeaderBlockWidth) IsKnown

func (v HeaderBlockWidth) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type HeadingBlock

type HeadingBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn           `json:"showOn,omitempty"`
	Text   *string           `json:"text,omitempty"`
	Size   *HeadingBlockSize `json:"size,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align  *Align                     `json:"align,omitempty"`
	Weight *EmailBlockStyleFontWeight `json:"weight,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HeadingBlock is defined by the Kirora API.

func (HeadingBlock) MarshalJSON

func (v HeadingBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "heading", which identifies a HeadingBlock, and the properties in Extra.

func (*HeadingBlock) UnmarshalJSON

func (v *HeadingBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HeadingBlockInput

type HeadingBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn           `json:"showOn,omitempty"`
	Text   *string           `json:"text,omitempty"`
	Size   *HeadingBlockSize `json:"size,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align  *Align                     `json:"align,omitempty"`
	Weight *EmailBlockStyleFontWeight `json:"weight,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

HeadingBlockInput is defined by the Kirora API.

func (HeadingBlockInput) MarshalJSON

func (v HeadingBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "heading", which identifies a HeadingBlockInput, and the properties in Extra.

func (*HeadingBlockInput) UnmarshalJSON

func (v *HeadingBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type HeadingBlockSize

type HeadingBlockSize string

HeadingBlockSize: Values other than these constants may be added to the API at any time.

const (
	HeadingBlockSize28px HeadingBlockSize = "28px"
	HeadingBlockSize22px HeadingBlockSize = "22px"
	HeadingBlockSize18px HeadingBlockSize = "18px"
)

func (HeadingBlockSize) IsKnown

func (v HeadingBlockSize) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type IdentifyContactInput

type IdentifyContactInput struct {
	// Your own id for the contact, up to 255 characters. Identify matches on it first.
	ExternalID Nullable[string] `json:"externalId,omitzero"`
	Email      Nullable[string] `json:"email,omitzero"`
	FirstName  Nullable[string] `json:"firstName,omitzero"`
	LastName   Nullable[string] `json:"lastName,omitzero"`
	// Phone number; normalised to E.164 (a leading `+` and country code).
	Phone Nullable[string] `json:"phone,omitzero"`
	// IANA timezone, e.g. `Europe/London`; used for send-time scheduling.
	Timezone Nullable[string] `json:"timezone,omitzero"`
	// ISO 3166-1 alpha-2 code. Omitted, it is inferred from the phone, else the timezone.
	Country Nullable[string] `json:"country,omitzero"`
	// BCP 47 tag (`fr`, `fr-CA`), stored canonical: the language the contact reads, and how
	// merge tags format numbers, dates and money for them.
	Locale Nullable[string] `json:"locale,omitzero"`
	// Named calendar dates, merged key by key; `null` removes one. A key held in
	// `attributes` is refused with 400 `VALIDATION_ERROR` at `dates.<key>`: set it to `null`
	// there in the same write to move it.
	Dates ContactDatesInput `json:"dates,omitzero"`
	// Custom attributes, merged key by key; `null` removes one. At most 50 keys and 16 KB.
	Attributes map[string]any `json:"attributes,omitzero"`
	// Consent on each channel, and how the contact agreed.
	Consent *SetContactConsentInput `json:"consent,omitempty"`
	// Topic choices keyed by topic id, at most 50, as `PUT
	// /v1/contacts/{id}/topics/{topicId}` sets them: `{ "subscribed": true }` for every
	// channel, or `{ "channels": { "email": … } }` per channel. Each change is recorded in
	// consent changes with this request; an unknown topic id refuses the whole write with
	// `VALIDATION_ERROR` at `topics.<id>`.
	Topics map[string]TopicChoiceInput `json:"topics,omitzero"`
	// Names of lists to add the contact to, up to 20, matched without case; a list the
	// workspace lacks is created. Adds only: the contact stays in the lists it is already
	// in.
	Lists []string `json:"lists,omitzero"`
}

IdentifyContactInput is defined by the Kirora API.

type IdentifyContactMeta

type IdentifyContactMeta struct {
	Created bool `json:"created"`
}

IdentifyContactMeta is defined by the Kirora API.

type IdentifyContactsBatchInput

type IdentifyContactsBatchInput struct {
	Contacts []IdentifyContactInput `json:"contacts"`
}

IdentifyContactsBatchInput is defined by the Kirora API.

type IdentifyContactsBatchResult

type IdentifyContactsBatchResult struct {
	Results []IdentifyContactsBatchResultEntry `json:"results"`
}

IdentifyContactsBatchResult is defined by the Kirora API.

type IdentifyContactsBatchResultEntry

type IdentifyContactsBatchResultEntry struct {
	// Whether a new contact was created.
	Created *bool          `json:"created,omitempty"`
	Contact *ContactDetail `json:"contact,omitempty"`
	Error   *BatchError    `json:"error,omitempty"`
}

IdentifyContactsBatchResultEntry is defined by the Kirora API.

type IfTimeHasPassed

type IfTimeHasPassed string

IfTimeHasPassed: Where the time has already gone when it is scheduled: `send_now` sends there at once, `next_day` at the same time the next day, and `skip` leaves those contacts out (skipped with `local_time_passed`).

const (
	IfTimeHasPassedSendNow IfTimeHasPassed = "send_now"
	IfTimeHasPassedSkip    IfTimeHasPassed = "skip"
	IfTimeHasPassedNextDay IfTimeHasPassed = "next_day"
)

func (IfTimeHasPassed) IsKnown

func (v IfTimeHasPassed) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type ImageBlock

type ImageBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	// A share of the row ("100%", "66%", "50%"), or a fixed width from "16px" to "600px",
	// such as "120px" for a logo. Never wider than the row.
	Width *HeaderBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageBlock is defined by the Kirora API.

func (ImageBlock) MarshalJSON

func (v ImageBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "image", which identifies a ImageBlock, and the properties in Extra.

func (*ImageBlock) UnmarshalJSON

func (v *ImageBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageBlockInput

type ImageBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	// A share of the row ("100%", "66%", "50%"), or a fixed width from "16px" to "600px",
	// such as "120px" for a logo. Never wider than the row.
	Width *HeaderBlockWidth `json:"width,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageBlockInput is defined by the Kirora API.

func (ImageBlockInput) MarshalJSON

func (v ImageBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "image", which identifies a ImageBlockInput, and the properties in Extra.

func (*ImageBlockInput) UnmarshalJSON

func (v *ImageBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageGroupBlock

type ImageGroupBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn                `json:"showOn,omitempty"`
	Count  *float64               `json:"count,omitempty"`
	Images []ImageGroupBlockImage `json:"images,omitzero"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageGroupBlock is defined by the Kirora API.

func (ImageGroupBlock) MarshalJSON

func (v ImageGroupBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "imagegroup", which identifies a ImageGroupBlock, and the properties in Extra.

func (*ImageGroupBlock) UnmarshalJSON

func (v *ImageGroupBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageGroupBlockImage

type ImageGroupBlockImage struct {
	Src *string `json:"src,omitempty"`
	Alt *string `json:"alt,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageGroupBlockImage is defined by the Kirora API.

func (ImageGroupBlockImage) MarshalJSON

func (v ImageGroupBlockImage) MarshalJSON() ([]byte, error)

MarshalJSON adds the properties in Extra.

func (*ImageGroupBlockImage) UnmarshalJSON

func (v *ImageGroupBlockImage) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageGroupBlockInput

type ImageGroupBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn                `json:"showOn,omitempty"`
	Count  *float64               `json:"count,omitempty"`
	Images []ImageGroupBlockImage `json:"images,omitzero"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageGroupBlockInput is defined by the Kirora API.

func (ImageGroupBlockInput) MarshalJSON

func (v ImageGroupBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "imagegroup", which identifies a ImageGroupBlockInput, and the properties in Extra.

func (*ImageGroupBlockInput) UnmarshalJSON

func (v *ImageGroupBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageTextBlock

type ImageTextBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Which side the image sits on; unset, the start of the reading direction (left, or
	// right in a right-to-left language).
	Side *ImageTextBlockSide `json:"side,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageTextBlock is defined by the Kirora API.

func (ImageTextBlock) MarshalJSON

func (v ImageTextBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "imagetext", which identifies a ImageTextBlock, and the properties in Extra.

func (*ImageTextBlock) UnmarshalJSON

func (v *ImageTextBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageTextBlockInput

type ImageTextBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Which side the image sits on; unset, the start of the reading direction (left, or
	// right in a right-to-left language).
	Side *ImageTextBlockSide `json:"side,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ImageTextBlockInput is defined by the Kirora API.

func (ImageTextBlockInput) MarshalJSON

func (v ImageTextBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "imagetext", which identifies a ImageTextBlockInput, and the properties in Extra.

func (*ImageTextBlockInput) UnmarshalJSON

func (v *ImageTextBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ImageTextBlockSide

type ImageTextBlockSide string

ImageTextBlockSide: Which side the image sits on; unset, the start of the reading direction (left, or right in a right-to-left language).

const (
	ImageTextBlockSideLeft  ImageTextBlockSide = "left"
	ImageTextBlockSideRight ImageTextBlockSide = "right"
)

func (ImageTextBlockSide) IsKnown

func (v ImageTextBlockSide) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type InstallationCondition

type InstallationCondition struct {
	// `active`: reachable by push (granted, active, not invalidated); `none`: not.
	Has InstallationConditionHas `json:"has"`
	// Only devices of this push project; any when omitted.
	PushProjectID *string `json:"pushProjectId,omitempty"`
	// Only devices on this platform; any when omitted.
	Platform *InstallationConditionPlatform `json:"platform,omitempty"`
}

InstallationCondition is defined by the Kirora API.

func (InstallationCondition) MarshalJSON

func (v InstallationCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "installation", which identifies a InstallationCondition.

type InstallationConditionHas

type InstallationConditionHas string

InstallationConditionHas: `active`: reachable by push (granted, active, not invalidated); `none`: not.

const (
	InstallationConditionHasActive InstallationConditionHas = "active"
	InstallationConditionHasNone   InstallationConditionHas = "none"
)

func (InstallationConditionHas) IsKnown

func (v InstallationConditionHas) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type InstallationConditionInput

type InstallationConditionInput = InstallationCondition

InstallationConditionInput is defined by the Kirora API.

type InstallationConditionPlatform

type InstallationConditionPlatform string

InstallationConditionPlatform: Only devices on this platform; any when omitted.

const (
	InstallationConditionPlatformIOS     InstallationConditionPlatform = "ios"
	InstallationConditionPlatformAndroid InstallationConditionPlatform = "android"
	InstallationConditionPlatformWeb     InstallationConditionPlatform = "web"
)

func (InstallationConditionPlatform) IsKnown

func (v InstallationConditionPlatform) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type InterruptionLevel

type InterruptionLevel string

InterruptionLevel: How iOS presents it: `passive` arrives silently, `time-sensitive` can break through Focus when the user allows it, and needs the app's Time Sensitive Notifications capability.

const (
	InterruptionLevelPassive       InterruptionLevel = "passive"
	InterruptionLevelActive        InterruptionLevel = "active"
	InterruptionLevelTimeSensitive InterruptionLevel = "time-sensitive"
)

func (InterruptionLevel) IsKnown

func (v InterruptionLevel) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type JourneyStatus

type JourneyStatus string

JourneyStatus: Values other than these constants may be added to the API at any time.

const (
	JourneyStatusActive    JourneyStatus = "active"
	JourneyStatusCompleted JourneyStatus = "completed"
	JourneyStatusExited    JourneyStatus = "exited"
)

func (JourneyStatus) IsKnown

func (v JourneyStatus) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type List

type List struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description *string   `json:"description"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

List is defined by the Kirora API.

type ListBlock

type ListBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ListBlock is defined by the Kirora API.

func (ListBlock) MarshalJSON

func (v ListBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "list", which identifies a ListBlock, and the properties in Extra.

func (*ListBlock) UnmarshalJSON

func (v *ListBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ListBlockInput

type ListBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ListBlockInput is defined by the Kirora API.

func (ListBlockInput) MarshalJSON

func (v ListBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "list", which identifies a ListBlockInput, and the properties in Extra.

func (*ListBlockInput) UnmarshalJSON

func (v *ListBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ListCampaignsParams

type ListCampaignsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
	// Part of the campaign's name, ignoring case.
	Query *string
	// Only campaigns in this status.
	Status *CampaignStatus
	// `true` lists archived campaigns only; unset or `false` leaves them out.
	Archived *bool
	// Only items carrying this tag, its name matched without case.
	Tag *string
	// `true`: only campaigns waiting in the agent review queue; `false`: only those not.
	PendingAgentReview *bool
}

ListCampaignsParams filters listCampaigns.

type ListCondition

type ListCondition struct {
	// One list or several: with `member: true` in any of them, with `false` in none of them.
	// Each must be one of the workspace's lists when the rules are saved.
	ListIDs []string `json:"listIds"`
	// True for in the lists, false for not in them.
	Member bool `json:"member"`
}

ListCondition is defined by the Kirora API.

func (ListCondition) MarshalJSON

func (v ListCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "list", which identifies a ListCondition.

type ListConditionInput

type ListConditionInput = ListCondition

ListConditionInput is defined by the Kirora API.

type ListContactListsParams

type ListContactListsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
}

ListContactListsParams filters listContactLists.

type ListContactsInput

type ListContactsInput struct {
	// Kirora's ids for the contacts.
	ContactIDs []string `json:"contactIds,omitzero"`
	// Your own ids for the contacts, as set with identify.
	ExternalIDs []string `json:"externalIds,omitzero"`
	// Email addresses, matched trimmed and without case.
	Emails []string `json:"emails,omitzero"`
}

ListContactsInput is defined by the Kirora API.

type ListContactsParams

type ListContactsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
	// Searches any part of the email address or name, ignoring case and accents in any
	// script.
	Query *string
	// Comma-separated channels, e.g. `email,push`: consent granted on each.
	Consent *string
	// Whether email to the contact, or to its address, is suppressed.
	Suppressed *bool
	// Only members of this list.
	ListID *string
	// The segment's members as stored at its last background sweep, so a contact that
	// matches only since then is not in it yet. For the live answer, list the segment's
	// contacts (`GET /v1/segments/{id}/contacts`).
	SegmentID *string
	// Only contacts created at or after this time (inclusive).
	CreatedAfter *time.Time
	// Only contacts created before this time (exclusive).
	CreatedBefore *time.Time
}

ListContactsParams filters listContacts.

type ListListsParams

type ListListsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
	// Part of the list's name, ignoring case.
	Query *string
}

ListListsParams filters listLists.

type ListMessagesParams

type ListMessagesParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
	// Only messages in this status.
	Status *MessageStatus
	// Only messages on this channel.
	Channel *ChannelInput
	// The exact address the message went to.
	Recipient *string
	// Part of the recipient's email address or name, matched against the contact the message
	// went to.
	Query *string
	// Only messages of this type: `marketing` or `transactional`.
	MessageType *MessageType
	// Only messages from this campaign.
	CampaignID *string
	// Only messages from this journey.
	JourneyID *string
	// With `journeyId`, only messages from the journey's step with this id, in every version
	// of its steps.
	StepID *string
	// Only transactional sends from this stored template; no other message records one.
	TemplateID *string
	// Only the transactional sends that carried this `correlationId`.
	CorrelationID *string
	// `true`: handed to the provider, whatever happened after; `false`: never sent (queued,
	// failed before sending or skipped).
	Sent *bool
	// `true`: delivery was confirmed, even if a complaint or bounce came later; `false`:
	// never confirmed.
	Delivered *bool
	// `true`: a hard bounce was recorded, even if a complaint came later; `false`: none. A
	// test send's acted-out bounce is no recorded bounce.
	Bounced *bool
	// `true`: a complaint was recorded; `false`: none. A test send's acted-out complaint is
	// no recorded complaint.
	Complained *bool
	// `true`: opened (or clicked) at least once; `false`: never.
	Opened *bool
	// `true`: a link clicked at least once; `false`: never.
	Clicked *bool
	// Only messages accepted at or after this time (inclusive).
	CreatedAfter *time.Time
	// Only messages accepted before this time (exclusive).
	CreatedBefore *time.Time
}

ListMessagesParams filters listMessages.

type ListPushInstallationsParams

type ListPushInstallationsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
}

ListPushInstallationsParams filters listPushInstallations.

type ListSuppressionsParams

type ListSuppressionsParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
	// One address, matched trimmed and without case: is it blocked?
	Email *string
	// Case-insensitive part of the address.
	Query *string
	// Only blocks with this reason.
	Reason *SuppressionReasonInput
	// Only blocks made at or after this time (inclusive).
	CreatedAfter *time.Time
	// Only blocks made before this time (exclusive).
	CreatedBefore *time.Time
}

ListSuppressionsParams filters listSuppressions.

type ListWorkspacesParams

type ListWorkspacesParams struct {
	// How many items a page holds: 1 to 100, 20 by default.
	Limit *int
	// Where the page starts: the previous page's `meta.pagination.nextCursor`. Omit it for
	// the first page, and send the same filters with it.
	Cursor *string
}

ListWorkspacesParams filters listWorkspaces.

type ListsPage

type ListsPage = Page[List, CursorPaginationMeta]

ListsPage is a page of lists.

type ListsService

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

ListsService manages lists of contacts.

func (*ListsService) AddContacts

func (s *ListsService) AddContacts(ctx context.Context, listID string, params *ListContactsInput, opts ...CallOption) (*AddedListContacts, error)

AddContacts adds contacts to a list, by ContactIDs, ExternalIDs or Emails (addListContacts). Existing members are skipped. A key is made for the call, so a retry replays the first result rather than reporting none added.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	list, err := client.Lists.Create(ctx, &kirora.CreateListInput{
		Name:        "Beta testers",
		Description: kirora.Value("Opted in to early features"),
	})
	if err != nil {
		log.Fatal(err)
	}
	added, err := client.Lists.AddContacts(ctx, list.ID, &kirora.ListContactsInput{
		Emails: []string{"ada@example.com", "alan@example.com"},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(added.AddedCount, "added; not found:", added.NotFound)
}

func (*ListsService) All

func (s *ListsService) All(ctx context.Context, params *ListListsParams, opts ...CallOption) iter.Seq2[List, error]

All iterates over every list, fetching pages as it goes (listLists).

func (*ListsService) Create

func (s *ListsService) Create(ctx context.Context, params *CreateListInput, opts ...CallOption) (*List, error)

Create creates a list (createList). Retries reuse one idempotency key, so they never create two.

func (*ListsService) Delete

func (s *ListsService) Delete(ctx context.Context, listID string, opts ...CallOption) error

Delete deletes a list, but not its contacts (deleteList). Safe to retry: a retry that finds it already deleted succeeds.

func (*ListsService) DeleteContacts

func (s *ListsService) DeleteContacts(ctx context.Context, listID string, params *ListContactsInput, opts ...CallOption) (*DeletedListContacts, error)

DeleteContacts removes contacts from a list, not from Kirora (deleteListContacts). Non-members are skipped. A key is made for the call, so a retry replays the first result rather than reporting none removed.

func (*ListsService) Get

func (s *ListsService) Get(ctx context.Context, listID string, opts ...CallOption) (*List, error)

Get fetches a list (getList).

func (*ListsService) List

func (s *ListsService) List(ctx context.Context, params *ListListsParams, opts ...CallOption) (*ListsPage, error)

List fetches a page of lists (listLists). See All for every list.

func (*ListsService) Update

func (s *ListsService) Update(ctx context.Context, listID string, params *UpdateListInput, opts ...CallOption) (*List, error)

Update changes a list (updateList). Safe to retry.

type MenuBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The entries, left to right: at most 8 { label, href }.
	Links []SocialBlockLink `json:"links,omitzero"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// What stands between entries: space only, a bar or a dot.
	Separator *MenuBlockSeparator `json:"separator,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

MenuBlock is defined by the Kirora API.

func (v MenuBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "menu", which identifies a MenuBlock, and the properties in Extra.

func (v *MenuBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type MenuBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The entries, left to right: at most 8 { label, href }.
	Links []SocialBlockInputLink `json:"links,omitzero"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// What stands between entries: space only, a bar or a dot.
	Separator *MenuBlockSeparator `json:"separator,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

MenuBlockInput is defined by the Kirora API.

func (v MenuBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "menu", which identifies a MenuBlockInput, and the properties in Extra.

func (v *MenuBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type MenuBlockSeparator string

MenuBlockSeparator: What stands between entries: space only, a bar or a dot.

const (
	MenuBlockSeparatorNone MenuBlockSeparator = "none"
	MenuBlockSeparatorBar  MenuBlockSeparator = "bar"
	MenuBlockSeparatorDot  MenuBlockSeparator = "dot"
)
func (v MenuBlockSeparator) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type MergeContactInput

type MergeContactInput struct {
	// The contact to keep, named one way; the contact in the path merges into it and is
	// deleted.
	Keep ContactIdentifierInput `json:"keep"`
}

MergeContactInput is defined by the Kirora API.

type MessageCopy added in v0.2.0

type MessageCopy struct {
	Kind MessageCopyKind `json:"kind"`
	// The message it is a copy of.
	Of string `json:"of"`
}

MessageCopy is defined by the Kirora API.

type MessageCopyKind added in v0.2.0

type MessageCopyKind string

MessageCopyKind: Values other than these constants may be added to the API at any time.

const (
	MessageCopyKindCC  MessageCopyKind = "cc"
	MessageCopyKindBCC MessageCopyKind = "bcc"
)

func (MessageCopyKind) IsKnown added in v0.2.0

func (v MessageCopyKind) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type MessageLimitUse

type MessageLimitUse struct {
	// Whether its messages count toward the workspace's message limits and are held by them.
	Apply bool `json:"apply"`
	// How long a message over a limit keeps being retried before it is skipped with reason
	// `message_limit`: whole hours, at most 48. Unset, it is skipped at once. Absent when
	// `apply` is false.
	RetryFor *Duration `json:"retryFor,omitempty"`
}

MessageLimitUse is defined by the Kirora API.

type MessageLimitUseInput

type MessageLimitUseInput = MessageLimitUse

MessageLimitUseInput is defined by the Kirora API.

type MessageStatus

type MessageStatus string

MessageStatus: Values other than these constants may be added to the API at any time.

const (
	MessageStatusQueued     MessageStatus = "queued"
	MessageStatusSending    MessageStatus = "sending"
	MessageStatusSkipped    MessageStatus = "skipped"
	MessageStatusSent       MessageStatus = "sent"
	MessageStatusFailed     MessageStatus = "failed"
	MessageStatusDelivered  MessageStatus = "delivered"
	MessageStatusBounced    MessageStatus = "bounced"
	MessageStatusComplained MessageStatus = "complained"
)

func (MessageStatus) IsKnown

func (v MessageStatus) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type MessageType

type MessageType string

MessageType: Values other than these constants may be added to the API at any time.

const (
	MessageTypeMarketing     MessageType = "marketing"
	MessageTypeTransactional MessageType = "transactional"
)

func (MessageType) IsKnown

func (v MessageType) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type MessagesPage

type MessagesPage = Page[OutboundMessage, CursorPaginationMeta]

MessagesPage is a page of sent messages.

type MessagesService

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

MessagesService reads the log of every message sent, by any campaign, journey or transactional send.

func (*MessagesService) All

All iterates over every message, newest first, fetching pages as it goes (listMessages).

Example
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	bounced := kirora.MessageStatusBounced
	since := time.Now().Add(-24 * time.Hour)
	for message, err := range client.Messages.All(ctx, &kirora.ListMessagesParams{Status: &bounced, CreatedAfter: &since}) {
		if err != nil {
			log.Fatal(err)
		}
		if message.RecipientEmail != nil {
			fmt.Println(*message.RecipientEmail, message.CreatedAt)
		}
	}
}

func (*MessagesService) Get

func (s *MessagesService) Get(ctx context.Context, messageID string, opts ...CallOption) (*OutboundMessage, error)

Get fetches one message from the log, whatever sent it (getMessage).

func (*MessagesService) List

func (s *MessagesService) List(ctx context.Context, params *ListMessagesParams, opts ...CallOption) (*MessagesPage, error)

List fetches a page of messages, newest first (listMessages). Filter by Status, Recipient, CorrelationID and more. See All for every message.

type Money

type Money struct {
	// The currency, an ISO 4217 code; null when none was named.
	Currency *string `json:"currency"`
	// The amount in that currency.
	Value float64 `json:"value"`
}

Money is defined by the Kirora API.

type Nullable

type Nullable[T any] struct {
	// contains filtered or unexported fields
}

Nullable is an optional field that can also be set to null, as on an update, where null clears a value and leaving the field out keeps it. Its zero value leaves the field out.

kirora.UpdateContactInput{
	FirstName: kirora.Value("Ada"), // sets it
	LastName:  kirora.Null[string](), // clears it
	// Phone is left as it is
}

func Null

func Null[T any]() Nullable[T]

Null returns a Nullable set to null.

func Value

func Value[T any](v T) Nullable[T]

Value returns a Nullable set to v.

func (Nullable[T]) Get

func (n Nullable[T]) Get() (T, bool)

Get returns the value, and whether there is one: false if it's null or unset.

func (Nullable[T]) IsNull

func (n Nullable[T]) IsNull() bool

IsNull reports whether it's set to null.

func (Nullable[T]) IsZero

func (n Nullable[T]) IsZero() bool

IsZero reports whether it's unset, so the `omitzero` option leaves it out of JSON.

func (Nullable[T]) MarshalJSON

func (n Nullable[T]) MarshalJSON() ([]byte, error)

func (*Nullable[T]) UnmarshalJSON

func (n *Nullable[T]) UnmarshalJSON(data []byte) error

type Option

type Option func(*settings) error

Option configures a Client when passed to NewClient, or a single call when passed to a method. The With functions in this package return one.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets the API host, without /v1, such as a mock server's URL in tests. It must be an http or https URL without a query or fragment; a path, such as a proxy's /kirora, goes before each request's /v1. The default is DefaultBaseURL, or KIRORA_BASE_URL when set.

Example

This example tests code that uses the SDK against a fake Kirora API.

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"net/http/httptest"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.Method + " " + r.URL.Path {
		case "GET /v1/lists/beta":
			w.Header().Set("Content-Type", "application/json")
			fmt.Fprint(w, `{"data":{"id":"beta","name":"Beta testers"}}`)
		default:
			w.WriteHeader(http.StatusNotFound)
			fmt.Fprint(w, `{"error":{"code":"NOT_FOUND","message":"no such route"}}`)
		}
	}))
	defer server.Close()

	// No retries, so an error from the fake comes back at once.
	client, err := kirora.NewClient("test-key", kirora.WithBaseURL(server.URL), kirora.WithMaxRetries(0))
	if err != nil {
		log.Fatal(err)
	}
	list, err := client.Lists.Get(context.Background(), "beta")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(list.Name)
	_, err = client.Lists.Get(context.Background(), "missing")
	fmt.Println(kirora.IsErrorCode(err, kirora.ErrorCodeNotFound))
}
Output:
Beta testers
true

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the *http.Client that sends requests, such as one with a proxy or custom transport. The default is http.DefaultClient. The client must not be nil. Its CheckRedirect isn't used: the SDK returns a redirect as a ResponseError.

func WithHeader

func WithHeader(name, value string) Option

WithHeader adds a header to every request, alongside any value the header already has. It can't replace the headers the SDK sets itself, such as Authorization. Idempotency-Key is the same as WithIdempotencyKey, so NewClient refuses it, since every call would share it. Kirora-Workspace is the same as WithWorkspace.

func WithMaxRetries

func WithMaxRetries(n int) Option

WithMaxRetries sets how many times a failed request is retried after the first attempt, from 0 to 10. The default is 3. Only failures a retry can't duplicate are retried: rate limits, connections never made, and, for operations that are safe to repeat or carry an idempotency key, other network errors and 5xx responses.

func WithMaxRetryDelay

func WithMaxRetryDelay(d time.Duration) Option

WithMaxRetryDelay sets the longest single wait between attempts. The default is 30 seconds, and d must not be negative. If the API asks, with Retry-After, for a longer wait than d, the call isn't retried and returns the *Error.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets how long each attempt may take, including reading the response. A call that retries can take longer in total; use the context for an overall deadline. The default is 30 seconds, and the timeout must be positive.

func WithWorkspace

func WithWorkspace(externalID string) Option

WithWorkspace makes calls act in the partner workspace with the given externalId. It needs a partner key, and externalID must not be empty. See Client.ForWorkspace.

type OutboundMessage

type OutboundMessage struct {
	ID string `json:"id"`
	// `marketing` (from `campaign` or `journey`) or `transactional` (neither).
	MessageType MessageType   `json:"messageType"`
	Channel     Channel       `json:"channel"`
	Status      MessageStatus `json:"status"`
	// The campaign it came from; null for any other message.
	Campaign *APICallerWorkspace `json:"campaign"`
	// The journey it came from, deleted or not; null for any other message.
	Journey *OutboundMessageJourney `json:"journey"`
	// The stored template and published version it was sent from; null for inline content.
	Template *OutboundMessageTemplate `json:"template"`
	// Set on a `cc` or `bcc` copy; null on the message itself.
	Copy *MessageCopy `json:"copy"`
	// Who it was for; null when the contact was deleted, or the message passed the retention
	// period: it no longer names anyone.
	Contact *OutboundMessageContact `json:"contact"`
	// The email address the message went to, frozen at the first attempt; null until then,
	// and for push.
	RecipientEmail *string `json:"recipientEmail"`
	// Sent to a reserved test address (`example.com` and the like): it passed every check a
	// real send does but was never handed to the provider. Any outcome was simulated from
	// the address, as `bounce@example.com` simulates a bounce.
	Simulated bool `json:"simulated"`
	// The reference a transactional send carried; null otherwise.
	CorrelationID *string `json:"correlationId"`
	// When a timed transactional send is due; null for one sent at once.
	SendAt *time.Time `json:"sendAt"`
	// When it was handed to the provider.
	SentAt *time.Time `json:"sentAt"`
	// When the provider confirmed delivery.
	DeliveredAt *time.Time `json:"deliveredAt"`
	// First open, when tracked: a person's first open or click, or a machine's open while
	// only a machine has opened it.
	OpenedAt *time.Time `json:"openedAt"`
	// Only a machine has opened it so far: a mail app fetched its images with no reader
	// (Apple Mail Privacy Protection, Gmail's prefetch on delivery) or a mail security
	// scanner checked it. A click or a later open by a person clears it.
	OpenedByMachine bool `json:"openedByMachine"`
	// A person's first click, when tracked.
	ClickedAt *time.Time `json:"clickedAt"`
	// A machine followed one of its links: a mail security scanner checking it on delivery,
	// a link preview. Such a click sets no `clickedAt` and sends no webhook.
	ClickedByMachine bool `json:"clickedByMachine"`
	// When the recipient marked it as spam (the first complaint); null for a simulated one.
	ComplainedAt *time.Time `json:"complainedAt"`
	// The hard bounce: set when `status` is `bounced`; null otherwise. A soft bounce is a
	// `failure` with reason `transient_bounce`.
	Bounce *OutboundMessageBounce `json:"bounce"`
	// Set when `status` is `failed`; null otherwise.
	Failure *OutboundMessageFailure `json:"failure"`
	// Set when `status` is `skipped`; null otherwise.
	Skip      *OutboundMessageSkip `json:"skip"`
	CreatedAt time.Time            `json:"createdAt"`
}

OutboundMessage is defined by the Kirora API.

type OutboundMessageBounce

type OutboundMessageBounce struct {
	// When it happened.
	OccurredAt time.Time `json:"occurredAt"`
	// Why: `mailbox_not_found`, `mailbox_full`, `suppressed` (the provider refuses the
	// address), or `general` for any other reason.
	Type OutboundMessageBounceType `json:"type"`
	// The receiving server's reply, such as `smtp; 550 5.1.1 user unknown`; null for a
	// simulated bounce.
	Detail *string `json:"detail"`
}

OutboundMessageBounce: The hard bounce: set when `status` is `bounced`; null otherwise. A soft bounce is a `failure` with reason `transient_bounce`.

type OutboundMessageBounceType

type OutboundMessageBounceType string

OutboundMessageBounceType: Why: `mailbox_not_found`, `mailbox_full`, `suppressed` (the provider refuses the address), or `general` for any other reason.

const (
	OutboundMessageBounceTypeMailboxNotFound OutboundMessageBounceType = "mailbox_not_found"
	OutboundMessageBounceTypeMailboxFull     OutboundMessageBounceType = "mailbox_full"
	OutboundMessageBounceTypeSuppressed      OutboundMessageBounceType = "suppressed"
	OutboundMessageBounceTypeGeneral         OutboundMessageBounceType = "general"
)

func (OutboundMessageBounceType) IsKnown

func (v OutboundMessageBounceType) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type OutboundMessageContact

type OutboundMessageContact struct {
	ID         string  `json:"id"`
	ExternalID *string `json:"externalId"`
	// The contact's email now, which may differ from `recipientEmail`.
	Email *string `json:"email"`
	// The contact's first name now.
	FirstName *string `json:"firstName"`
	// The contact's last name now.
	LastName *string `json:"lastName"`
}

OutboundMessageContact: Who it was for; null when the contact was deleted, or the message passed the retention period: it no longer names anyone.

type OutboundMessageFailure

type OutboundMessageFailure struct {
	// When it happened.
	OccurredAt time.Time `json:"occurredAt"`
	// Why sending broke, such as `provider_rejected` (the provider refused the content) or
	// `transient_bounce`. `not_sent`: a problem on Kirora's side stopped it; nothing in your
	// content, audience or setup caused it, and Kirora is alerted. In rare cases the
	// provider may have delivered it before the problem.
	Reason string `json:"reason"`
}

OutboundMessageFailure: Set when `status` is `failed`; null otherwise.

type OutboundMessageJourney

type OutboundMessageJourney struct {
	// Null once the journey is deleted.
	ID *string `json:"id"`
	// The journey's current name; null once it is deleted.
	Name *string `json:"name"`
	// The journey was deleted after sending this. Its messages and their counts stay;
	// nothing names the journey any more.
	Deleted bool `json:"deleted"`
	// The enrollment that sent it.
	EnrollmentID string `json:"enrollmentId"`
	// The id of the step that sent it.
	StepID string `json:"stepId"`
}

OutboundMessageJourney: The journey it came from, deleted or not; null for any other message.

type OutboundMessageSkip

type OutboundMessageSkip struct {
	// When it happened.
	OccurredAt time.Time `json:"occurredAt"`
	// Which guard stopped it before sending, such as `suppressed`, `consent_missing` or
	// `cancelled`; `fallback_not_needed`: a transactional `fallbackOrder` fallback whose
	// first channel arrived; `plan_limit_reached`: a fallback the plan had no room for when
	// it was due; `sending_review_required`: email from a sending domain Kirora has not
	// approved yet.
	Reason string `json:"reason"`
	// With `suppressed`: why the address is blocked: `unsubscribed`, `bounced`,
	// `complained`, `complained_transactional`, `manual` or `imported`. Null otherwise.
	SuppressionReason *SuppressionReason `json:"suppressionReason"`
}

OutboundMessageSkip: Set when `status` is `skipped`; null otherwise.

type OutboundMessageTemplate

type OutboundMessageTemplate struct {
	ID      string `json:"id"`
	Version int    `json:"version"`
}

OutboundMessageTemplate: The stored template and published version it was sent from; null for inline content.

type Page

type Page[T, M any] struct {
	Data []T `json:"data"`
	Meta M   `json:"meta"`
}

Page is one page of a list. Pass Meta.Pagination.NextCursor back as the Cursor param, with the same filters, for the next page; it's nil on the last one.

func RequestPage

func RequestPage[T, M any](ctx context.Context, c *Client, path string, query url.Values, opts ...CallOption) (*Page[T, M], error)

RequestPage fetches one page of an endpoint that has no method in this SDK, as Request does.

type Pagination

type Pagination struct {
	Limit      int     `json:"limit"`
	NextCursor *string `json:"nextCursor"`
}

Pagination is defined by the Kirora API.

type ProductBlock

type ProductBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The name and price in bold (the default) or regular weight.
	Weight *EmailBlockStyleFontWeight `json:"weight,omitempty"`
	Text   *string                    `json:"text,omitempty"`
	Text2  *string                    `json:"text2,omitempty"`
	Desc   *string                    `json:"desc,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	Src  *string `json:"src,omitempty"`
	Alt  *string `json:"alt,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ProductBlock is defined by the Kirora API.

func (ProductBlock) MarshalJSON

func (v ProductBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "product", which identifies a ProductBlock, and the properties in Extra.

func (*ProductBlock) UnmarshalJSON

func (v *ProductBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ProductBlockInput

type ProductBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The name and price in bold (the default) or regular weight.
	Weight *EmailBlockStyleFontWeight `json:"weight,omitempty"`
	Text   *string                    `json:"text,omitempty"`
	Text2  *string                    `json:"text2,omitempty"`
	Desc   *string                    `json:"desc,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	Src  *string `json:"src,omitempty"`
	Alt  *string `json:"alt,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

ProductBlockInput is defined by the Kirora API.

func (ProductBlockInput) MarshalJSON

func (v ProductBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "product", which identifies a ProductBlockInput, and the properties in Extra.

func (*ProductBlockInput) UnmarshalJSON

func (v *ProductBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type PushBlocker

type PushBlocker struct {
	// What blocks it, for code to branch on.
	Code PushBlockerCode `json:"code"`
	// What to do about it, for the person or agent fixing it.
	Message string `json:"message"`
	// With `draft_incomplete`: the field still missing, such as `subject`.
	Field *string `json:"field,omitempty"`
}

PushBlocker is defined by the Kirora API.

type PushBlockerCode

type PushBlockerCode string

PushBlockerCode: What blocks it, for code to branch on.

const (
	PushBlockerCodeDraftIncomplete      PushBlockerCode = "draft_incomplete"
	PushBlockerCodePushAppNotReady      PushBlockerCode = "push_app_not_ready"
	PushBlockerCodeNoEligibleRecipients PushBlockerCode = "no_eligible_recipients"
)

func (PushBlockerCode) IsKnown

func (v PushBlockerCode) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type PushEligibility

type PushEligibility struct {
	// Contacts reachable on this channel after the exclusions: the number a send is sized
	// by.
	EligibleRecipientCount int `json:"eligibleRecipientCount"`
	// What stops the push channel sending.
	Blockers []PushBlocker `json:"blockers"`
	// Contacts left out of the audience, by reason.
	Excluded PushEligibilityExcluded `json:"excluded"`
	// Whether the push app is set up to send.
	ApplicationReady bool `json:"applicationReady"`
}

PushEligibility is defined by the Kirora API.

func (PushEligibility) MarshalJSON

func (v PushEligibility) MarshalJSON() ([]byte, error)

MarshalJSON adds "channel": "push", which identifies a PushEligibility.

type PushEligibilityExcluded

type PushEligibilityExcluded struct {
	// Contacts without push consent.
	ConsentMissing int `json:"consentMissing"`
	// Consented, but the campaign's topic does not reach them.
	TopicUnsubscribed int `json:"topicUnsubscribed"`
	// Contacts with no registered device.
	MissingInstallation int `json:"missingInstallation"`
}

PushEligibilityExcluded: Contacts left out of the audience, by reason.

type PushInstallation

type PushInstallation struct {
	ID        string `json:"id"`
	ContactID string `json:"contactId"`
	PushAppID string `json:"pushAppId"`
	// Your own id for the device, as registered.
	ExternalInstallationID string                        `json:"externalInstallationId"`
	Platform               InstallationConditionPlatform `json:"platform"`
	Environment            PushInstallationEnvironment   `json:"environment"`
	Permission             PushPermission                `json:"permission"`
	// False once the device is disabled or its token is refused.
	Active bool `json:"active"`
	// When the provider refused the token. A deleted installation keeps it as it was;
	// `active` says it no longer receives.
	InvalidatedAt *time.Time `json:"invalidatedAt"`
	// When the device last registered or refreshed.
	LastSeenAt time.Time `json:"lastSeenAt"`
	// The Kirora SDK and version that last registered it; null from a server.
	SDK       *string   `json:"sdk"`
	CreatedAt time.Time `json:"createdAt"`
}

PushInstallation is defined by the Kirora API.

type PushInstallationEnvironment

type PushInstallationEnvironment string

PushInstallationEnvironment: Values other than these constants may be added to the API at any time.

const (
	PushInstallationEnvironmentSandbox    PushInstallationEnvironment = "sandbox"
	PushInstallationEnvironmentProduction PushInstallationEnvironment = "production"
)

func (PushInstallationEnvironment) IsKnown

func (v PushInstallationEnvironment) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type PushInstallationsPage

type PushInstallationsPage = Page[PushInstallation, CursorPaginationMeta]

PushInstallationsPage is a page of a contact's push devices and browsers.

type PushPermission

type PushPermission string

PushPermission: Notification permission on the device.

const (
	PushPermissionGranted PushPermission = "granted"
	PushPermissionDenied  PushPermission = "denied"
)

func (PushPermission) IsKnown

func (v PushPermission) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type PushTargetKind

type PushTargetKind string

PushTargetKind: Values other than these constants may be added to the API at any time.

const (
	PushTargetKindAPNSToken           PushTargetKind = "apns_token"
	PushTargetKindFCMToken            PushTargetKind = "fcm_token"
	PushTargetKindWebPushSubscription PushTargetKind = "web_push_subscription"
)

func (PushTargetKind) IsKnown

func (v PushTargetKind) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type PushUrgency

type PushUrgency string

PushUrgency: `high` asks the push service to deliver promptly, even to a sleeping device; `normal` lets it wait for a good moment to save battery. Device settings and the app still decide whether and how it is shown. Unset, a transactional push is `high` and any other `normal`.

const (
	PushUrgencyHigh   PushUrgency = "high"
	PushUrgencyNormal PushUrgency = "normal"
)

func (PushUrgency) IsKnown

func (v PushUrgency) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type QuoteBlock

type QuoteBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	Text2  *string `json:"text2,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

QuoteBlock is defined by the Kirora API.

func (QuoteBlock) MarshalJSON

func (v QuoteBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "quote", which identifies a QuoteBlock, and the properties in Extra.

func (*QuoteBlock) UnmarshalJSON

func (v *QuoteBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type QuoteBlockInput

type QuoteBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	Text2  *string `json:"text2,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

QuoteBlockInput is defined by the Kirora API.

func (QuoteBlockInput) MarshalJSON

func (v QuoteBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "quote", which identifies a QuoteBlockInput, and the properties in Extra.

func (*QuoteBlockInput) UnmarshalJSON

func (v *QuoteBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type RateLimit

type RateLimit struct {
	// Limit is how many requests the window allows.
	Limit int

	// Remaining is how many requests are left in the current window.
	Remaining int

	// Reset is how long until the window resets.
	Reset time.Duration
}

RateLimit is the rate limit the API reported with a response.

type RegisterPushInstallationInput

type RegisterPushInstallationInput struct {
	// The push app the device registers with.
	PushAppID string `json:"pushAppId"`
	// Your own stable id for the device; registering it again updates it.
	ExternalInstallationID string `json:"externalInstallationId"`
	// Whether the user allowed notifications; only `granted` devices receive.
	Permission PushPermission  `json:"permission"`
	TargetKind *PushTargetKind `json:"targetKind,omitempty"`
	// The device token from APNs or FCM.
	Target *string `json:"target,omitempty"`
	// The browser's `PushSubscription`, as JSON.
	Subscription *WebPushSubscription `json:"subscription,omitempty"`
	// When the device last reported this state.
	LastSeenAt *time.Time `json:"lastSeenAt,omitempty"`
}

RegisterPushInstallationInput is defined by the Kirora API.

type RepeatBlock

type RepeatBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The list to repeat over: `event.properties.<name>` (a journey's event, or a
	// transactional send's `data`) or `contact.attributes.<name>`.
	List  string `json:"list"`
	Limit *int   `json:"limit,omitempty"`
	// The blocks written out once per item of `list`, where `{{ item.<field> }}` reads that
	// item. Repeats do not nest.
	Blocks []EmailBlock `json:"blocks"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

RepeatBlock is defined by the Kirora API.

func (RepeatBlock) MarshalJSON

func (v RepeatBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "repeat", which identifies a RepeatBlock, and the properties in Extra.

func (*RepeatBlock) UnmarshalJSON

func (v *RepeatBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type RepeatBlockInput

type RepeatBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The list to repeat over: `event.properties.<name>` (a journey's event, or a
	// transactional send's `data`) or `contact.attributes.<name>`.
	List  string `json:"list"`
	Limit *int   `json:"limit,omitempty"`
	// The blocks written out once per item of `list`, where `{{ item.<field> }}` reads that
	// item. Repeats do not nest.
	Blocks []EmailBlockInput `json:"blocks"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

RepeatBlockInput is defined by the Kirora API.

func (RepeatBlockInput) MarshalJSON

func (v RepeatBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "repeat", which identifies a RepeatBlockInput, and the properties in Extra.

func (*RepeatBlockInput) UnmarshalJSON

func (v *RepeatBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type Response

type Response struct {
	StatusCode int
	Header     http.Header

	// RequestID identifies the request to Kirora support.
	RequestID string

	// IdempotencyReplay is true when the API returned the stored response of an earlier
	// request with the same idempotency key instead of running the operation again.
	IdempotencyReplay bool

	// RateLimit is nil when the response has no valid rate limit headers.
	RateLimit *RateLimit
}

Response holds details of an HTTP response from the API. See WithResponseInto.

Example
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	var resp kirora.Response
	_, err := client.Contacts.Get(ctx, kirora.ContactExternalID("user-1"), kirora.WithResponseInto(&resp))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(resp.RequestID)

	// Once less than a tenth of the limit is left, wait for it to reset rather than run
	// into 429s.
	if rl := resp.RateLimit; rl != nil && rl.Remaining < rl.Limit/10 {
		time.Sleep(rl.Reset)
	}
}

type ResponseError

type ResponseError struct {
	// Op is the request's method and path.
	Op         string
	StatusCode int
	RequestID  string
	// Message describes what was wrong with the response.
	Message string
	// Err is the decoding error, when there is one.
	Err error
}

ResponseError is returned when the API answered but the SDK couldn't use the response, such as a body that isn't the JSON expected or is too large to read.

func (*ResponseError) Error

func (e *ResponseError) Error() string

func (*ResponseError) Unwrap

func (e *ResponseError) Unwrap() error

type ScheduleCampaignInput

type ScheduleCampaignInput struct {
	Type CampaignScheduleType `json:"type"`
	// The instant everyone receives it at.
	SendAt *time.Time `json:"sendAt,omitempty"`
	// The wall-clock time (`YYYY-MM-DDTHH:MM`, no timezone) each contact receives it at on
	// their own clock. It may already have passed in some timezones, not in all.
	LocalDateTime *string `json:"localDateTime,omitempty"`
	// The IANA timezone for contacts without one; omit it for the workspace's.
	TimezoneIfUnknown *string `json:"timezoneIfUnknown,omitempty"`
	// Where the time has already gone when it is scheduled: `send_now` sends there at once,
	// `next_day` at the same time the next day, and `skip` leaves those contacts out
	// (skipped with `local_time_passed`).
	IfTimeHasPassed *IfTimeHasPassed `json:"ifTimeHasPassed,omitempty"`
}

ScheduleCampaignInput is defined by the Kirora API.

type SectionBlock

type SectionBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// A photo behind the section's blocks, covering the box. Needs `style.backgroundColor`,
	// which Outlook for Windows and clients with images off show instead, and which text is
	// made readable on.
	BackgroundImage *string `json:"backgroundImage,omitempty"`
	// The section's child blocks, drawn inside its box.
	Blocks []EmailBlock `json:"blocks"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SectionBlock is defined by the Kirora API.

func (SectionBlock) MarshalJSON

func (v SectionBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "section", which identifies a SectionBlock, and the properties in Extra.

func (*SectionBlock) UnmarshalJSON

func (v *SectionBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SectionBlockInput

type SectionBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// A photo behind the section's blocks, covering the box. Needs `style.backgroundColor`,
	// which Outlook for Windows and clients with images off show instead, and which text is
	// made readable on.
	BackgroundImage *string `json:"backgroundImage,omitempty"`
	// The section's child blocks, drawn inside its box.
	Blocks []EmailBlockInput `json:"blocks"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SectionBlockInput is defined by the Kirora API.

func (SectionBlockInput) MarshalJSON

func (v SectionBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "section", which identifies a SectionBlockInput, and the properties in Extra.

func (*SectionBlockInput) UnmarshalJSON

func (v *SectionBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SegmentCondition

type SegmentCondition struct {
	SegmentID string `json:"segmentId"`
	// True for in the segment, false for not in it.
	Member bool `json:"member"`
}

SegmentCondition is defined by the Kirora API.

func (SegmentCondition) MarshalJSON

func (v SegmentCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "segment", which identifies a SegmentCondition.

type SegmentConditionInput

type SegmentConditionInput = SegmentCondition

SegmentConditionInput is defined by the Kirora API.

type SegmentRule

type SegmentRule struct {
	Value SegmentRuleValue
}

SegmentRule is one of the following, told apart by "type": AttributeCondition ("attribute"), ContactFieldCondition ("contact"), EventCondition ("event"), ActivityCondition ("activity"), InstallationCondition ("installation"), ListCondition ("list"), SegmentCondition ("segment"), TopicCondition ("topic"), or SegmentRuleGroup (without "type").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (SegmentRule) MarshalJSON

func (u SegmentRule) MarshalJSON() ([]byte, error)

func (*SegmentRule) UnmarshalJSON

func (u *SegmentRule) UnmarshalJSON(data []byte) error

type SegmentRuleCondition

type SegmentRuleCondition struct {
	Value SegmentRuleConditionValue
}

SegmentRuleCondition is one of the following, told apart by "type": AttributeCondition ("attribute"), ContactFieldCondition ("contact"), EventCondition ("event"), ActivityCondition ("activity"), InstallationCondition ("installation"), ListCondition ("list"), SegmentCondition ("segment"), TopicCondition ("topic").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (SegmentRuleCondition) MarshalJSON

func (u SegmentRuleCondition) MarshalJSON() ([]byte, error)

func (*SegmentRuleCondition) UnmarshalJSON

func (u *SegmentRuleCondition) UnmarshalJSON(data []byte) error

type SegmentRuleConditionInput

type SegmentRuleConditionInput struct {
	Value SegmentRuleConditionInputValue
}

SegmentRuleConditionInput is one of the following, told apart by "type": AttributeConditionInput ("attribute"), ContactFieldConditionInput ("contact"), EventConditionInput ("event"), ActivityConditionInput ("activity"), InstallationConditionInput ("installation"), ListConditionInput ("list"), SegmentConditionInput ("segment"), TopicConditionInput ("topic").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (SegmentRuleConditionInput) MarshalJSON

func (u SegmentRuleConditionInput) MarshalJSON() ([]byte, error)

func (*SegmentRuleConditionInput) UnmarshalJSON

func (u *SegmentRuleConditionInput) UnmarshalJSON(data []byte) error

type SegmentRuleConditionInputValue

type SegmentRuleConditionInputValue interface {
	// contains filtered or unexported methods
}

SegmentRuleConditionInputValue is implemented by each kind of SegmentRuleConditionInput, and by Unknown.

type SegmentRuleConditionValue

type SegmentRuleConditionValue interface {
	// contains filtered or unexported methods
}

SegmentRuleConditionValue is implemented by each kind of SegmentRuleCondition, and by Unknown.

type SegmentRuleGroup

type SegmentRuleGroup struct {
	// Every rule must match.
	All []SegmentRuleCondition `json:"all,omitzero"`
	// At least one rule must match.
	Any []SegmentRuleCondition `json:"any,omitzero"`
}

SegmentRuleGroup is defined by the Kirora API.

type SegmentRuleGroupInput

type SegmentRuleGroupInput struct {
	// Every rule must match.
	All []SegmentRuleConditionInput `json:"all,omitzero"`
	// At least one rule must match.
	Any []SegmentRuleConditionInput `json:"any,omitzero"`
}

SegmentRuleGroupInput is defined by the Kirora API.

type SegmentRuleInput

type SegmentRuleInput struct {
	Value SegmentRuleInputValue
}

SegmentRuleInput is one of the following, told apart by "type": AttributeConditionInput ("attribute"), ContactFieldConditionInput ("contact"), EventConditionInput ("event"), ActivityConditionInput ("activity"), InstallationConditionInput ("installation"), ListConditionInput ("list"), SegmentConditionInput ("segment"), TopicConditionInput ("topic"), or SegmentRuleGroupInput (without "type").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

func (SegmentRuleInput) MarshalJSON

func (u SegmentRuleInput) MarshalJSON() ([]byte, error)

func (*SegmentRuleInput) UnmarshalJSON

func (u *SegmentRuleInput) UnmarshalJSON(data []byte) error

type SegmentRuleInputValue

type SegmentRuleInputValue interface {
	// contains filtered or unexported methods
}

SegmentRuleInputValue is implemented by each kind of SegmentRuleInput, and by Unknown.

type SegmentRuleValue

type SegmentRuleValue interface {
	// contains filtered or unexported methods
}

SegmentRuleValue is implemented by each kind of SegmentRule, and by Unknown.

type SegmentRules

type SegmentRules struct {
	// Every rule or nested group must match.
	All []SegmentRule `json:"all,omitzero"`
	// At least one rule or nested group must match.
	Any []SegmentRule `json:"any,omitzero"`
}

SegmentRules is defined by the Kirora API.

type SegmentRulesInput

type SegmentRulesInput struct {
	// Every rule or nested group must match.
	All []SegmentRuleInput `json:"all,omitzero"`
	// At least one rule or nested group must match.
	Any []SegmentRuleInput `json:"any,omitzero"`
}

SegmentRulesInput is defined by the Kirora API.

type SendTransactionalBatchEntry

type SendTransactionalBatchEntry struct {
	// As the `Idempotency-Key` header of a single send: one per message you mean. Without
	// one, a retried batch sends this message again.
	IdempotencyKey *string                `json:"idempotencyKey,omitempty"`
	Message        SendTransactionalInput `json:"message"`
}

SendTransactionalBatchEntry is defined by the Kirora API.

type SendTransactionalBatchResultEntry

type SendTransactionalBatchResultEntry struct {
	// As sent; null when none was.
	IdempotencyKey *string `json:"idempotencyKey"`
	// True when this key had already been accepted; nothing new was sent.
	Replayed *bool                  `json:"replayed,omitempty"`
	Messages []TransactionalMessage `json:"messages,omitzero"`
	// Channels given that were not sent, each with the reason: the contact cannot receive
	// it, or the plan has no room for it.
	SkippedChannels []TransactionalSkippedChannel `json:"skippedChannels,omitzero"`
	// `cc` or `bcc` addresses that got no copy, each with the reason.
	SkippedCopies []TransactionalSkippedCopy `json:"skippedCopies,omitzero"`
	Error         *BatchError                `json:"error,omitempty"`
}

SendTransactionalBatchResultEntry is defined by the Kirora API.

type SendTransactionalInput

type SendTransactionalInput struct {
	// Who receives it.
	To TransactionalRecipientInput `json:"to"`
	// Values the content reads as `{{ data.<key> }}`: a stored template, inline email and
	// the push `title` and `body` alike.
	Data map[string]any `json:"data,omitzero"`
	// Set when the message carries a secret (a reset link, a one-time code): its content is
	// kept only while the message is queued or sending, and removed once sending finishes,
	// whatever the workspace's retention says.
	Sensitive *bool `json:"sensitive,omitempty"`
	// Your own reference for this send, echoed on its webhooks and its read.
	CorrelationID *string `json:"correlationId,omitempty"`
	// Inline (`subject`, `from`, `html`), or a stored template by `template`; either may
	// carry `attachments`, `threading`, `tracking`, `cc` and `bcc`.
	Email *SendTransactionalInputEmail `json:"email,omitempty"`
	// A push notification to the contact's devices. Give `push`, `email`, or both.
	Push *TransactionalPushInput `json:"push,omitempty"`
	// When to send, up to 90 days ahead, with its UTC offset. Suppression and push
	// reachability are checked when the request is accepted and again when it goes. A
	// `fallbackOrder` fallback keeps this time but goes only after the message before it
	// fails, is skipped or bounces.
	SendAt *time.Time `json:"sendAt,omitempty"`
	// With both `push` and `email`, each once, in the order to try them: the first the
	// contact can receive is sent, and the next only if it fails, is skipped or bounces.
	// Left out, each channel the contact can receive is sent.
	FallbackOrder []Channel `json:"fallbackOrder,omitzero"`
}

SendTransactionalInput is defined by the Kirora API.

type SendTransactionalInputEmail

type SendTransactionalInputEmail struct {
	// The template's alias, such as `password-reset`, or its id.
	Template *string `json:"template,omitempty"`
	// The subject line. Merge tags are allowed.
	Subject *string `json:"subject,omitempty"`
	// Shown by inboxes after the subject. Merge tags are allowed; keep it near 100
	// characters.
	PreviewText *string `json:"previewText,omitempty"`
	// The sender address, on a verified sending domain.
	From *string `json:"from,omitempty"`
	// Where replies go; the part before the @ must be ASCII.
	ReplyTo *string `json:"replyTo,omitempty"`
	// Files it carries: up to 10, 10 MB in all.
	Attachments []EmailAttachmentInput `json:"attachments,omitzero"`
	// Places it in an existing conversation, as the `In-Reply-To` and `References` headers.
	Threading *EmailThreadingInput `json:"threading,omitempty"`
	// Open and click tracking; off unless asked for. Contacts whose `country` is in the EEA
	// or the UK are never tracked.
	Tracking *TransactionalEmailTrackingInput `json:"tracking,omitempty"`
	// Addresses that get a copy and are shown in its `Cc` line. Each goes as its own
	// message, with its own bounces and complaints, and counts as one email. Up to 14 across
	// `cc` and `bcc`.
	CC []string `json:"cc,omitzero"`
	// Addresses that get a copy without being shown to anyone. Sent and counted as `cc` is.
	BCC []string `json:"bcc,omitzero"`
	// The HTML body. Rendered from the design when one is set.
	HTML *string `json:"html,omitempty"`
	// The plain-text alternative.
	Text *string `json:"text,omitempty"`
	// Set to `false` for HTML that is already finished: `{{` then goes out exactly as
	// written, and nothing is checked or filled in. `{{unsubscribe_url}}` and
	// `{{web_version_url}}` still work. Defaults to `true`.
	MergeTags *bool `json:"mergeTags,omitempty"`
}

SendTransactionalInputEmail: Inline (`subject`, `from`, `html`), or a stored template by `template`; either may carry `attachments`, `threading`, `tracking`, `cc` and `bcc`.

type SendTransactionalMessagesBatchInput

type SendTransactionalMessagesBatchInput struct {
	Messages []SendTransactionalBatchEntry `json:"messages"`
}

SendTransactionalMessagesBatchInput is defined by the Kirora API.

type SendTransactionalMessagesBatchResult

type SendTransactionalMessagesBatchResult struct {
	Results []SendTransactionalBatchResultEntry `json:"results"`
}

SendTransactionalMessagesBatchResult is defined by the Kirora API.

type SetContactConsentInput

type SetContactConsentInput struct {
	// Consent to email. Omitted, the current value is kept.
	Email *bool `json:"email,omitempty"`
	// Consent to push. Omitted, the current value is kept.
	Push *bool `json:"push,omitempty"`
	// How the contact agreed, recorded as the proof of any consent this request grants.
	// Required when it grants consent on a channel or (on identify) a topic, else 400
	// `VALIDATION_ERROR` at `consent.statement`; withdrawing needs none.
	Statement *ConsentStatementInput `json:"statement,omitempty"`
}

SetContactConsentInput is defined by the Kirora API.

type SetContactTopicInput

type SetContactTopicInput struct {
	// Join (true) or leave (false) the topic on every channel; it clears each channel's own
	// choice.
	Subscribed *bool `json:"subscribed,omitempty"`
	// One channel's choice each, applied after `subscribed`; a channel left out keeps its
	// choice.
	Channels map[string]bool `json:"channels,omitzero"`
	// How the contact agreed; required to join on any channel.
	Statement *ConsentStatementInput `json:"statement,omitempty"`
}

SetContactTopicInput is defined by the Kirora API.

type SharedBlockReference

type SharedBlockReference struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The workspace's shared block placed here, by reference.
	SharedBlockID string `json:"sharedBlockId"`
	// Edited here only: these blocks render instead of the shared content. Omit to follow
	// the shared block.
	Override []EmailBlock `json:"override,omitzero"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SharedBlockReference is defined by the Kirora API.

func (SharedBlockReference) MarshalJSON

func (v SharedBlockReference) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "shared", which identifies a SharedBlockReference, and the properties in Extra.

func (*SharedBlockReference) UnmarshalJSON

func (v *SharedBlockReference) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SharedBlockReferenceInput

type SharedBlockReferenceInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The workspace's shared block placed here, by reference.
	SharedBlockID string `json:"sharedBlockId"`
	// Edited here only: these blocks render instead of the shared content. Omit to follow
	// the shared block.
	Override []EmailBlockInput `json:"override,omitzero"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SharedBlockReferenceInput is defined by the Kirora API.

func (SharedBlockReferenceInput) MarshalJSON

func (v SharedBlockReferenceInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "shared", which identifies a SharedBlockReferenceInput, and the properties in Extra.

func (*SharedBlockReferenceInput) UnmarshalJSON

func (v *SharedBlockReferenceInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type ShowOn

type ShowOn string

ShowOn: Show the block only on phones (screens up to 620px) or only on wider screens. Clients that ignore screen size show the desktop version, and so does plain text. Omit to show it everywhere.

const (
	ShowOnMobile  ShowOn = "mobile"
	ShowOnDesktop ShowOn = "desktop"
)

func (ShowOn) IsKnown

func (v ShowOn) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type SocialBlock

type SocialBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// The profiles to show; without any, the brand kit's social links.
	Links []SocialBlockLink `json:"links,omitzero"`
	// Each link as its network's icon (the default), the icon and its label, or the label
	// alone. The network is read from the link's address; any other address shows a globe.
	Display *SocialBlockDisplay `json:"display,omitempty"`
	// Icons in each network's colour (the default), near-black, or white for a dark
	// background.
	IconStyle *SocialBlockIconStyle `json:"iconStyle,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SocialBlock is defined by the Kirora API.

func (SocialBlock) MarshalJSON

func (v SocialBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "social", which identifies a SocialBlock, and the properties in Extra.

func (*SocialBlock) UnmarshalJSON

func (v *SocialBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SocialBlockDisplay

type SocialBlockDisplay string

SocialBlockDisplay: Each link as its network's icon (the default), the icon and its label, or the label alone. The network is read from the link's address; any other address shows a globe.

const (
	SocialBlockDisplayIcons SocialBlockDisplay = "icons"
	SocialBlockDisplayBoth  SocialBlockDisplay = "both"
	SocialBlockDisplayText  SocialBlockDisplay = "text"
)

func (SocialBlockDisplay) IsKnown

func (v SocialBlockDisplay) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type SocialBlockIconStyle

type SocialBlockIconStyle string

SocialBlockIconStyle: Icons in each network's colour (the default), near-black, or white for a dark background.

const (
	SocialBlockIconStyleColor SocialBlockIconStyle = "color"
	SocialBlockIconStyleDark  SocialBlockIconStyle = "dark"
	SocialBlockIconStyleLight SocialBlockIconStyle = "light"
)

func (SocialBlockIconStyle) IsKnown

func (v SocialBlockIconStyle) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type SocialBlockInput

type SocialBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// The profiles to show; without any, the brand kit's social links.
	Links []SocialBlockInputLink `json:"links,omitzero"`
	// Each link as its network's icon (the default), the icon and its label, or the label
	// alone. The network is read from the link's address; any other address shows a globe.
	Display *SocialBlockDisplay `json:"display,omitempty"`
	// Icons in each network's colour (the default), near-black, or white for a dark
	// background.
	IconStyle *SocialBlockIconStyle `json:"iconStyle,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SocialBlockInput is defined by the Kirora API.

func (SocialBlockInput) MarshalJSON

func (v SocialBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "social", which identifies a SocialBlockInput, and the properties in Extra.

func (*SocialBlockInput) UnmarshalJSON

func (v *SocialBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SocialBlockInputLink = SocialBlockLink

SocialBlockInputLink is defined by the Kirora API.

type SocialBlockLink struct {
	Label string `json:"label"`
	Href  string `json:"href"`
}

SocialBlockLink is defined by the Kirora API.

type SpacerBlock

type SpacerBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The height, from "4px" to "200px".
	Size *string `json:"size,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SpacerBlock is defined by the Kirora API.

func (SpacerBlock) MarshalJSON

func (v SpacerBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "spacer", which identifies a SpacerBlock, and the properties in Extra.

func (*SpacerBlock) UnmarshalJSON

func (v *SpacerBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type SpacerBlockInput

type SpacerBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	// The height, from "4px" to "200px".
	Size *string `json:"size,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

SpacerBlockInput is defined by the Kirora API.

func (SpacerBlockInput) MarshalJSON

func (v SpacerBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "spacer", which identifies a SpacerBlockInput, and the properties in Extra.

func (*SpacerBlockInput) UnmarshalJSON

func (v *SpacerBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type Suppression

type Suppression struct {
	ID      string            `json:"id"`
	Channel string            `json:"channel"`
	Address string            `json:"address"`
	Reason  SuppressionReason `json:"reason"`
	// True for `manual` and `imported`; bounces, complaints and unsubscribes cannot be
	// removed.
	Removable bool      `json:"removable"`
	CreatedAt time.Time `json:"createdAt"`
}

Suppression is defined by the Kirora API.

type SuppressionReason

type SuppressionReason string

SuppressionReason: Why the address is blocked: `manual` (blocked by a person), `imported` (added through `addSuppressions`), `unsubscribed`, `bounced`, `complained` (marked as spam on marketing mail) or `complained_transactional` (marked as spam on a transactional message).

const (
	SuppressionReasonManual                  SuppressionReason = "manual"
	SuppressionReasonImported                SuppressionReason = "imported"
	SuppressionReasonUnsubscribed            SuppressionReason = "unsubscribed"
	SuppressionReasonBounced                 SuppressionReason = "bounced"
	SuppressionReasonComplained              SuppressionReason = "complained"
	SuppressionReasonComplainedTransactional SuppressionReason = "complained_transactional"
)

func (SuppressionReason) IsKnown

func (v SuppressionReason) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type SuppressionReasonInput

type SuppressionReasonInput = SuppressionReason

SuppressionReasonInput: Why the address is blocked: `manual` (blocked by a person), `imported` (added through `addSuppressions`), `unsubscribed`, `bounced`, `complained` (marked as spam on marketing mail) or `complained_transactional` (marked as spam on a transactional message).

type SuppressionsPage

type SuppressionsPage = Page[Suppression, CursorPaginationMeta]

SuppressionsPage is a page of suppressed addresses.

type SuppressionsService

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

SuppressionsService manages the email addresses Kirora never sends to, such as after a bounce or complaint.

func (*SuppressionsService) Add

Add suppresses addresses (addSuppressions). Addresses already suppressed are skipped. A key is made for the call, so a retry replays the first result.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	added, err := client.Suppressions.Add(ctx, &kirora.AddSuppressionsInput{
		Emails: []string{"left-the-company@example.com", "not-an-email"},
	})
	if err != nil {
		log.Fatal(err)
	}
	// An entry that isn't an email address comes back in Invalid instead of failing the
	// call.
	fmt.Println(added.AddedCount, added.AlreadySuppressedCount, added.Invalid)

	_, err = client.Suppressions.Delete(ctx, &kirora.DeleteSuppressionsInput{Emails: []string{"left-the-company@example.com"}})
	if err != nil {
		log.Fatal(err)
	}
}

func (*SuppressionsService) All

All iterates over every suppression, fetching pages as it goes (listSuppressions).

func (*SuppressionsService) Delete

Delete removes suppressions, so the addresses can be sent to again (deleteSuppressions). Addresses not suppressed are skipped. A key is made for the call, so a retry replays the first result rather than reporting them not found.

func (*SuppressionsService) List

List fetches a page of suppressions (listSuppressions). See All for every one.

type TemplateSnapshotInput

type TemplateSnapshotInput struct {
	Value TemplateSnapshotInputValue
}

TemplateSnapshotInput is one of the following, told apart by "kind": DesignSnapshotInput ("design"), HTMLSnapshotInput ("html").

Set Value to one of those, or switch on its type. A kind added to the API after this version of the SDK comes through as Unknown.

The email: a design, or HTML. Copied from a template, or written here; later template edits do not change it.

func (TemplateSnapshotInput) MarshalJSON

func (u TemplateSnapshotInput) MarshalJSON() ([]byte, error)

func (*TemplateSnapshotInput) UnmarshalJSON

func (u *TemplateSnapshotInput) UnmarshalJSON(data []byte) error

type TemplateSnapshotInputValue

type TemplateSnapshotInputValue interface {
	// contains filtered or unexported methods
}

TemplateSnapshotInputValue is implemented by each kind of TemplateSnapshotInput, and by Unknown.

type TextBlock

type TextBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

TextBlock is defined by the Kirora API.

func (TextBlock) MarshalJSON

func (v TextBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "text", which identifies a TextBlock, and the properties in Extra.

func (*TextBlock) UnmarshalJSON

func (v *TextBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type TextBlockInput

type TextBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Text   *string `json:"text,omitempty"`
	// When unset, headings, text, buttons and boxed text start from the reading side (left,
	// or right in a right-to-left language); other blocks centre.
	Align *Align `json:"align,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

TextBlockInput is defined by the Kirora API.

func (TextBlockInput) MarshalJSON

func (v TextBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "text", which identifies a TextBlockInput, and the properties in Extra.

func (*TextBlockInput) UnmarshalJSON

func (v *TextBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type TopicChoiceInput

type TopicChoiceInput struct {
	// Join (true) or leave (false) the topic on every channel; it clears each channel's own
	// choice.
	Subscribed *bool `json:"subscribed,omitempty"`
	// One channel's choice each, applied after `subscribed`; a channel left out keeps its
	// choice.
	Channels map[string]bool `json:"channels,omitzero"`
}

TopicChoiceInput is defined by the Kirora API.

type TopicCondition

type TopicCondition struct {
	// One of the workspace's topics when the rules are saved.
	TopicID string `json:"topicId"`
	// Reads the contact's choice for this channel, which overrides their topic-wide choice.
	// Without it, the rule reads the topic-wide choice, which a contact's `subscribed`
	// shows.
	Channel *Channel `json:"channel,omitempty"`
	// True for contacts the topic reaches, false for those it does not.
	Subscribed bool `json:"subscribed"`
}

TopicCondition is defined by the Kirora API.

func (TopicCondition) MarshalJSON

func (v TopicCondition) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "topic", which identifies a TopicCondition.

type TopicConditionInput

type TopicConditionInput = TopicCondition

TopicConditionInput is defined by the Kirora API.

type TrackEventInput

type TrackEventInput struct {
	// Kirora's id for the contact.
	ContactID *string `json:"contactId,omitempty"`
	// Case-sensitive, up to 128 characters once leading and trailing spaces are removed.
	// `contact.*` is reserved, and `Ordered Product` is recorded from each `Order
	// Completed`.
	Name string `json:"name"`
	// Free-form details of the event; at most 16 KB, keys up to 64 characters, `products` up
	// to 250 lines.
	Properties map[string]any `json:"properties,omitzero"`
	// When it happened; defaults to now. At most 24 hours ahead.
	OccurredAt *time.Time `json:"occurredAt,omitempty"`
	// Where and on what it happened, beside the properties.
	Context *EventContextInput `json:"context,omitempty"`
	// Your own id for the contact, as set with identify.
	ExternalID *string `json:"externalId,omitempty"`
	// The contact's email address, matched trimmed and without case.
	Email *string `json:"email,omitempty"`
}

TrackEventInput is defined by the Kirora API.

type TrackEventsBatchEntry

type TrackEventsBatchEntry struct {
	// As the `Idempotency-Key` header of a single track: one per event you mean. Optional,
	// but without one a retried entry records the event again.
	IdempotencyKey *string         `json:"idempotencyKey,omitempty"`
	Event          TrackEventInput `json:"event"`
}

TrackEventsBatchEntry is defined by the Kirora API.

type TrackEventsBatchInput

type TrackEventsBatchInput struct {
	Events []TrackEventsBatchEntry `json:"events"`
}

TrackEventsBatchInput is defined by the Kirora API.

type TrackEventsBatchResult

type TrackEventsBatchResult struct {
	Results []TrackEventsBatchResultEntry `json:"results"`
}

TrackEventsBatchResult is defined by the Kirora API.

type TrackEventsBatchResultEntry

type TrackEventsBatchResultEntry struct {
	IdempotencyKey *string `json:"idempotencyKey"`
	// True when the key was used before and the stored event is returned.
	Replayed *bool         `json:"replayed,omitempty"`
	Event    *TrackedEvent `json:"event,omitempty"`
	Error    *BatchError   `json:"error,omitempty"`
}

TrackEventsBatchResultEntry is defined by the Kirora API.

type TrackedEvent

type TrackedEvent struct {
	ID         string    `json:"id"`
	OccurredAt time.Time `json:"occurredAt"`
	// When retention deletes it: when it happened plus the days the plan kept events when it
	// was stored. Fixed: a plan change moves only later events.
	ExpiresAt time.Time `json:"expiresAt"`
}

TrackedEvent is defined by the Kirora API.

type TransactionalEmailTrackingInput

type TransactionalEmailTrackingInput struct {
	// Track opens with a pixel.
	Opens *bool `json:"opens,omitempty"`
	// Rewrite links to track clicks.
	Clicks *bool `json:"clicks,omitempty"`
}

TransactionalEmailTrackingInput is defined by the Kirora API.

type TransactionalMessage

type TransactionalMessage struct {
	ID      string        `json:"id"`
	Channel Channel       `json:"channel"`
	Status  MessageStatus `json:"status"`
	// The `correlationId` given when it was sent, if any.
	CorrelationID *string   `json:"correlationId"`
	CreatedAt     time.Time `json:"createdAt"`
	// When a timed message goes out; null when it went at once.
	SendAt *time.Time `json:"sendAt"`
	// With `fallbackOrder`: the message this one stands in for. It waits as `queued` until
	// that one ends: sent when it failed, was skipped or bounced, else skipped with reason
	// `fallback_not_needed`. Null otherwise.
	FallbackFor *string `json:"fallbackFor"`
	// Set on a `cc` or `bcc` copy; null on the message itself.
	Copy *MessageCopy `json:"copy"`
}

TransactionalMessage is defined by the Kirora API.

type TransactionalPushInput

type TransactionalPushInput struct {
	// The notification title (up to 100 characters).
	Title string `json:"title"`
	// The notification text (up to 500 characters).
	Body string `json:"body"`
	// The HTTPS page opened when the notification is tapped.
	ActionURL *string `json:"actionUrl,omitempty"`
	// A large picture: web and Android show it; iOS needs the app's service extension.
	ImageURL *string `json:"imageUrl,omitempty"`
	// Web only; iOS and Android show the app's own notification icon.
	IconURL *string `json:"iconUrl,omitempty"`
	// Up to 10 string key-value pairs passed to the app untouched, for deep links and in-app
	// routing.
	Data map[string]string `json:"data,omitzero"`
	// Up to 2 action buttons.
	Buttons []CampaignContentPushButton `json:"buttons,omitzero"`
	// A newer notification with the same key replaces the older one on the device.
	CollapseKey *string `json:"collapseKey,omitempty"`
	// The name of a sound the app ships; the device's default if unset.
	Sound *string `json:"sound,omitempty"`
	// The number shown on the iOS app icon.
	Badge *int `json:"badge,omitempty"`
	// How long a provider keeps trying an offline device, up to 28 days; zero delivers now
	// or never. Defaults to one day.
	TTL *DurationOrZeroInput `json:"ttl,omitempty"`
	// `high` asks the push service to deliver promptly, even to a sleeping device; `normal`
	// lets it wait for a good moment to save battery. Device settings and the app still
	// decide whether and how it is shown. Unset, a transactional push is `high` and any
	// other `normal`.
	Urgency *PushUrgency `json:"urgency,omitempty"`
	// Fields that differ on one platform, each replacing the shared one there (a whole
	// `data` map, not merged key by key). On iOS and Android `actionUrl` may be an app link
	// such as `myapp://orders`; the shared one and the web one must be HTTPS.
	Overrides *CreateCampaignInputContentPushOverrides `json:"overrides,omitempty"`
	// Reaches the contact's devices on every app of the project. Needed only when the
	// workspace has more than one push project.
	PushProjectID *string `json:"pushProjectId,omitempty"`
}

TransactionalPushInput is defined by the Kirora API.

type TransactionalRecipientInput

type TransactionalRecipientInput = ContactIdentifier

TransactionalRecipientInput is defined by the Kirora API.

type TransactionalSendResult

type TransactionalSendResult struct {
	Messages []TransactionalMessage `json:"messages"`
	// Channels given that were not sent, each with the reason: the contact cannot receive
	// it, or the plan has no room for it.
	SkippedChannels []TransactionalSkippedChannel `json:"skippedChannels"`
	// `cc` or `bcc` addresses that got no copy, each with the reason.
	SkippedCopies []TransactionalSkippedCopy `json:"skippedCopies"`
}

TransactionalSendResult is defined by the Kirora API.

type TransactionalService

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

TransactionalService sends one-off messages, such as receipts and password resets.

func (*TransactionalService) Cancel

func (s *TransactionalService) Cancel(ctx context.Context, messageID string, opts ...CallOption) (*OutboundMessage, error)

Cancel cancels a message scheduled with SendAt, before it's sent (cancelScheduledTransactionalMessage). A key is made for the call, so a retry replays the result rather than failing once it's cancelled.

func (*TransactionalService) Send

Send sends a transactional message (sendTransactionalMessage). Retries reuse one idempotency key, so they never send twice.

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	var resp kirora.Response
	sent, err := client.Transactional.Send(ctx, &kirora.SendTransactionalInput{
		To:    kirora.ContactIdentifier{Email: kirora.Ptr("customer@example.com")},
		Data:  map[string]any{"orderId": "1234"},
		Email: &kirora.SendTransactionalInputEmail{Template: kirora.Ptr("order-receipt")},
	}, kirora.WithIdempotencyKey("receipt-1234"), kirora.WithResponseInto(&resp))
	if err != nil {
		log.Fatal(err)
	}
	// IdempotencyReplay is true when the key was used before, so nothing was sent again.
	fmt.Println(len(sent.Messages), resp.RequestID, resp.IdempotencyReplay)
}

func (*TransactionalService) SendBatch

SendBatch sends up to 100 messages, each with its own IdempotencyKey (sendTransactionalMessagesBatch). Each entry in Results, in the order sent, has either the sent messages or an Error. An entry without its own key gets one per call.

type TransactionalSkippedChannel

type TransactionalSkippedChannel struct {
	Channel Channel `json:"channel"`
	// Its error code, such as `SUPPRESSED`.
	Code    string `json:"code"`
	Message string `json:"message"`
}

TransactionalSkippedChannel is defined by the Kirora API.

type TransactionalSkippedCopy added in v0.2.0

type TransactionalSkippedCopy struct {
	Email string          `json:"email"`
	Kind  MessageCopyKind `json:"kind"`
	// Its error code, such as `SUPPRESSED`.
	Code    string `json:"code"`
	Message string `json:"message"`
}

TransactionalSkippedCopy is defined by the Kirora API.

type TriggerCampaignInput

type TriggerCampaignInput struct {
	// Values every recipient shares.
	Data map[string]any `json:"data,omitzero"`
	// The people to send to, each named by one identifier.
	Recipients []CampaignRecipientInput `json:"recipients"`
}

TriggerCampaignInput is defined by the Kirora API.

type TriggeredCampaign

type TriggeredCampaign struct {
	Campaign Campaign `json:"campaign"`
	// Recipients that name no contact in the workspace, as listed; not sent.
	NotFound []ContactIdentifier `json:"notFound"`
}

TriggeredCampaign is defined by the Kirora API.

type Unknown

type Unknown struct {
	Raw json.RawMessage
}

Unknown is the Value of a union type, such as EmailBlock or SegmentRule, holding a kind added to the API after this version of the SDK. Raw is its JSON, which is sent back unchanged when the union is encoded.

type UpdateContactInput

type UpdateContactInput struct {
	// Your own id for the contact, up to 255 characters. Identify matches on it first.
	ExternalID Nullable[string] `json:"externalId,omitzero"`
	Email      Nullable[string] `json:"email,omitzero"`
	FirstName  Nullable[string] `json:"firstName,omitzero"`
	LastName   Nullable[string] `json:"lastName,omitzero"`
	// Phone number; normalised to E.164 (a leading `+` and country code).
	Phone Nullable[string] `json:"phone,omitzero"`
	// IANA timezone, e.g. `Europe/London`; used for send-time scheduling.
	Timezone Nullable[string] `json:"timezone,omitzero"`
	// ISO 3166-1 alpha-2 code. Omitted, it is inferred from the phone, else the timezone.
	Country Nullable[string] `json:"country,omitzero"`
	// BCP 47 tag (`fr`, `fr-CA`), stored canonical: the language the contact reads, and how
	// merge tags format numbers, dates and money for them.
	Locale Nullable[string] `json:"locale,omitzero"`
	// Named calendar dates, merged key by key; `null` removes one. A key held in
	// `attributes` is refused with 400 `VALIDATION_ERROR` at `dates.<key>`: set it to `null`
	// there in the same write to move it.
	Dates ContactDatesInput `json:"dates,omitzero"`
	// Custom attributes, merged key by key; `null` removes one. At most 50 keys and 16 KB.
	Attributes map[string]any `json:"attributes,omitzero"`
	// Consent on each channel, and how the contact agreed.
	Consent *SetContactConsentInput `json:"consent,omitempty"`
}

UpdateContactInput is defined by the Kirora API.

type UpdateListInput

type UpdateListInput struct {
	// Unique within the workspace, ignoring case.
	Name        *string          `json:"name,omitempty"`
	Description Nullable[string] `json:"description,omitzero"`
}

UpdateListInput is defined by the Kirora API.

type UpdateWorkspaceInput

type UpdateWorkspaceInput struct {
	Name *string `json:"name,omitempty"`
	// Two-letter ISO 3166-1 country code.
	Country *string `json:"country,omitempty"`
	// IANA timezone, such as `Europe/Berlin`.
	Timezone *string `json:"timezone,omitempty"`
	// The business's website.
	Website Nullable[string] `json:"website,omitzero"`
	// What the workspace sends.
	MailKind Nullable[WorkspaceMailKind] `json:"mailKind,omitzero"`
	// How its contacts agreed to hear from it: a signup form, checkout, an app.
	ContactOptIn Nullable[string] `json:"contactOptIn,omitzero"`
}

UpdateWorkspaceInput is defined by the Kirora API.

type VerticalAlign

type VerticalAlign string

VerticalAlign: Where shorter columns sit against the tallest one.

const (
	VerticalAlignTop    VerticalAlign = "top"
	VerticalAlignMiddle VerticalAlign = "middle"
	VerticalAlignBottom VerticalAlign = "bottom"
)

func (VerticalAlign) IsKnown

func (v VerticalAlign) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type VideoBlock

type VideoBlock struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyle `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRules `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

VideoBlock is defined by the Kirora API.

func (VideoBlock) MarshalJSON

func (v VideoBlock) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "video", which identifies a VideoBlock, and the properties in Extra.

func (*VideoBlock) UnmarshalJSON

func (v *VideoBlock) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type VideoBlockInput

type VideoBlockInput struct {
	// Identifies the block within the template; unique among its blocks.
	ID string `json:"id"`
	// Visual overrides for this block, such as colours, font and spacing.
	Style *EmailBlockStyleInput `json:"style,omitempty"`
	// Show the block only to contacts these segment rules match, checked as each message is
	// rendered. Omit to show it to everyone.
	VisibleIf *SegmentRulesInput `json:"visibleIf,omitempty"`
	// Show the block only when this value is present (not missing, empty or false), such as
	// `data.vat` for a VAT row; checked as each message is rendered.
	VisibleIfPresent *string `json:"visibleIfPresent,omitempty"`
	// Show the block only on phones (screens up to 620px) or only on wider screens. Clients
	// that ignore screen size show the desktop version, and so does plain text. Omit to show
	// it everywhere.
	ShowOn *ShowOn `json:"showOn,omitempty"`
	Src    *string `json:"src,omitempty"`
	Alt    *string `json:"alt,omitempty"`
	Text   *string `json:"text,omitempty"`
	// Where it links: an `https:`, `http:`, `mailto:` or `tel:` address, or a merge tag.
	// `https://` is added to a bare address such as `acme.com/setup`. A draft may hold
	// anything; a button or video whose link is none of these cannot be published or sent.
	Href *string `json:"href,omitempty"`
	// Extra holds properties without a field above, by name, such as ones added to the API
	// after this version of the SDK. They're sent back unchanged; a property with a field
	// above takes precedence over one here.
	Extra map[string]json.RawMessage `json:"-"`
}

VideoBlockInput is defined by the Kirora API.

func (VideoBlockInput) MarshalJSON

func (v VideoBlockInput) MarshalJSON() ([]byte, error)

MarshalJSON adds "type": "video", which identifies a VideoBlockInput, and the properties in Extra.

func (*VideoBlockInput) UnmarshalJSON

func (v *VideoBlockInput) UnmarshalJSON(data []byte) error

UnmarshalJSON keeps properties without a field in Extra.

type WebPushSubscription

type WebPushSubscription struct {
	// The browser push service's URL, as `PushSubscription.toJSON()` gives it.
	Endpoint string `json:"endpoint"`
	// When the subscription expires, in epoch milliseconds, if the browser says.
	ExpirationTime Nullable[int] `json:"expirationTime,omitzero"`
	// The subscription keys, exactly as `PushSubscription.toJSON()` gives them.
	Keys WebPushSubscriptionKeys `json:"keys"`
}

WebPushSubscription: The browser's `PushSubscription`, as JSON.

type WebPushSubscriptionKeys

type WebPushSubscriptionKeys struct {
	// The browser's public key, base64url.
	P256dh string `json:"p256dh"`
	// The subscription's auth secret, base64url.
	Auth string `json:"auth"`
}

WebPushSubscriptionKeys: The subscription keys, exactly as `PushSubscription.toJSON()` gives them.

type WebhookEvent

type WebhookEvent string

WebhookEvent: WebhookEvent is the type of a webhook, from its X-Webhook-Event header.

const (
	WebhookEventCampaignSent          WebhookEvent = "campaign.sent"
	WebhookEventContactConsentChanged WebhookEvent = "contact.consent_changed"
	WebhookEventContactCreated        WebhookEvent = "contact.created"
	WebhookEventContactUnsubscribed   WebhookEvent = "contact.unsubscribed"
	WebhookEventFormSubmitted         WebhookEvent = "form.submitted"
	WebhookEventJourneyActionReached  WebhookEvent = "journey.action_reached"
	WebhookEventJourneyEnrolled       WebhookEvent = "journey.enrolled"
	WebhookEventMessageBounced        WebhookEvent = "message.bounced"
	WebhookEventMessageClicked        WebhookEvent = "message.clicked"
	WebhookEventMessageComplained     WebhookEvent = "message.complained"
	WebhookEventMessageDelivered      WebhookEvent = "message.delivered"
	WebhookEventMessageFailed         WebhookEvent = "message.failed"
	WebhookEventMessageOpened         WebhookEvent = "message.opened"
	WebhookEventMessageSent           WebhookEvent = "message.sent"
	WebhookEventMessageSkipped        WebhookEvent = "message.skipped"
	WebhookEventWebhookTest           WebhookEvent = "webhook.test"
)

func (WebhookEvent) IsKnown

func (v WebhookEvent) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type WebhookHeaders

type WebhookHeaders struct {
	// Event is the kind of event, such as WebhookEventMessageDelivered.
	Event WebhookEvent

	// EventID identifies the event. Webhooks are delivered at least once, so deduplicate
	// on it.
	EventID string
	// Attempt counts deliveries of the event, from 1.
	Attempt int
	// Timestamp and Signature are what VerifyWebhookSignature checks.
	Timestamp string
	Signature string
}

WebhookHeaders holds the Kirora headers of a webhook request. Get them with ReadWebhookHeaders or VerifyWebhook.

func ReadWebhookHeaders

func ReadWebhookHeaders(h http.Header) (headers WebhookHeaders, ok bool)

ReadWebhookHeaders reads a webhook's headers from h, without verifying them. ok is false if the timestamp, signature, event or event id header is missing, or the attempt header is set but isn't a whole number from 1. The signature doesn't cover the event or event id headers: once VerifyWebhookSignature succeeds, trust the body's eventType and eventId rather than these, or use VerifyWebhook, which checks they match.

func VerifyWebhook

func VerifyWebhook(secret string, r *http.Request, opts *WebhookOptions) (WebhookHeaders, []byte, error)

VerifyWebhook reads r's webhook headers and body, verifies the signature as VerifyWebhookSignature does, checks the event and event id headers match the signed body, and returns both. It consumes r.Body; parse the returned body only once VerifyWebhook succeeds.

A request that fails verification, including a body over 10 MiB, gets a *WebhookVerificationError, and should be rejected. A body that can't be read, an empty secret or invalid opts get a plain error.

Example
package main

import (
	"encoding/json"
	"errors"
	"fmt"
	"log"
	"net/http"
	"os"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	http.HandleFunc("/webhooks/kirora", func(w http.ResponseWriter, r *http.Request) {
		headers, body, err := kirora.VerifyWebhook(os.Getenv("KIRORA_WEBHOOK_SECRET"), r, nil)
		var verr *kirora.WebhookVerificationError
		if errors.As(err, &verr) {
			log.Printf("rejected a webhook: %s", verr.Reason)
			http.Error(w, "invalid webhook", http.StatusUnauthorized)
			return
		} else if err != nil {
			// The request couldn't be read; it may still be a genuine webhook.
			http.Error(w, "", http.StatusInternalServerError)
			return
		}
		// Parse only the body VerifyWebhook returns, once the signature has matched.
		var event map[string]any
		json.Unmarshal(body, &event)
		fmt.Println(headers.Event, headers.EventID)
		w.WriteHeader(http.StatusOK)
	})
}

type WebhookOptions

type WebhookOptions struct {
	// Tolerance is how far the timestamp may be from Now, such as Ptr(time.Minute). It
	// must not be negative; 0 means the timestamp must match Now to the second. nil means
	// DefaultWebhookTolerance.
	Tolerance *time.Duration

	// Now is the time the timestamp is checked against, such as a fixed time in tests.
	// The zero value means the current time.
	Now time.Time
}

WebhookOptions configures webhook verification. A nil *WebhookOptions uses the defaults.

type WebhookVerificationError

type WebhookVerificationError struct {
	Reason WebhookVerificationFailure
	// contains filtered or unexported fields
}

WebhookVerificationError is returned when a webhook request fails verification and should be rejected. Reason says why.

func (*WebhookVerificationError) Error

func (e *WebhookVerificationError) Error() string

type WebhookVerificationFailure

type WebhookVerificationFailure string

WebhookVerificationFailure is why a webhook failed verification. See WebhookVerificationError.

const (
	// WebhookInvalidTimestamp means the timestamp header is missing or isn't a whole
	// number of seconds.
	WebhookInvalidTimestamp WebhookVerificationFailure = "invalid_timestamp"

	// WebhookSignatureMismatch means no signature matches the body: the secret is wrong,
	// or the body was changed, such as parsed and re-serialized, before verification.
	WebhookSignatureMismatch WebhookVerificationFailure = "signature_mismatch"

	// WebhookTimestampOutsideTolerance means the timestamp is further from now than the
	// tolerance: the request is a replay, or a clock is out of sync.
	WebhookTimestampOutsideTolerance WebhookVerificationFailure = "timestamp_outside_tolerance"

	// WebhookInvalidHeaders means the signature, event or event id header is missing, the
	// attempt header isn't a whole number from 1, or the event or event id header doesn't
	// match the signed body.
	WebhookInvalidHeaders WebhookVerificationFailure = "invalid_headers"

	// WebhookBodyTooLarge means the body is larger than 10 MiB.
	WebhookBodyTooLarge WebhookVerificationFailure = "body_too_large"
)

type WhereOperator

type WhereOperator string

WhereOperator: `notEquals` also matches an event without the property. `equals` and `notEquals` ignore case and accents in text. The date operators read the property as a date, as attribute conditions do: UTC days, an ISO-8601 date is the start of that day, and a property that is missing or not an ISO-8601 date or date and time never matches. They read the property's own date; `within` limits when the event happened. Membership moves with the calendar: a contact enters when the date comes into range, with no new event, and a journey triggered by entering the segment then starts for them.

const (
	WhereOperatorEquals          WhereOperator = "equals"
	WhereOperatorNotEquals       WhereOperator = "notEquals"
	WhereOperatorGt              WhereOperator = "gt"
	WhereOperatorGte             WhereOperator = "gte"
	WhereOperatorLt              WhereOperator = "lt"
	WhereOperatorLte             WhereOperator = "lte"
	WhereOperatorBefore          WhereOperator = "before"
	WhereOperatorAfter           WhereOperator = "after"
	WhereOperatorWithinLastDays  WhereOperator = "withinLastDays"
	WhereOperatorMoreThanDaysAgo WhereOperator = "moreThanDaysAgo"
	WhereOperatorInNextDays      WhereOperator = "inNextDays"
)

func (WhereOperator) IsKnown

func (v WhereOperator) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type Workspace

type Workspace struct {
	ID string `json:"id"`
	// Your own id for the tenant.
	ExternalID string `json:"externalId"`
	Name       string `json:"name"`
	// Two-letter ISO 3166-1 country code.
	Country string `json:"country"`
	// IANA timezone; decides local-time sends and report days.
	Timezone string `json:"timezone"`
	// `suspended` refuses every send in the workspace until it is resumed; `deleting`
	// refuses them too, and the workspace is purged unless the deletion is cancelled.
	Status WorkspaceStatus `json:"status"`
	// When it was suspended; null if not.
	SuspendedAt *time.Time `json:"suspendedAt"`
	// When deletion was asked for; null if not.
	DeletionRequestedAt *time.Time `json:"deletionRequestedAt"`
	// When the workspace and everything in it is deleted for good, unless the deletion is
	// cancelled before; null if no deletion is pending.
	DeletesAt *time.Time `json:"deletesAt"`
	// The business's website.
	Website *string `json:"website"`
	// What the workspace sends.
	MailKind *WorkspaceMailKind `json:"mailKind"`
	// How its contacts agreed to hear from it: a signup form, checkout, an app.
	ContactOptIn *string   `json:"contactOptIn"`
	CreatedAt    time.Time `json:"createdAt"`
}

Workspace is defined by the Kirora API.

type WorkspaceMailKind added in v0.2.0

type WorkspaceMailKind string

WorkspaceMailKind: What the workspace sends.

const (
	WorkspaceMailKindMarketing     WorkspaceMailKind = "marketing"
	WorkspaceMailKindTransactional WorkspaceMailKind = "transactional"
	WorkspaceMailKindBoth          WorkspaceMailKind = "both"
)

func (WorkspaceMailKind) IsKnown added in v0.2.0

func (v WorkspaceMailKind) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type WorkspaceStatus

type WorkspaceStatus string

WorkspaceStatus: `suspended` refuses every send in the workspace until it is resumed; `deleting` refuses them too, and the workspace is purged unless the deletion is cancelled.

const (
	WorkspaceStatusActive    WorkspaceStatus = "active"
	WorkspaceStatusSuspended WorkspaceStatus = "suspended"
	WorkspaceStatusDeleting  WorkspaceStatus = "deleting"
)

func (WorkspaceStatus) IsKnown

func (v WorkspaceStatus) IsKnown() bool

IsKnown is false for a value added to the API after this version of the SDK.

type WorkspacesPage

type WorkspacesPage = Page[Workspace, CursorPaginationMeta]

WorkspacesPage is a page of workspaces.

type WorkspacesService

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

WorkspacesService manages your tenants' workspaces, for partner keys only. Each is named by the externalId you give it; act in one with Client.ForWorkspace.

func (*WorkspacesService) All

All iterates over every workspace, fetching pages as it goes (listWorkspaces).

func (*WorkspacesService) CancelDeletion

func (s *WorkspacesService) CancelDeletion(ctx context.Context, externalID string, opts ...CallOption) (*Workspace, error)

CancelDeletion stops a workspace's scheduled deletion (cancelWorkspaceDeletion).

func (*WorkspacesService) Create

func (s *WorkspacesService) Create(ctx context.Context, params *CreateWorkspaceInput, opts ...CallOption) (*Workspace, error)

Create creates a workspace (createWorkspace). Retries reuse one idempotency key, so they never create two.

func (*WorkspacesService) Delete

func (s *WorkspacesService) Delete(ctx context.Context, externalID string, opts ...CallOption) (*Workspace, error)

Delete schedules a workspace's deletion, which CancelDeletion can undo until it happens, and returns the workspace in its pending state (deleteWorkspace).

Example
package main

import (
	"context"
	"fmt"
	"log"

	kirora "github.com/kiroratech/kirora-go"
)

func main() {
	ctx := context.Background()
	client, _ := kirora.NewClient("")

	workspace, err := client.Workspaces.Delete(ctx, "tenant-42")
	if err != nil {
		log.Fatal(err)
	}
	// Deletion is only scheduled, so it can be cancelled until DeletesAt.
	fmt.Println(workspace.Status, "until", workspace.DeletesAt)

	if _, err := client.Workspaces.CancelDeletion(ctx, "tenant-42"); err != nil {
		log.Fatal(err)
	}
}

func (*WorkspacesService) Get

func (s *WorkspacesService) Get(ctx context.Context, externalID string, opts ...CallOption) (*Workspace, error)

Get fetches a workspace (getWorkspace).

func (*WorkspacesService) List

List fetches a page of workspaces (listWorkspaces). See All for every one.

func (*WorkspacesService) Resume

func (s *WorkspacesService) Resume(ctx context.Context, externalID string, opts ...CallOption) (*Workspace, error)

Resume lets a suspended workspace send again (resumeWorkspace).

func (*WorkspacesService) Suspend

func (s *WorkspacesService) Suspend(ctx context.Context, externalID string, opts ...CallOption) (*Workspace, error)

Suspend stops every send in a workspace until it's resumed, dropping what's queued (suspendWorkspace). Reading and editing keep working.

func (*WorkspacesService) Update

func (s *WorkspacesService) Update(ctx context.Context, externalID string, params *UpdateWorkspaceInput, opts ...CallOption) (*Workspace, error)

Update changes a workspace (updateWorkspace). Safe to retry.

Directories

Path Synopsis
examples
bulk-import command
Command bulk-import identifies the contacts in a CSV file, 100 to a call, and pauses when the rate limit runs low.
Command bulk-import identifies the contacts in a CSV file, 100 to a call, and pauses when the rate limit runs low.
partner command
Command partner lists every tenant workspace under a partner key, with the number of contacts in each active one.
Command partner lists every tenant workspace under a partner key, with the number of contacts in each active one.
webhook-server command
Command webhook-server receives Kirora webhooks: it checks each one's signature, skips events it has already handled, and logs the ones it acts on.
Command webhook-server receives Kirora webhooks: it checks each one's signature, skips events it has already handled, and logs the ones it acts on.
internal
codegen command
Command codegen generates the SDK's models.go, error_codes.go, webhook_events.go and operations.go from the Kirora OpenAPI spec.
Command codegen generates the SDK's models.go, error_codes.go, webhook_events.go and operations.go from the Kirora OpenAPI spec.

Jump to

Keyboard shortcuts

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