curl -X GET "https://api.tktchurch.com/v1/auth/verify-email?token=eyJhbGciOiJIUzI1NiIs..."
const verifyEmail = async (token) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/verify-email?token=${token}`,
{
method: 'GET'
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
func verifyEmail(token: String) async throws {
guard var urlComponents = URLComponents(string: "https://api.tktchurch.com/v1/auth/verify-email") else {
throw URLError(.badURL)
}
urlComponents.queryItems = [
URLQueryItem(name: "token", value: token)
]
guard let url = urlComponents.url else {
throw URLError(.badURL)
}
var request = URLRequest(url: url)
request.httpMethod = "GET"
let (_, response) = try await URLSession.shared.data(for: request)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
guard httpResponse.statusCode == 200 else {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await verifyEmail(token: "eyJhbGciOiJIUzI1NiIs...")
print("Email verified successfully")
} catch {
print("Verification failed: \(error.localizedDescription)")
}
class EmailVerificationService(private val client: OkHttpClient) {
suspend fun verifyEmail(token: String) {
val url = HttpUrl.Builder()
.scheme("https")
.host("api.tktchurch.com")
.addPathSegments("v1/auth/verify-email")
.addQueryParameter("token", token)
.build()
val request = Request.Builder()
.url(url)
.get()
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Verification failed")
}
}
}
}
// Usage
try {
emailVerificationService.verifyEmail("eyJhbGciOiJIUzI1NiIs...")
println("Email verified successfully")
} catch (e: Exception) {
println("Verification failed: ${e.message}")
}
import axios from 'axios';
const verifyEmail = async (token: string): Promise<boolean> => {
try {
const response = await axios.get(
'https://api.tktchurch.com/v1/auth/verify-email',
{
params: { token }
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Verification failed');
}
throw error;
}
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
{
"status": 200,
"message": "Email verified successfully"
}
{
"error": {
"status": 400,
"reason": "Verification token is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired verification token"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
Authentication
Verify Email
Verify user email address using the token sent via email
GET
/
auth
/
verify-email
curl -X GET "https://api.tktchurch.com/v1/auth/verify-email?token=eyJhbGciOiJIUzI1NiIs..."
const verifyEmail = async (token) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/verify-email?token=${token}`,
{
method: 'GET'
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
func verifyEmail(token: String) async throws {
guard var urlComponents = URLComponents(string: "https://api.tktchurch.com/v1/auth/verify-email") else {
throw URLError(.badURL)
}
urlComponents.queryItems = [
URLQueryItem(name: "token", value: token)
]
guard let url = urlComponents.url else {
throw URLError(.badURL)
}
var request = URLRequest(url: url)
request.httpMethod = "GET"
let (_, response) = try await URLSession.shared.data(for: request)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
guard httpResponse.statusCode == 200 else {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await verifyEmail(token: "eyJhbGciOiJIUzI1NiIs...")
print("Email verified successfully")
} catch {
print("Verification failed: \(error.localizedDescription)")
}
class EmailVerificationService(private val client: OkHttpClient) {
suspend fun verifyEmail(token: String) {
val url = HttpUrl.Builder()
.scheme("https")
.host("api.tktchurch.com")
.addPathSegments("v1/auth/verify-email")
.addQueryParameter("token", token)
.build()
val request = Request.Builder()
.url(url)
.get()
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Verification failed")
}
}
}
}
// Usage
try {
emailVerificationService.verifyEmail("eyJhbGciOiJIUzI1NiIs...")
println("Email verified successfully")
} catch (e: Exception) {
println("Verification failed: ${e.message}")
}
import axios from 'axios';
const verifyEmail = async (token: string): Promise<boolean> => {
try {
const response = await axios.get(
'https://api.tktchurch.com/v1/auth/verify-email',
{
params: { token }
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Verification failed');
}
throw error;
}
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
{
"status": 200,
"message": "Email verified successfully"
}
{
"error": {
"status": 400,
"reason": "Verification token is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired verification token"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
This is a public endpoint that does not require authentication. The verification token in the URL is sufficient for verification.
Query Parameters
string
required
The verification token received in the email. This is a JWT token containing the user ID.
Response
A successful request returns HTTP 200 OK status, indicating that the email has been verified. The user’semailVerified status will be updated to true in the database.
Error Responses
object
Common error cases:
- 400 Bad Request: Missing verification token
- 401 Unauthorized: Invalid or expired token
- 404 Not Found: User not found
curl -X GET "https://api.tktchurch.com/v1/auth/verify-email?token=eyJhbGciOiJIUzI1NiIs..."
const verifyEmail = async (token) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/verify-email?token=${token}`,
{
method: 'GET'
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 200;
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
func verifyEmail(token: String) async throws {
guard var urlComponents = URLComponents(string: "https://api.tktchurch.com/v1/auth/verify-email") else {
throw URLError(.badURL)
}
urlComponents.queryItems = [
URLQueryItem(name: "token", value: token)
]
guard let url = urlComponents.url else {
throw URLError(.badURL)
}
var request = URLRequest(url: url)
request.httpMethod = "GET"
let (_, response) = try await URLSession.shared.data(for: request)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
guard httpResponse.statusCode == 200 else {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await verifyEmail(token: "eyJhbGciOiJIUzI1NiIs...")
print("Email verified successfully")
} catch {
print("Verification failed: \(error.localizedDescription)")
}
class EmailVerificationService(private val client: OkHttpClient) {
suspend fun verifyEmail(token: String) {
val url = HttpUrl.Builder()
.scheme("https")
.host("api.tktchurch.com")
.addPathSegments("v1/auth/verify-email")
.addQueryParameter("token", token)
.build()
val request = Request.Builder()
.url(url)
.get()
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Verification failed")
}
}
}
}
// Usage
try {
emailVerificationService.verifyEmail("eyJhbGciOiJIUzI1NiIs...")
println("Email verified successfully")
} catch (e: Exception) {
println("Verification failed: ${e.message}")
}
import axios from 'axios';
const verifyEmail = async (token: string): Promise<boolean> => {
try {
const response = await axios.get(
'https://api.tktchurch.com/v1/auth/verify-email',
{
params: { token }
}
);
return response.status === 200;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Verification failed');
}
throw error;
}
};
// Usage
try {
await verifyEmail('eyJhbGciOiJIUzI1NiIs...');
console.log('Email verified successfully');
} catch (error) {
console.error('Verification failed:', error.message);
}
{
"status": 200,
"message": "Email verified successfully"
}
{
"error": {
"status": 400,
"reason": "Verification token is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired verification token"
}
}
{
"error": {
"status": 404,
"reason": "User not found"
}
}
