Skip to content
Splashify Pro
Email docsEmail

Go Quickstart

go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"from":      "[email protected]",
		"to":        []string{"[email protected]"},
		"subject":   "Welcome",
		"html_body": "<h1>Welcome 👋</h1>",
		"text_body": "Welcome.",
	})

	req, _ := http.NewRequest("POST",
		"https://api.splashifypro.com/api/v1/partner/email/send",
		bytes.NewReader(body),
	)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("SPLASHIFY_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var out struct {
		Success bool `json:"success"`
		Results []struct {
			MessageID string `json:"message_id"`
			Status    string `json:"status"`
		} `json:"results"`
	}
	json.NewDecoder(res.Body).Decode(&out)
	fmt.Println(out.Results[0].MessageID)
}

What's next