Skip to content
Splashify Pro
Email docsEmail

Go Quickstart

There is no Go SDK. The API is plain HTTP and JSON, so the standard library is all you need.

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"`
		Message string `json:"message"`
		Results []struct {
			MessageID string `json:"message_id"`
			Status    string `json:"status"`
		} `json:"results"`
	}
	json.NewDecoder(res.Body).Decode(&out)
	if res.StatusCode >= 400 {
		fmt.Println(res.StatusCode, out.Message)
		return
	}
	fmt.Println(out.Results[0].MessageID)
}

What's next