Forgot password
curl --request POST \
--url https://api.example.com/api/v1/auth/forgot-passwordimport requests
url = "https://api.example.com/api/v1/auth/forgot-password"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/auth/forgot-password', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/auth/forgot-password",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/auth/forgot-password"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/auth/forgot-password")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/forgot-password")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuth
Forgot password
Start a password reset. Sends a 6-digit code if the email is known and verified.
POST
/
api
/
v1
/
auth
/
forgot-password
Forgot password
curl --request POST \
--url https://api.example.com/api/v1/auth/forgot-passwordimport requests
url = "https://api.example.com/api/v1/auth/forgot-password"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/auth/forgot-password', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/auth/forgot-password",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/auth/forgot-password"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/auth/forgot-password")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/forgot-password")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOverview
Initiates a password reset by sending a 6-digit code to the supplied email. The code has a 15-minute TTL (longer than the email-verify OTP because mobile users often switch apps to read it). The endpoint always returns200 OK. The actual side effect — whether an email is sent — depends on internal state the response does not reveal:
- Email unknown → silent no-op.
- Email known but unverified → silent no-op. (Prevents using password-reset as a verification bypass.)
- Email belongs to an OAuth-only account (Google / Apple, no password set) → silent no-op.
- Email known, verified, has a password → fresh 6-digit code dispatched via Resend.
Authentication
None required.Path parameters
None.Query parameters
None.Request body
| Field | Type | Required | Allowed values | Example |
|---|---|---|---|---|
email | string | yes | RFC 5322 valid, lowercased server-side | alice@example.com |
Example payload
{
"email": "alice@example.com"
}
Response — 200 OK
| Field | Type | Notes | Example |
|---|---|---|---|
ok | boolean | Always true. | true |
Example response
{
"ok": true
}
Error responses
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_FAILED | Email malformed. |
404, no 409, no rate-limit response from this endpoint. The internal cooldown is silent so the response shape stays constant.
Side effects
When the email belongs to a verified, password-using, non-deleted account:- Inserts an
otp_codesrow (purpose: 'password_reset', 15-min TTL). Any prior outstanding reset code for this email is invalidated. - Sends an email via Resend with the 6-digit code.
See also
- Reset password — confirm the code and set a new password.
curl
curl -X POST https://api.swappr.co.uk/api/v1/auth/forgot-password \
-H "Content-Type: application/json" \
-d '{ "email": "alice@example.com" }'