Cascade provides a REST API. Below is a practical minimum in Go with the net/http client.
Set OTP_API_TOKEN and OTP_API_DOMAIN in your backend environment. Set OTP_API_DOMAIN to the domain bound to the key, such as example.kz. Send the 4- or 6-digit code the user entered as a string. The verification examples read it from OTP_CODE.
Useful links: API, send, verify, examples, FAQ, pricing, documentation.
Installation
The standard library is enough; a separate Cascade module may be missing.
# go mod init example.com/app
Send example
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
func cascade(path string, payload any) (map[string]any, error) {
b, _ := json.Marshal(payload)
req, _ := http.NewRequest(http.MethodPost, "https://cascade.kz/api"+path, bytes.NewReader(b))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OTP_API_TOKEN"))
req.Header.Set("X-Cascade-Client-Domain", os.Getenv("OTP_API_DOMAIN"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
defer res.Body.Close()
var out map[string]any
json.NewDecoder(res.Body).Decode(&out)
return out, nil
}
Call /otp/send and /otp/verify, checking success. See API, errors, compare.