Skip to content

Releases

Elastic Email Go SDK 4.4.0

Choose a tag to compare

@eeppodolak eeppodolak released this 13 Oct 11:50

📦 Go module: https://pkg.go.dev/github.com/elasticemail/elasticemail-go/v4@v4.4.0

go get github.com/elasticemail/elasticemail-go/v4@v4.4.0

What's in this release

Optional Idempotency-Key on email sends, so a send can be retried after a timeout or network error without going out (or being charged) twice. Without a key, sends behave exactly as before.

Updated endpoints

  • EmailsAPI.EmailsTransactionalPost, EmailsAPI.EmailsPost and EmailsAPI.EmailsMergefilePost: new optional builder method IdempotencyKey(key string), sent as the Idempotency-Key header (1-255 printable ASCII characters)
  • The same three endpoints now document 400, 409, 422 and 503 responses

Existing code compiles and behaves the same: the key is a new optional builder method, nothing else changed.

Retry a send safely

key := uuid.NewString() // github.com/google/uuid: one new key per logical send

result, httpRes, err := client.EmailsAPI.EmailsTransactionalPost(ctx).
	EmailTransactionalMessageData(*message).
	IdempotencyKey(key).
	Execute()
if err != nil {
	// Timeout or 5xx: retry with the same key and the same message.
}
if httpRes != nil && httpRes.Header.Get("Idempotency-Replayed") == "true" {
	fmt.Println("Already sent earlier:", result.GetTransactionID())
}

How the key behaves

  • Same key and the same request (same endpoint, byte-identical body) within 24 hours: you get the stored response of the first request (same status, TransactionID and MessageID) with Idempotency-Replayed: true. Nothing is sent or charged again.
  • Same key with a different body or endpoint: 422.
  • Same key while the first request is still running: 409.
  • Invalid key: 400. Key couldn't be confirmed: 503 with Retry-After (seconds); retry with the same key.
  • If the first request fails (4xx/5xx), the key is released, so a corrected retry with the same key runs.
  • Keys are scoped per account (subaccounts are separate) and kept for 24 hours from the first request.

Generate a new key (e.g. a UUID v4) for each logical send and reuse it only to retry that send, with the message built the same way.

Elastic Email Go SDK 4.3.0

Choose a tag to compare

@eeppodolak eeppodolak released this 13 Oct 07:23

Elastic Email Go SDK 4.3.0

📦 Go module: https://pkg.go.dev/github.com/elasticemail/elasticemail-go/v4@v4.3.0

go get github.com/elasticemail/elasticemail-go/v4@v4.3.0

What's in this release

Opt-in HMAC-SHA256 webhook signing and POST + JSON webhook delivery. Both are chosen when a webhook is created and can't be changed later. Webhooks created without them keep working exactly as before (unsigned GET).

New endpoint

  • WebhookAPI.WebhookByPublicidSecretRotatePost(ctx, publicid): POST /webhook/{publicid}/secret/rotate replaces the signing secret of a signed webhook and returns the new one, only in that response

New and updated models

  • WebhookCreatePayload: new SetEnableSigning, SetDeliveryMethod. EnableSigning: true signs every request; DeliveryMethod: PostJson sends events as a POST with a JSON body instead of a GET with a query string
  • Webhook: new GetSigningEnabled, GetDeliveryMethod, GetSigningSecret. SigningSecret is returned only when a webhook is created with signing, or when its secret is rotated: store it safely
  • New WebhookDeliveryMethod with WEBHOOKDELIVERYMETHOD_GET and WEBHOOKDELIVERYMETHOD_POST_JSON

Create a signed webhook

payload := ElasticEmail.NewWebhookCreatePayload("my-webhook", "https://your-app.example.com/webhook")
payload.SetNotificationForSent(true)
payload.SetEnableSigning(true)
payload.SetDeliveryMethod(ElasticEmail.WEBHOOKDELIVERYMETHOD_POST_JSON)

created, _, err := client.WebhookAPI.WebhookPost(ctx).WebhookCreatePayload(*payload).Execute()
// Returned only now - store it in your secret manager.
fmt.Println(created.GetSigningSecret())

Verifying requests

Signed requests carry X-ElasticEmail-Timestamp, X-ElasticEmail-Signature: v1=<hex> and X-ElasticEmail-Webhook-Id. The signature is hex(HMAC-SHA256(secret, "{timestamp}\n{METHOD}\n{path and query}\n{raw body}")).

  1. Read the raw body before parsing it as JSON. A GET has no body.
  2. Reject the request if the timestamp is more than 5 minutes away from your clock.
  3. Compute the expected signature, using the request target exactly as received (still URL-encoded), and compare it with every v1= entry of X-ElasticEmail-Signature in constant time.
  4. If nothing matches, return 401. The notification is retried for up to 24 hours, signed with the current secret.

Signed and POST webhooks don't follow redirects, so point the webhook at the final URL.

Elastic Email Go SDK 4.2.0

Choose a tag to compare

@eeppodolak eeppodolak released this 28 Sep 09:55

Elastic Email Go SDK 4.2.0

This is the first GitHub Release of the Go SDK. It brings the version in line with the other Elastic Email client libraries and is the first version published as a proper Go module under /v4.

📦 pkg.go.dev

go get github.com/elasticemail/elasticemail-go/v4@v4.2.0

What's in this release

  • Webhooks (WebhookAPI): full CRUD for webhooks: WebhookGet, WebhookPost, WebhookByPublicidGet, WebhookByPublicidPut and WebhookByPublicidDelete. New models: Webhook, WebhookCreatePayload, WebhookUpdatePayload.
  • Automations (CampaignsAPI): CampaignsAutomationByNameTriggerPost (POST /campaigns/automation/{name}/trigger) triggers an automation for a contact.
  • Subaccounts (SubAccountsAPI): SubaccountsByEmailApikeyGet (GET /subaccounts/{email}/apikey) returns a subaccount's API key.
  • Domains: new DKIMRecord model. DomainData and DomainDetail gain CertificateExpiryDate, WasEverVerified and DKIMRecord.
  • Campaigns: CampaignOptions gains SendAtLocalTime.
  • Enums: CertificateValidationStatus adds InProgress. EventType adds Error, TransactionalUnsubscribe and Suppress.
  • Docs: SecurityAPI now notes that a subaccount's default API key expires after 48 hours.
  • Package version set to 4.2.0 (previously 4.0.31). The default User-Agent is now OpenAPI-Generator/4.2.0/go.

Breaking changes

  • The module path now ends in /v4. Earlier tags (4.0.x) had no v prefix and a module path without a major-version suffix, so Go tooling never saw them as releases. Update your imports:

    // before
    import ElasticEmail "github.com/elasticemail/elasticemail-go"
    // after
    import ElasticEmail "github.com/elasticemail/elasticemail-go/v4"

    Then run go get github.com/elasticemail/elasticemail-go/v4@v4.2.0 and go mod tidy. The package name (ElasticEmail) and the API surface are otherwise unchanged.

Compatibility

  • Go 1.18 or later, no third-party runtime dependencies
  • Elastic Email REST API v4

Full changelog: 4.0.31...v4.2.0

Sponsor
SponsoredKunjungi sekarang
Promo