Create a key to copy examples filled with your team.
Send emails with Go
POST /sends with net/http.
POST /sends with net/http. PostShiba has no official module.
send.go
1
package main
2
3
import (
4
"bytes"
5
"net/http"
6
)
7
8
func main() {
9
body := []byte(`{
10
"send": {
11
"from": "hello@mail.example.com",
12
"to": ["you@example.com"],
13
"subject": "PostShiba test",
14
"text": "hello from PostShiba",
15
"html": "<p>hello from PostShiba</p>",
16
"unique_args": {"campaign_id": "cmp_123", "site": "docs"}
17
}
18
}`)
19
req, err := http.NewRequest(
20
http.MethodPost,
21
"https://postshiba.com/api/v1/teams/1/clusters/4/sends",
22
bytes.NewReader(body),
23
)
24
if err != nil {
25
panic(err)
26
}
27
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
28
req.Header.Set("Content-Type", "application/json")
29
resp, err := http.DefaultClient.Do(req)
30
if err != nil {
31
panic(err)
32
}
33
defer resp.Body.Close()
34
}