curl -X DELETE "https://api.tktchurch.com/v1/auth/devices/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const revokeDevice = async (accessToken, deviceId) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 204;
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
func revokeDevice(accessToken: String, deviceId: UUID) async throws {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/devices/\(deviceId)")!)
urlRequest.httpMethod = "DELETE"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (_, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 204 {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await revokeDevice(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
deviceId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Device revoked successfully")
} catch {
print("Failed to revoke device: \(error.localizedDescription)")
}
class DeviceService(private val client: OkHttpClient) {
suspend fun revokeDevice(accessToken: String, deviceId: String) {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/devices/$deviceId")
.delete()
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to revoke device")
}
}
}
}
// Usage
try {
deviceService.revokeDevice(
"eyJhbGciOiJIUzI1NiIs...", // access token
"123e4567-e89b-12d3-a456-426614174000" // device ID
)
println("Device revoked successfully")
} catch (e: Exception) {
println("Failed to revoke device: ${e.message}")
}
import axios from 'axios';
const revokeDevice = async (accessToken: string, deviceId: string): Promise<void> => {
try {
await axios.delete(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to revoke device');
}
throw error;
}
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
{
"error": {
"status": 400,
"reason": "Invalid device ID format"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "Device not found"
}
}
{
"error": {
"status": 500,
"reason": "Invalid user ID in token"
}
}
Devices
Revoke Device
Revoke access for a specific device, invalidating its tokens
DELETE
/
auth
/
devices
/
{id}
curl -X DELETE "https://api.tktchurch.com/v1/auth/devices/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const revokeDevice = async (accessToken, deviceId) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 204;
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
func revokeDevice(accessToken: String, deviceId: UUID) async throws {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/devices/\(deviceId)")!)
urlRequest.httpMethod = "DELETE"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (_, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 204 {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await revokeDevice(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
deviceId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Device revoked successfully")
} catch {
print("Failed to revoke device: \(error.localizedDescription)")
}
class DeviceService(private val client: OkHttpClient) {
suspend fun revokeDevice(accessToken: String, deviceId: String) {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/devices/$deviceId")
.delete()
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to revoke device")
}
}
}
}
// Usage
try {
deviceService.revokeDevice(
"eyJhbGciOiJIUzI1NiIs...", // access token
"123e4567-e89b-12d3-a456-426614174000" // device ID
)
println("Device revoked successfully")
} catch (e: Exception) {
println("Failed to revoke device: ${e.message}")
}
import axios from 'axios';
const revokeDevice = async (accessToken: string, deviceId: string): Promise<void> => {
try {
await axios.delete(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to revoke device');
}
throw error;
}
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
{
"error": {
"status": 400,
"reason": "Invalid device ID format"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "Device not found"
}
}
{
"error": {
"status": 500,
"reason": "Invalid user ID in token"
}
}
This endpoint requires authentication. Include the JWT access token in the Authorization header.
Path Parameters
string
required
The UUID of the device token to revoke
Response
A successful request returns HTTP 204 No Content status. The following actions are performed:- The device’s refresh token is blacklisted
- Any associated access tokens are blacklisted
- The tokens are removed from the database
Error Responses
object
Common error cases:
- 400 Bad Request: Invalid device ID format
- 401 Unauthorized: Missing or invalid access token
- 404 Not Found: Device not found or belongs to another user
- 500 Internal Server Error: Invalid user ID in token
curl -X DELETE "https://api.tktchurch.com/v1/auth/devices/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
const revokeDevice = async (accessToken, deviceId) => {
const response = await fetch(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.status === 204;
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
func revokeDevice(accessToken: String, deviceId: UUID) async throws {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/devices/\(deviceId)")!)
urlRequest.httpMethod = "DELETE"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
let (_, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 204 {
throw URLError(.badServerResponse)
}
}
// Usage
do {
try await revokeDevice(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
deviceId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Device revoked successfully")
} catch {
print("Failed to revoke device: \(error.localizedDescription)")
}
class DeviceService(private val client: OkHttpClient) {
suspend fun revokeDevice(accessToken: String, deviceId: String) {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/auth/devices/$deviceId")
.delete()
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to revoke device")
}
}
}
}
// Usage
try {
deviceService.revokeDevice(
"eyJhbGciOiJIUzI1NiIs...", // access token
"123e4567-e89b-12d3-a456-426614174000" // device ID
)
println("Device revoked successfully")
} catch (e: Exception) {
println("Failed to revoke device: ${e.message}")
}
import axios from 'axios';
const revokeDevice = async (accessToken: string, deviceId: string): Promise<void> => {
try {
await axios.delete(
`https://api.tktchurch.com/v1/auth/devices/${deviceId}`,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to revoke device');
}
throw error;
}
};
// Usage
try {
await revokeDevice(
'eyJhbGciOiJIUzI1NiIs...', // access token
'123e4567-e89b-12d3-a456-426614174000' // device ID
);
console.log('Device revoked successfully');
} catch (error) {
console.error('Failed to revoke device:', error.message);
}
{
"error": {
"status": 400,
"reason": "Invalid device ID format"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 404,
"reason": "Device not found"
}
}
{
"error": {
"status": 500,
"reason": "Invalid user ID in token"
}
}
