curl -X POST "https://api.tktchurch.com/v1/auth/forgot-password" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]"
}'
const requestPasswordReset = async (email) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/forgot-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
struct ForgotPasswordRequest: Encodable {
let email: String
}
func requestPasswordReset(email: String) async throws {
let request = ForgotPasswordRequest(email: email)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/forgot-password")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try? JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
}
// Usage
do {
try await requestPasswordReset(email: "[email protected]")
print("Password reset instructions sent if email exists")
} catch {
print("Failed to request password reset: \(error.localizedDescription)")
}
data class ForgotPasswordRequest(
val email: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun requestPasswordReset(email: String) {
val request = ForgotPasswordRequest(email)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/forgot-password")
.post(requestBody)
.header("Content-Type", "application/json")
.build()
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to request password reset")
}
}
}
}
// Usage
try {
passwordResetService.requestPasswordReset("[email protected]")
println("Password reset instructions sent if email exists")
} catch (e: Exception) {
println("Failed to request password reset: ${e.message}")
}
import axios from 'axios';
interface ForgotPasswordRequest {
email: string;
}
const requestPasswordReset = async (email: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/forgot-password',
{ email },
{
headers: {
'Content-Type': 'application/json',
},
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to request password reset');
}
throw error;
}
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
{
"status": 200,
"message": "If the email exists, password reset instructions will be sent"
}
{
"error": {
"status": 400,
"reason": "Invalid email format"
}
}
Authentication
Forgot Password
Request a password reset link
POST
/
auth
/
forgot-password
curl -X POST "https://api.tktchurch.com/v1/auth/forgot-password" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]"
}'
const requestPasswordReset = async (email) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/forgot-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
struct ForgotPasswordRequest: Encodable {
let email: String
}
func requestPasswordReset(email: String) async throws {
let request = ForgotPasswordRequest(email: email)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/forgot-password")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try? JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
}
// Usage
do {
try await requestPasswordReset(email: "[email protected]")
print("Password reset instructions sent if email exists")
} catch {
print("Failed to request password reset: \(error.localizedDescription)")
}
data class ForgotPasswordRequest(
val email: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun requestPasswordReset(email: String) {
val request = ForgotPasswordRequest(email)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/forgot-password")
.post(requestBody)
.header("Content-Type", "application/json")
.build()
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to request password reset")
}
}
}
}
// Usage
try {
passwordResetService.requestPasswordReset("[email protected]")
println("Password reset instructions sent if email exists")
} catch (e: Exception) {
println("Failed to request password reset: ${e.message}")
}
import axios from 'axios';
interface ForgotPasswordRequest {
email: string;
}
const requestPasswordReset = async (email: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/forgot-password',
{ email },
{
headers: {
'Content-Type': 'application/json',
},
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to request password reset');
}
throw error;
}
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
{
"status": 200,
"message": "If the email exists, password reset instructions will be sent"
}
{
"error": {
"status": 400,
"reason": "Invalid email format"
}
}
This is a public endpoint that does not require authentication.
Request Body
string
required
The email address associated with the account. Must be a valid email format.
Response
A successful request returns HTTP 200 OK status. For security reasons, the same response is returned whether or not the email exists in the system. If the email exists:- A password reset token will be generated (valid for 1 hour)
- A password reset email will be sent to the provided email address
For security purposes, this endpoint always returns a 200 OK response, regardless of whether the email exists in the system. This prevents email enumeration attacks.
Error Responses
object
Common error cases:
- 400 Bad Request: Invalid email format
curl -X POST "https://api.tktchurch.com/v1/auth/forgot-password" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]"
}'
const requestPasswordReset = async (email) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/forgot-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
struct ForgotPasswordRequest: Encodable {
let email: String
}
func requestPasswordReset(email: String) async throws {
let request = ForgotPasswordRequest(email: email)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/forgot-password")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try? JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
}
// Usage
do {
try await requestPasswordReset(email: "[email protected]")
print("Password reset instructions sent if email exists")
} catch {
print("Failed to request password reset: \(error.localizedDescription)")
}
data class ForgotPasswordRequest(
val email: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun requestPasswordReset(email: String) {
val request = ForgotPasswordRequest(email)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/forgot-password")
.post(requestBody)
.header("Content-Type", "application/json")
.build()
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to request password reset")
}
}
}
}
// Usage
try {
passwordResetService.requestPasswordReset("[email protected]")
println("Password reset instructions sent if email exists")
} catch (e: Exception) {
println("Failed to request password reset: ${e.message}")
}
import axios from 'axios';
interface ForgotPasswordRequest {
email: string;
}
const requestPasswordReset = async (email: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/forgot-password',
{ email },
{
headers: {
'Content-Type': 'application/json',
},
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to request password reset');
}
throw error;
}
};
// Usage
try {
await requestPasswordReset('[email protected]');
console.log('Password reset instructions sent if email exists');
} catch (error) {
console.error('Failed to request password reset:', error.message);
}
{
"status": 200,
"message": "If the email exists, password reset instructions will be sent"
}
{
"error": {
"status": 400,
"reason": "Invalid email format"
}
}
