packagemainimport("bytes""crypto/rand""encoding/hex""encoding/json""net/http""os")constapi="https://api.example.com/organizations/<org>"// newKey returns a random idempotency key.funcnewKey()string{b:=make([]byte,16)rand.Read(b)returnhex.EncodeToString(b)}// call sends one request with the access token and a JSON body (or none).// An optional idempotency key is sent as the Idempotency-Key header.funccall(method,pathstring,bodyany,idempotencyKey...string)(*http.Response,error){varbufbytes.Bufferifbody!=nil{iferr:=json.NewEncoder(&buf).Encode(body);err!=nil{returnnil,err}}req,err:=http.NewRequest(method,api+path,&buf)iferr!=nil{returnnil,err}req.Header.Set("Authorization","Bearer "+os.Getenv("STREAMTIME_TOKEN"))req.Header.Set("Content-Type","application/json")iflen(idempotencyKey)>0{req.Header.Set("Idempotency-Key",idempotencyKey[0])}returnhttp.DefaultClient.Do(req)}
Set up email
Go to Settings → SMTP Email (also a step of first-time setup).
Turn on Send notification emails.
Under Mail server, enter SMTP server, Connection security, Port and, if needed, Timeout (seconds).
Under Sign in, enter Username (optional) and Password, or leave both blank if the server accepts mail without signing in.
Under Sender, enter From address, From name (optional) and Link address in emails.
Under Which emails to send, choose resource health, alerts and the weekly performance report.
Under Test the settings, select Send test email, then save.
curl -X PUT "$API/smtp-config/"\-H"Authorization: Bearer $STREAMTIME_TOKEN"-H"Content-Type: application/json"\-d'{"enabled": true, "host": "smtp.example.com", "port": 587,
"encryption": "starttls", "username": "streamtime", "password": "<password>",
"from_email": "streamtime@example.com", "from_name": "Streamtime",
"link_base_url": "https://console.example.com",
"status_emails_enabled": true, "alert_emails_enabled": true,
"weekly_report_enabled": true}'# Send a test (to the signed-in user if "to" is left out).
curl -X POST "$API/smtp-config/test/"\-H"Authorization: Bearer $STREAMTIME_TOKEN"-H"Content-Type: application/json"\-d'{"to": "you@example.com"}'
encryption is starttls, ssl or none. Leave password out to keep the saved one; send an empty value to remove it. The password is never returned.
An organization has one set of mail settings. terraform destroy stops managing them and leaves their current values in place. The password is kept in sensitive state and can’t be recovered by an import.