Logs Api
Logs API - Access App Activity and Security Logs
Learn how to retrieve and monitor various types of logs from your Tadabase application including login attempts, page views, emails, sessions, and security events via the REST API.
What are Logs?
Logs in Tadabase track various activities in your application including user authentication, page views, email delivery, security events, and builder activities. The Logs API provides programmatic access to this data for monitoring, analytics, and compliance purposes.
API Key Permission Required
Your API key must have the allow_log permission enabled to access log endpoints. This permission must be enabled in your API key settings within the Tadabase builder.
Authentication
All log endpoints require standard Tadabase API authentication headers:
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Pagination
All log endpoints support pagination to handle large datasets efficiently:
- Default limit: 50 items per page
- Page parameter:
?page=1(starts at 1) - Response includes:
total_items,total_pages,page
Failed Login Attempts
Retrieve records of failed login attempts to monitor security and identify potential threats.
GET /api/v1/logs/failed-logins?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 5,
"total_items": 243,
"items": [
{
"created_at": "2024-01-28 14:23:15",
"username": "user@example.com",
"ip": "192.168.1.100",
"city": "San Francisco",
"state": "California",
"country": "United States",
"platform": "Windows",
"browser": "Chrome 120.0",
"device": "Desktop",
"device_type": "desktop"
}
]
}
Failed Login Properties
| Property | Description |
|---|---|
created_at |
Timestamp of failed login attempt |
username |
Username/email attempted |
ip |
IP address of the attempt |
city |
City from IP geolocation |
state |
State/province from IP geolocation |
country |
Country from IP geolocation |
platform |
Operating system (Windows, macOS, iOS, Android) |
browser |
Browser name and version |
device |
Device name or type |
device_type |
Device category (desktop, mobile, tablet) |
Successful Logins
Track successful user authentication events with detailed location and device information.
GET /api/v1/logs/logins?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 12,
"total_items": 587,
"items": [
{
"email": "user@example.com",
"name": "John Doe",
"type": "Login",
"created_at": "2024-01-28 09:15:42",
"address": "123 Main St",
"address2": "Apt 4B",
"city": "New York",
"state": "New York",
"country": "United States",
"zip": "10001",
"latitude": "40.7128",
"longitude": "-74.0060",
"ip": "192.168.1.50",
"platform": "macOS",
"browser": "Safari 17.2",
"device": "Macintosh",
"device_type": "desktop"
}
]
}
Login Properties
| Property | Description |
|---|---|
email |
User's email address |
name |
User's full name |
type |
Login type (Login, Auto-login, etc.) |
created_at |
Login timestamp |
address |
Street address from IP geolocation |
city |
City from IP geolocation |
state |
State/province |
country |
Country name |
zip |
Postal code |
latitude |
Geographic latitude |
longitude |
Geographic longitude |
ip |
IP address |
platform |
Operating system |
browser |
Browser name and version |
device |
Device name |
device_type |
Device category |
Page Views
Monitor user activity and page navigation throughout your application.
GET /api/v1/logs/page-views?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 45,
"total_items": 2234,
"items": [
{
"url": "/dashboard",
"data_type_id": "page_abc123",
"page_id": "page_abc123",
"created_at": "2024-01-28 10:30:15",
"ip": "192.168.1.75",
"app_user_id": "encoded_user_id",
"browser": "Chrome 120.0",
"user": {
"name": "Jane Smith",
"email": "jane@example.com"
}
},
{
"url": "/reports",
"data_type_id": "page_def456",
"page_id": "page_def456",
"created_at": "2024-01-28 10:28:42",
"ip": "192.168.1.80",
"app_user_id": "",
"browser": "Firefox 121.0",
"user": {
"name": "Not Logged in"
}
}
]
}
Page View Properties
| Property | Description |
|---|---|
url |
Page URL path |
data_type_id |
Internal page identifier |
page_id |
Encoded page identifier |
created_at |
View timestamp |
ip |
Visitor IP address |
app_user_id |
Encoded user ID (empty if not logged in) |
browser |
Browser name and version |
user |
User object with name and email (or "Not Logged in"/"User Deleted") |
Email Logs
Track all emails sent from your application including delivery status and content.
GET /api/v1/logs/emails?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 8,
"total_items": 392,
"items": [
{
"unique_id": "12345",
"created_at": "2024-01-28 11:45:30",
"to": "recipient@example.com,recipient2@example.com",
"subject": "Welcome to Our App",
"status": "Sent",
"body": "...",
"from_email": "noreply@myapp.com",
"from_name": "My Application",
"browser": "Chrome 120.0",
"ip": "192.168.1.100"
}
]
}
Email Properties
| Property | Description |
|---|---|
unique_id |
Unique email log identifier |
created_at |
Email sent timestamp |
to |
Comma-separated list of recipients |
subject |
Email subject line |
status |
Delivery status (Sent, Failed, Pending) |
body |
Email HTML content |
from_email |
Sender email address |
from_name |
Sender display name |
browser |
Browser that triggered the email |
ip |
IP address that triggered the email |
Active Sessions
View currently active user sessions in your application.
GET /api/v1/logs/sessions?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 2,
"total_items": 87,
"items": [
{
"email": "user@example.com",
"name": "John Doe",
"created_at": "2024-01-28 08:00:00",
"expire_at": "2024-01-28 21:00:00",
"last_active_at": "2024-01-28 14:30:22",
"browser": "Chrome 120.0",
"ip": "192.168.1.50"
}
]
}
Session Filtering
The sessions endpoint only returns sessions created within the last 13 hours that have not expired. This provides a real-time view of active users in your application.
Session Properties
| Property | Description |
|---|---|
email |
User's email address |
name |
User's full name |
created_at |
Session start time |
expire_at |
Session expiration time |
last_active_at |
Last activity timestamp |
browser |
Browser name and version |
ip |
User's IP address |
Blocked Users
Retrieve information about users who have been blocked from accessing your application.
GET /api/v1/logs/blocked-users?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 1,
"total_items": 15,
"items": [
{
"type": "Manual",
"created_at": "2024-01-27 15:30:00",
"username": "suspicious@example.com",
"start_at": "2024-01-27 15:30:00",
"end_at": "2024-02-27 15:30:00",
"status": "Blocked"
}
]
}
Blocked User Properties
| Property | Description |
|---|---|
type |
Block type (Manual, Automatic, etc.) |
created_at |
When the block was created |
username |
Blocked username/email |
start_at |
Block start time |
end_at |
Block expiration time (if temporary) |
status |
Current status (Blocked, Unblocked) |
Blocked IP Addresses
Monitor IP addresses that have been blocked from accessing your application.
GET /api/v1/logs/blocked-ips?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 1,
"total_items": 23,
"items": [
{
"type": "Automatic",
"created_at": "2024-01-28 12:00:00",
"username": "192.168.1.200",
"start_at": "2024-01-28 12:00:00",
"end_at": "2024-01-28 18:00:00",
"status": "Blocked"
}
]
}
Blocked IP Properties
| Property | Description |
|---|---|
type |
Block type (Automatic from failed logins, Manual) |
created_at |
When the block was created |
username |
Blocked IP address |
start_at |
Block start time |
end_at |
Block expiration time |
status |
Current status (Blocked, Unblocked) |
Builder Activities
Track activities performed in the Tadabase builder interface for audit and compliance purposes.
GET /api/v1/logs/builder-activities?page=1
Headers:
X-Tadabase-App-id: your_app_id
X-Tadabase-App-Key: your_app_key
X-Tadabase-App-Secret: your_app_secret
Response
{
"type": "success",
"page": 1,
"total_pages": 15,
"total_items": 732,
"items": [
{
"type": "Page Created",
"created_at": "2024-01-28 13:20:45",
"ip": "192.168.1.100",
"user": {
"name": "Admin User",
"email": "admin@example.com"
},
"metas": [
{
"name": "page_name",
"val": "New Dashboard"
},
{
"name": "page_id",
"val": "page_xyz123"
}
]
}
]
}
Builder Activity Properties
| Property | Description |
|---|---|
type |
Activity type (Page Created, Field Updated, etc.) |
created_at |
Activity timestamp |
ip |
IP address of the builder user |
user |
Builder user object with name and email |
metas |
Array of metadata key-value pairs with activity details |
Example: Security Dashboard
// Monitor security events across multiple log types
async function getSecurityDashboard() {
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
// Get failed logins
const failedLogins = await fetch(
'https://api.tadabase.io/api/v1/logs/failed-logins',
{ headers }
).then(r => r.json());
// Get blocked IPs
const blockedIps = await fetch(
'https://api.tadabase.io/api/v1/logs/blocked-ips',
{ headers }
).then(r => r.json());
// Get blocked users
const blockedUsers = await fetch(
'https://api.tadabase.io/api/v1/logs/blocked-users',
{ headers }
).then(r => r.json());
return {
failedLogins: failedLogins.items,
failedLoginCount: failedLogins.total_items,
blockedIps: blockedIps.items,
blockedIpCount: blockedIps.total_items,
blockedUsers: blockedUsers.items,
blockedUserCount: blockedUsers.total_items,
securityScore: calculateSecurityScore(failedLogins, blockedIps)
};
}
function calculateSecurityScore(failedLogins, blockedIps) {
// Example security score calculation
const recentFailedLogins = failedLogins.items.filter(log => {
const logDate = new Date(log.created_at);
const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
return logDate > dayAgo;
}).length;
if (recentFailedLogins === 0) return 'Excellent';
if (recentFailedLogins
Example: Email Delivery Monitor
// Monitor email delivery status and identify failures
async function monitorEmailDelivery(hoursToCheck = 24) {
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
let page = 1;
let allEmails = [];
let hasMorePages = true;
// Fetch all email logs
while (hasMorePages) {
const response = await fetch(
`https://api.tadabase.io/api/v1/logs/emails?page=${page}`,
{ headers }
);
const data = await response.json();
allEmails = allEmails.concat(data.items);
if (page >= data.total_pages) {
hasMorePages = false;
}
page++;
}
// Filter to recent timeframe
const cutoffTime = new Date(Date.now() - hoursToCheck * 60 * 60 * 1000);
const recentEmails = allEmails.filter(email => {
return new Date(email.created_at) > cutoffTime;
});
// Calculate statistics
const stats = {
total: recentEmails.length,
sent: recentEmails.filter(e => e.status === 'Sent').length,
failed: recentEmails.filter(e => e.status === 'Failed').length,
pending: recentEmails.filter(e => e.status === 'Pending').length,
deliveryRate: 0
};
stats.deliveryRate = stats.total > 0
? Math.round((stats.sent / stats.total) * 100)
: 0;
return {
stats,
failedEmails: recentEmails.filter(e => e.status === 'Failed')
};
}
// Usage
const emailReport = await monitorEmailDelivery(24);
console.log(`Email Delivery Rate: ${emailReport.stats.deliveryRate}%`);
console.log(`Failed Emails: ${emailReport.stats.failed}`);
if (emailReport.failedEmails.length > 0) {
console.log('Failed Email Details:');
emailReport.failedEmails.forEach(email => {
console.log(` To: ${email.to}, Subject: ${email.subject}`);
});
}
Example: Active Users Monitor
// Get currently active users and their session info
async function getActiveUsers() {
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
const response = await fetch(
'https://api.tadabase.io/api/v1/logs/sessions',
{ headers }
);
const data = await response.json();
// Process active sessions
const activeUsers = data.items.map(session => {
const lastActive = new Date(session.last_active_at);
const minutesAgo = Math.floor((Date.now() - lastActive) / 60000);
return {
name: session.name,
email: session.email,
browser: session.browser,
ip: session.ip,
minutesSinceActive: minutesAgo,
isIdle: minutesAgo > 15
};
});
return {
total: data.total_items,
activeNow: activeUsers.filter(u => !u.isIdle).length,
idle: activeUsers.filter(u => u.isIdle).length,
users: activeUsers
};
}
// Usage
const activeUsers = await getActiveUsers();
console.log(`Total Active Sessions: ${activeUsers.total}`);
console.log(`Currently Active: ${activeUsers.activeNow}`);
console.log(`Idle Users: ${activeUsers.idle}`);
Example: Page Analytics
// Analyze page view patterns
async function analyzePageViews(pages = 3) {
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
let allViews = [];
// Fetch multiple pages of views
for (let page = 1; page {
urlCounts[view.url] = (urlCounts[view.url] || 0) + 1;
});
// Get top pages
const topPages = Object.entries(urlCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 10)
.map(([url, count]) => ({ url, views: count }));
// Count logged in vs anonymous
const loggedInViews = allViews.filter(v => v.app_user_id).length;
const anonymousViews = allViews.length - loggedInViews;
return {
totalViews: allViews.length,
topPages,
loggedInViews,
anonymousViews,
loggedInPercentage: Math.round((loggedInViews / allViews.length) * 100)
};
}
// Usage
const analytics = await analyzePageViews(5);
console.log('Page View Analytics:');
console.log(`Total Views: ${analytics.totalViews}`);
console.log(`Logged In: ${analytics.loggedInPercentage}%`);
console.log('\nTop Pages:');
analytics.topPages.forEach((page, i) => {
console.log(`${i + 1}. ${page.url} - ${page.views} views`);
});
Example: Comprehensive Log Manager Class
class TadabaseLogManager {
constructor(appId, appKey, appSecret) {
this.headers = {
'X-Tadabase-App-id': appId,
'X-Tadabase-App-Key': appKey,
'X-Tadabase-App-Secret': appSecret
};
this.baseUrl = 'https://api.tadabase.io/api/v1/logs';
}
async fetchLog(logType, page = 1) {
const response = await fetch(
`${this.baseUrl}/${logType}?page=${page}`,
{ headers: this.headers }
);
const data = await response.json();
if (data.type === 'error') {
throw new Error(`Failed to fetch ${logType}: ${data.msg}`);
}
return data;
}
async fetchAllPages(logType, maxPages = null) {
let page = 1;
let allItems = [];
let hasMorePages = true;
while (hasMorePages) {
const data = await this.fetchLog(logType, page);
allItems = allItems.concat(data.items);
if (page >= data.total_pages || (maxPages && page >= maxPages)) {
hasMorePages = false;
}
page++;
}
return allItems;
}
async getFailedLogins(page = 1) {
return await this.fetchLog('failed-logins', page);
}
async getLogins(page = 1) {
return await this.fetchLog('logins', page);
}
async getPageViews(page = 1) {
return await this.fetchLog('page-views', page);
}
async getEmails(page = 1) {
return await this.fetchLog('emails', page);
}
async getSessions(page = 1) {
return await this.fetchLog('sessions', page);
}
async getBlockedUsers(page = 1) {
return await this.fetchLog('blocked-users', page);
}
async getBlockedIps(page = 1) {
return await this.fetchLog('blocked-ips', page);
}
async getBuilderActivities(page = 1) {
return await this.fetchLog('builder-activities', page);
}
async getSecuritySummary() {
const [failedLogins, blockedIps, blockedUsers] = await Promise.all([
this.getFailedLogins(),
this.getBlockedIps(),
this.getBlockedUsers()
]);
return {
failedLoginCount: failedLogins.total_items,
blockedIpCount: blockedIps.total_items,
blockedUserCount: blockedUsers.total_items,
recentFailedLogins: failedLogins.items
};
}
async getActivitySummary() {
const [pageViews, sessions, logins] = await Promise.all([
this.getPageViews(),
this.getSessions(),
this.getLogins()
]);
return {
totalPageViews: pageViews.total_items,
activeSessions: sessions.total_items,
totalLogins: logins.total_items,
recentViews: pageViews.items.slice(0, 10)
};
}
}
// Usage
const logManager = new TadabaseLogManager(
'your_app_id',
'your_app_key',
'your_app_secret'
);
// Get failed logins
const failedLogins = await logManager.getFailedLogins();
console.log('Failed Logins:', failedLogins);
// Get security summary
const securitySummary = await logManager.getSecuritySummary();
console.log('Security Summary:', securitySummary);
// Get all emails (first 5 pages)
const allEmails = await logManager.fetchAllPages('emails', 5);
console.log(`Fetched ${allEmails.length} email logs`);
// Get activity summary
const activitySummary = await logManager.getActivitySummary();
console.log('Activity Summary:', activitySummary);
Error Handling
async function fetchLogsWithErrorHandling(logType, page = 1) {
const headers = {
'X-Tadabase-App-id': 'your_app_id',
'X-Tadabase-App-Key': 'your_app_key',
'X-Tadabase-App-Secret': 'your_app_secret'
};
try {
const response = await fetch(
`https://api.tadabase.io/api/v1/logs/${logType}?page=${page}`,
{ headers }
);
const data = await response.json();
if (data.type === 'error') {
// Check for specific error types
if (data.msg.includes('not allowed')) {
console.error('API key missing "allow_log" permission');
console.error('Enable this permission in your API key settings');
} else {
console.error('API Error:', data.msg);
}
return null;
}
return data;
} catch (error) {
console.error('Network or parsing error:', error.message);
return null;
}
}
// Usage
const logs = await fetchLogsWithErrorHandling('failed-logins');
if (logs) {
console.log('Successfully fetched logs:', logs);
}
Best Practices
- Enable log permissions: Ensure your API key has
allow_logpermission enabled - Use pagination wisely: Don't fetch all pages if you only need recent data
- Cache results: Log data doesn't change retroactively, cache historical data
- Monitor security logs: Regularly check failed logins and blocked IPs for threats
- Track email delivery: Monitor email logs to ensure critical notifications are delivered
- Respect rate limits: Log API calls count toward your rate limits
- Filter client-side: Fetch data in chunks and filter on your side for complex queries
- Archive old logs: Periodically export and archive log data for long-term storage
- Set up alerts: Create automated alerts for unusual security patterns
- Audit builder activities: Use builder activity logs for compliance and auditing
Common Use Cases
Security Monitoring
Track failed login attempts, blocked IPs, and suspicious activity patterns to protect your application.
Compliance and Auditing
Use builder activity logs and email logs to maintain audit trails for regulatory compliance.
User Analytics
Analyze page views and session data to understand user behavior and improve UX.
Email Delivery Monitoring
Track email delivery success rates and identify delivery issues before they impact users.
Active User Monitoring
Monitor current sessions to understand peak usage times and concurrent user counts.
Rate Limits and Permissions
Important Considerations
- Log API endpoints require the
allow_logpermission on your API key - This permission must be enabled in addition to
allow_api_access - All log API calls count toward your application's rate limits
- Plan limits may restrict access to certain log types
Next Steps
Learn how to work with other monitoring features:
→ Status API - Check application status and health
→ Tasks API - Monitor task execution logs
→ Automations API - Track automation activity
We'd love to hear your feedback.