curl -X POST "https://api.tktchurch.com/v1/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIs...",
"newPassword": "newSecurePassword123"
}'
const resetPassword = async (token, newPassword) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/reset-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ token, newPassword })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
struct ResetPasswordRequest: Encodable {
let token: String
let newPassword: String
}
func resetPassword(token: String, newPassword: String) async throws {
let request = ResetPasswordRequest(
token: token,
newPassword: newPassword
)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/reset-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 resetPassword(
token: "eyJhbGciOiJIUzI1NiIs...",
newPassword: "newSecurePassword123"
)
print("Password reset successfully")
} catch {
print("Failed to reset password: \(error.localizedDescription)")
}
data class ResetPasswordRequest(
val token: String,
val newPassword: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun resetPassword(token: String, newPassword: String) {
val request = ResetPasswordRequest(token, newPassword)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/reset-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 reset password")
}
}
}
}
// Usage
try {
passwordResetService.resetPassword(
"eyJhbGciOiJIUzI1NiIs...",
"newSecurePassword123"
)
println("Password reset successfully")
} catch (e: Exception) {
println("Failed to reset password: ${e.message}")
}
import axios from 'axios';
interface ResetPasswordRequest {
token: string;
newPassword: string;
}
const resetPassword = async (token: string, newPassword: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/reset-password',
{ token, newPassword },
{
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 reset password');
}
throw error;
}
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
{
"status": 200,
"message": "Password reset successfully"
}
{
"error": {
"status": 400,
"reason": "Invalid or missing reset token"
}
}
{
"error": {
"status": 401,
"reason": "Reset token has expired"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
Authentication
Reset Password
Reset user password using the token received via email
POST
/
auth
/
reset-password
curl -X POST "https://api.tktchurch.com/v1/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIs...",
"newPassword": "newSecurePassword123"
}'
const resetPassword = async (token, newPassword) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/reset-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ token, newPassword })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
struct ResetPasswordRequest: Encodable {
let token: String
let newPassword: String
}
func resetPassword(token: String, newPassword: String) async throws {
let request = ResetPasswordRequest(
token: token,
newPassword: newPassword
)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/reset-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 resetPassword(
token: "eyJhbGciOiJIUzI1NiIs...",
newPassword: "newSecurePassword123"
)
print("Password reset successfully")
} catch {
print("Failed to reset password: \(error.localizedDescription)")
}
data class ResetPasswordRequest(
val token: String,
val newPassword: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun resetPassword(token: String, newPassword: String) {
val request = ResetPasswordRequest(token, newPassword)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/reset-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 reset password")
}
}
}
}
// Usage
try {
passwordResetService.resetPassword(
"eyJhbGciOiJIUzI1NiIs...",
"newSecurePassword123"
)
println("Password reset successfully")
} catch (e: Exception) {
println("Failed to reset password: ${e.message}")
}
import axios from 'axios';
interface ResetPasswordRequest {
token: string;
newPassword: string;
}
const resetPassword = async (token: string, newPassword: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/reset-password',
{ token, newPassword },
{
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 reset password');
}
throw error;
}
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
{
"status": 200,
"message": "Password reset successfully"
}
{
"error": {
"status": 400,
"reason": "Invalid or missing reset token"
}
}
{
"error": {
"status": 401,
"reason": "Reset token has expired"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
This is a public endpoint that does not require authentication. The reset token from the email is used for verification.
Request Body
string
required
The password reset token received in the email. This is a JWT token containing the user ID.
string
required
The new password for the account. Must meet password requirements.
Response
A successful request returns HTTP 200 OK status, indicating that the password has been successfully updated.Error Responses
object
Common error cases:
- 400 Bad Request: Invalid or missing token
- 400 Bad Request: Password validation failed
- 401 Unauthorized: Expired or invalid token
- 404 Not Found: User not found
curl -X POST "https://api.tktchurch.com/v1/auth/reset-password" \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIs...",
"newPassword": "newSecurePassword123"
}'
const resetPassword = async (token, newPassword) => {
const response = await fetch(
'https://api.tktchurch.com/v1/auth/reset-password',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ token, newPassword })
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
struct ResetPasswordRequest: Encodable {
let token: String
let newPassword: String
}
func resetPassword(token: String, newPassword: String) async throws {
let request = ResetPasswordRequest(
token: token,
newPassword: newPassword
)
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/reset-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 resetPassword(
token: "eyJhbGciOiJIUzI1NiIs...",
newPassword: "newSecurePassword123"
)
print("Password reset successfully")
} catch {
print("Failed to reset password: \(error.localizedDescription)")
}
data class ResetPasswordRequest(
val token: String,
val newPassword: String
)
class PasswordResetService(private val client: OkHttpClient) {
suspend fun resetPassword(token: String, newPassword: String) {
val request = ResetPasswordRequest(token, newPassword)
val requestBody = request.toJson()
.toRequestBody("application/json".toMediaType())
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/reset-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 reset password")
}
}
}
}
// Usage
try {
passwordResetService.resetPassword(
"eyJhbGciOiJIUzI1NiIs...",
"newSecurePassword123"
)
println("Password reset successfully")
} catch (e: Exception) {
println("Failed to reset password: ${e.message}")
}
import axios from 'axios';
interface ResetPasswordRequest {
token: string;
newPassword: string;
}
const resetPassword = async (token: string, newPassword: string): Promise<boolean> => {
try {
const response = await axios.post(
'https://api.tktchurch.com/v1/auth/reset-password',
{ token, newPassword },
{
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 reset password');
}
throw error;
}
};
// Usage
try {
await resetPassword('eyJhbGciOiJIUzI1NiIs...', 'newSecurePassword123');
console.log('Password reset successfully');
} catch (error) {
console.error('Failed to reset password:', error.message);
}
{
"status": 200,
"message": "Password reset successfully"
}
{
"error": {
"status": 400,
"reason": "Invalid or missing reset token"
}
}
{
"error": {
"status": 401,
"reason": "Reset token has expired"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
