POST
/
api
/
v1
/
auth
/
forgot-password
Forgot password
curl --request POST \
  --url https://api.example.com/api/v1/auth/forgot-password
import 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_body

Overview

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 returns 200 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.
This means an attacker who guesses an email cannot tell whether it is registered, verified, or OAuth-bound.

Authentication

None required.

Path parameters

None.

Query parameters

None.

Request body

FieldTypeRequiredAllowed valuesExample
emailstringyesRFC 5322 valid, lowercased server-sidealice@example.com

Example payload

{
  "email": "alice@example.com"
}

Response — 200 OK

FieldTypeNotesExample
okbooleanAlways true.true

Example response

{
  "ok": true
}

Error responses

StatusCodeMeaning
400VALIDATION_FAILEDEmail malformed.
There is no 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_codes row (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.
Otherwise, no side effects.

See also

curl

curl -X POST https://api.swappr.co.uk/api/v1/auth/forgot-password \
  -H "Content-Type: application/json" \
  -d '{ "email": "alice@example.com" }'