Request one-time passcode
POST
One-time passcode request
application/json- body
email*stringFormat
emailNo Content
The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/users/otp/request" \ -H "Content-Type: application/json" \ -d '{ "email": "[email protected]"}'const { CODER_URL } = process.env;const url = `${CODER_URL}/api/v2/users/otp/request`;const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ email: "[email protected]", }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/users/otp/request"response = requests.post( url, json={ "email": "[email protected]", },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "email": "[email protected]"}`) url := os.Getenv("CODER_URL") + "/api/v2/users/otp/request" req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response204
Empty