Skip to content

SDK

Go SDK / HTTP client

Connect Cascade via net/http: send and verify OTP.

Quick Answer

Call https://cascade.kz/api with a Bearer token from Go on the backend.

Summary

Ready fragments for Go: set up an HTTP client, initialize Bearer, send, verify, handle errors. An official package may be missing.

Key Takeaways

  • An official package is not required — HTTP is enough.
  • Server-side calls only.
  • Check success in JSON.

Related Questions

Cascade provides a REST API. Below is a practical minimum in Go with the net/http client.

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("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.