Guides
Strata Documentation
Navigate faster with curated quickstarts. Switch between Guides, API Reference, and Changelog without getting lost.
Coreline Documentation
Complete guide to using the Coreline workspace platform and integrating with our API.
Coreline is a comprehensive workspace management platform designed for Roblox communities. This documentation covers both the web interface features and the complete API reference for building integrations.
What You'll Find Here
- Getting Started: Learn authentication, rate limits, and best practices
- How-To Guides: Step-by-step tutorials for common integration tasks
- Workspace Features: Complete guide to all dashboard features
- API Reference: Detailed documentation for all endpoints
Authentication
All API requests require authentication using API keys. Each server/integration gets its own unique API key.
Getting Your API Key
- 1. Navigate to Workspace Admin in the dashboard
- 2. Go to the API Keys section
- 3. Click "Generate New Key" and provide a name (e.g., "Discord Bot")
- 4. Copy the key immediately - it won't be shown again
- 5. Store it securely in your environment variables
Using Your API Key
Include your API key in the Authorization header of every request:
Authorization: Bearer your_api_key_hereIt's also recommended to include an X-Source header to identify your integration:
X-Source: discord-botExample Request
fetch('https://yoursite.com/api/staff/overview', {
headers: {
'Authorization': 'Bearer your_api_key_here',
'X-Source': 'discord-bot'
}
})Rate Limits
To ensure fair usage and system stability, API requests are rate limited:
Standard Endpoints
60 requests per minute
Burst Limit
100 requests per 10 seconds
Rate Limit Headers
Every API response includes rate limit information in headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1640995200Handling Rate Limits
If you exceed the rate limit, you'll receive a 429 Too Many Requests response:
{
"error": "Rate limit exceeded",
"retryAfter": 30
}Best Practices
Security
- • Never commit API keys to version control
- • Store keys in environment variables
- • Rotate keys periodically
- • Use separate keys for different environments (dev/prod)
- • Revoke keys immediately if compromised
Performance
- • Cache responses when possible
- • Use query parameters to filter data
- • Implement exponential backoff for retries
- • Monitor your rate limit usage
- • Batch requests when appropriate
Error Handling
- • Always check response status codes
- • Implement proper error logging
- • Handle network failures gracefully
- • Validate response data before using it
- • Provide meaningful error messages to users
Quick Start
Get started with the Coreline API in under 5 minutes.
Step 1: Get Your API Key
Navigate to Workspace Admin → API Keys and generate a new key.
Step 2: Make Your First Request
// Node.js example
const API_KEY = process.env.CORELINE_API_KEY;
const BASE_URL = 'https://yoursite.com/api';
async function getStaffOverview() {
const response = await fetch(`${BASE_URL}/staff/overview`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-integration'
}
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log('Top performers:', data.topPerformers);
console.log('Total staff:', data.totalStaff);
}
getStaffOverview();Step 3: Handle Errors
async function apiRequest(endpoint) {
try {
const response = await fetch(`${BASE_URL}${endpoint}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-integration'
}
});
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After');
console.log(`Rate limited. Retry after ${retryAfter}s`);
return null;
}
if (!response.ok) {
const error = await response.json();
console.error('API Error:', error);
return null;
}
return await response.json();
} catch (error) {
console.error('Network error:', error);
return null;
}
}Discord Bot Integration
Learn how to integrate Coreline with your Discord bot to display staff data, sessions, and more.
Display Staff Leaderboard
// Discord.js example - Staff leaderboard command
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'leaderboard') {
const response = await fetch('https://yoursite.com/api/staff/overview', {
headers: {
'Authorization': `Bearer ${process.env.CORELINE_API_KEY}`,
'X-Source': 'discord-bot'
}
});
const data = await response.json();
const embed = {
title: '🏆 Staff Leaderboard',
description: 'Top performers this week',
color: 0x5865F2,
fields: data.topPerformers.slice(0, 10).map((staff, index) => ({
name: `${index + 1}. ${staff.displayName}`,
value: `**Minutes:** ${staff.totalMinutes} | **Sessions:** ${staff.totalSessions}`,
inline: false
})),
footer: { text: `Total Staff: ${data.totalStaff}` },
timestamp: new Date().toISOString()
};
await interaction.reply({ embeds: [embed] });
}
});Show User Activity
// Show activity for a specific user
async function showUserActivity(userId) {
const response = await fetch(
`https://yoursite.com/api/activity/overview?userId=${userId}&period=weekly`,
{
headers: {
'Authorization': `Bearer ${process.env.CORELINE_API_KEY}`,
'X-Source': 'discord-bot'
}
}
);
const data = await response.json();
const embed = {
title: '📊 Activity Overview',
color: 0x5865F2,
fields: [
{
name: 'Active Time',
value: `${data.aggregate.activeMinutes} minutes`,
inline: true
},
{
name: 'Sessions Hosted',
value: data.aggregate.sessionsHosted.toString(),
inline: true
},
{
name: 'Sessions Attended',
value: data.aggregate.sessionsAttended.toString(),
inline: true
},
{
name: 'Weekly Quota',
value: `${data.quotas.weekly.completed}/${data.quotas.weekly.required} minutes (${data.quotas.weekly.percentage}%)`,
inline: false
}
],
timestamp: new Date().toISOString()
};
return embed;
}Upcoming Sessions
// Get and display upcoming sessions
async function getUpcomingSessions() {
const now = new Date();
const endOfDay = new Date();
endOfDay.setHours(23, 59, 59, 999);
const params = new URLSearchParams({
startAfter: now.toISOString(),
startBefore: endOfDay.toISOString()
});
const response = await fetch(
`https://yoursite.com/api/sessions?${params}`,
{
headers: {
'Authorization': `Bearer ${process.env.CORELINE_API_KEY}`,
'X-Source': 'discord-bot'
}
}
);
const data = await response.json();
if (data.sessions.length === 0) {
return { content: 'No upcoming sessions today.' };
}
const embed = {
title: '📅 Upcoming Sessions Today',
color: 0x5865F2,
fields: data.sessions.map(session => ({
name: session.name,
value: `**Host:** ${session.hostUsername || 'Unclaimed'}\n**Time:** <t:${Math.floor(new Date(session.startTimeUtc).getTime() / 1000)}:t>\n**Status:** ${session.status}`,
inline: true
})),
footer: { text: `${data.sessions.length} session(s)` },
timestamp: new Date().toISOString()
};
return { embeds: [embed] };
}Session Tracking
Learn how to track and monitor sessions programmatically.
Fetching Sessions
Use the sessions API to get scheduled sessions with optional time-based filtering:
// Get all sessions for today
const startOfDay = new Date();
startOfDay.setHours(0, 0, 0, 0);
const endOfDay = new Date();
endOfDay.setHours(23, 59, 59, 999);
const params = new URLSearchParams({
startAfter: startOfDay.toISOString(),
startBefore: endOfDay.toISOString()
});
const response = await fetch(`https://yoursite.com/api/sessions?${params}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'session-tracker'
}
});
const data = await response.json();
console.log(`Found ${data.sessions.length} sessions today`);Monitoring Active Sessions
// Poll for active sessions every minute
setInterval(async () => {
const response = await fetch('https://yoursite.com/api/sessions', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'session-monitor'
}
});
const data = await response.json();
const activeSessions = data.sessions.filter(s => s.status === 'active');
if (activeSessions.length > 0) {
console.log(`Active sessions: ${activeSessions.map(s => s.name).join(', ')}`);
}
}, 60000); // Check every minuteActivity Monitoring
Track user activity, quotas, and performance metrics.
Get User Activity
async function getUserActivity(userId, period = 'weekly') {
const response = await fetch(
`https://yoursite.com/api/activity/overview?userId=${userId}&period=${period}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'activity-monitor'
}
}
);
const data = await response.json();
return {
activeMinutes: data.aggregate.activeMinutes,
sessionsHosted: data.aggregate.sessionsHosted,
sessionsAttended: data.aggregate.sessionsAttended,
weeklyQuota: data.quotas.weekly,
monthlyQuota: data.quotas.monthly,
recentSessions: data.recentSessions
};
}Check Quota Compliance
async function checkQuotaCompliance(userId) {
const activity = await getUserActivity(userId, 'weekly');
const isCompliant = activity.weeklyQuota.percentage >= 100;
const shortfall = isCompliant
? 0
: activity.weeklyQuota.required - activity.weeklyQuota.completed;
return {
isCompliant,
shortfall,
percentage: activity.weeklyQuota.percentage,
completed: activity.weeklyQuota.completed,
required: activity.weeklyQuota.required
};
}Staff Management
Access and manage staff directory data programmatically.
Get Staff Overview
async function getStaffOverview() {
const response = await fetch('https://yoursite.com/api/staff/overview', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'staff-manager'
}
});
const data = await response.json();
return {
totalStaff: data.totalStaff,
activeToday: data.activeToday,
topPerformers: data.topPerformers,
recentActivity: data.recentActivity,
departmentBreakdown: data.departmentBreakdown
};
}Search Staff Directory
async function searchStaff(searchTerm, department = null) {
const params = new URLSearchParams({
search: searchTerm,
sortBy: 'name',
sortOrder: 'asc'
});
if (department) {
params.append('department', department);
}
const response = await fetch(
`https://yoursite.com/api/staff/directory?${params}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'staff-search'
}
}
);
const data = await response.json();
return data.directory;
}Get Staff Profile
async function getStaffProfile(userId) {
const response = await fetch(
`https://yoursite.com/api/staff/profile?userId=${userId}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'profile-viewer'
}
}
);
const data = await response.json();
return {
user: data.user,
metrics: data.metrics,
quotas: data.quotas,
recentSessions: data.recentSessions,
rank: data.rank
};
}Building Dashboards
Create custom dashboards and analytics using the Coreline API.
Real-Time Activity Dashboard
// React example - Real-time activity dashboard
import { useEffect, useState } from 'react';
function ActivityDashboard() {
const [overview, setOverview] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchData() {
const response = await fetch('/api/staff/overview', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'web-dashboard'
}
});
const data = await response.json();
setOverview(data);
setLoading(false);
}
fetchData();
const interval = setInterval(fetchData, 60000); // Refresh every minute
return () => clearInterval(interval);
}, []);
if (loading) return <div>Loading...</div>;
return (
<div className="dashboard">
<div className="stat-card">
<h3>Total Staff</h3>
<p>{overview.totalStaff}</p>
</div>
<div className="stat-card">
<h3>Active Today</h3>
<p>{overview.activeToday}</p>
</div>
{/* More stats... */}
</div>
);
}Performance Analytics
// Analyze performance trends
async function analyzePerformanceTrends(userId) {
const periods = ['daily', 'weekly', 'monthly'];
const trends = {};
for (const period of periods) {
const response = await fetch(
`https://yoursite.com/api/activity/overview?userId=${userId}&period=${period}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'analytics'
}
}
);
const data = await response.json();
trends[period] = {
activeMinutes: data.aggregate.activeMinutes,
quotaPercentage: data.quotas[period]?.percentage || 0,
sessions: data.aggregate.sessionsHosted + data.aggregate.sessionsAttended
};
}
return trends;
}Dashboard Overview
The Dashboard is your central hub for monitoring workspace activity and performance. It provides real-time insights into staff performance, upcoming sessions, and key metrics.
Key Performance Indicators (KPIs)
- Total Staff: Number of staff members in your workspace
- Active Today: Staff members who have logged activity today
- Total Sessions: All scheduled sessions across all time
- Active Sessions: Currently ongoing sessions
Widgets
Top Performers
Shows the highest-performing staff members based on total active minutes, sessions hosted, and quota completion percentage.
Upcoming Sessions
Displays the next scheduled sessions with host information and start times.
Recent Activity
Timeline of recent workspace activity including sessions, messages, and staff actions.
Sessions
Sessions are scheduled events where staff members participate in various activities. The Sessions page allows you to view, create, and manage all workspace sessions.
Features
- 24-Hour View: See all sessions scheduled for the selected day across all 24 hours
- Session Status: Track whether sessions are upcoming, active, completed, or cancelled
- Host Management: Claim or assign sessions to specific hosts
- Server Assignment: Link sessions to specific Roblox server instances
- Attendance Tracking: Monitor who attends each session
Session Types
Sessions can be customized using presets that define the type of event:
- • Training Sessions
- • Shift Coverage
- • Special Events
- • Team Meetings
- • Custom Presets
Activity Tracking
Activity Tracking monitors all staff actions and participation across your workspace. This includes session attendance, active time, idle time, and various engagement metrics.
Metrics Tracked
- Active Minutes: Time spent actively participating
- Idle Minutes: Time spent idle but present
- Sessions Hosted: Number of sessions led by the user
- Sessions Attended: Number of sessions participated in
- Messages: Chat messages and interactions
Time Periods
View activity data across different time periods:
- • Daily - Last 24 hours
- • Weekly - Last 7 days
- • Monthly - Last 30 days
Quotas
Coming soonQuotas will define minimum activity requirements for staff members. This feature is under active development; the API and UI are not yet available in production.
Quota Types
Weekly Quota
Minimum active minutes required per week.
Monthly Quota
Minimum active minutes required per month.
Quota Management
Planned capabilities (not live yet):
- Rank-Based: Different quotas for different ranks
- Auto-Tracking: Automatically calculated from activity data
- Progress Indicators: Visual feedback on quota completion
- Exemptions: LOA and special exemptions supported
Staff Directory
The Staff Directory provides a comprehensive view of all workspace members with their profiles, roles, performance metrics, and contact information.
Features
- Search & Filter: Find staff by name, department, or role
- Performance Metrics: See total minutes, sessions, and quota completion
- Department Organization: Browse by department hierarchy
- Profile Links: Direct links to Roblox profiles
- Avatar Headshots: Visual identification with Roblox avatars
Departments
- • Executive (Rank 254+)
- • Management (Rank 200-253)
- • Operations (Rank 100-199)
- • Department Leads (Rank 50-99)
- • Staff (Rank 17-49)
Wall & Discussions
The Wall is a communication hub where staff can post updates, announcements, and engage in discussions. Think of it as an internal social feed for your workspace.
Features
- Post Updates: Share announcements and news with all staff
- Comments: Discuss and reply to posts
- Rich Content: Support for text formatting and links
- Pinned Posts: Keep important announcements at the top
- Moderation: Edit or remove posts as needed
Notices
Notices are official announcements and alerts that appear at the top of the dashboard. Use them for important workspace-wide communications.
Notice Types
Info
General information and updates
Warning
Important notices requiring attention
Alert
Critical announcements and urgent matters
Success
Positive updates and achievements
Leave (LOA)
Leave of Absence (LOA) management allows staff to formally request time off with automatic quota exemptions during their absence.
Features
- Request Management: Submit and track leave requests
- Approval Workflow: Managers can approve or deny requests
- Quota Exemption: Automatic exemption from quotas during leave
- Leave History: View past and current leave periods
- Duration Tracking: Specify start and end dates
Leave Types
- • Vacation
- • Medical
- • Personal
- • Emergency
- • Extended Leave
Alliances
Manage partnerships and alliances with other Roblox groups. Track alliance members, permissions, and collaborative activities.
Features
- Alliance Registry: List of all partner groups
- Member Access: Grant permissions to alliance members
- Activity Tracking: Monitor alliance participation
- Contact Management: Store alliance leadership contacts
Policies
The Policies section contains all workspace rules, guidelines, and standard operating procedures that staff members need to follow.
Features
- Document Library: Organized collection of all policies
- Version Control: Track policy updates and changes
- Search: Quickly find relevant policies
- Categories: Organize by department or topic
- Required Reading: Mark policies as mandatory
Workspace Admin
Workspace Admin is the control center for managing your workspace settings, API keys, permissions, and advanced configurations.
Features
- API Key Management: Generate, rotate, and revoke API keys
- Permission Settings: Configure rank-based permissions
- Quota Configuration: Set minimum activity requirements
- Integration Settings: Configure external integrations
- Audit Logs: Review system and admin actions
- Workspace Settings: General configuration and branding
⚠️ Admin Only: This section requires Workspace Admin permission (Rank 254+)
Authentication API
API authentication uses Bearer tokens. All endpoints require a valid API key in the Authorization header.
Header Format
Authorization: Bearer your_api_key_here
X-Source: your-integration-nameResponse Codes
200Success - Request completed401Unauthorized - Invalid or missing API key403Forbidden - Insufficient permissions429Too Many Requests - Rate limit exceeded500Internal Server ErrorStaff Overview API
/api/staff/overviewGet comprehensive staff statistics including total staff count, active members, top performers, recent activity, and department breakdown. Service-auth calls must target a workspace via?workspaceId=ws_… or an x-workspace-id header (session-based requests already include this).
Response
{
"totalStaff": 45,
"activeToday": 12,
"topPerformers": [
{
"userId": "44223311",
"displayName": "Ashxr_11",
"username": "Ashxr_11",
"department": "Executive",
"totalMinutes": 1250,
"totalSessions": 42,
"quotaPercentage": 208,
"headshot": "https://thumbnails.roblox.com/..."
}
],
"recentActivity": [
{
"userId": "44223311",
"displayName": "Ashxr_11",
"action": "hosted_session",
"details": "Training Session",
"timestamp": "2025-12-28T01:30:00.000Z"
}
],
"departmentBreakdown": {
"Executive": 2,
"Management": 5,
"Operations": 15,
"Department Leads": 8,
"Staff": 15
}
}Example
const response = await fetch('https://yoursite.com/api/staff/overview?workspaceId=ws_123', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app',
// Or send the workspace via header instead of query:
// 'x-workspace-id': 'ws_123'
}
});
const data = await response.json();
console.log(`Total staff: ${data.totalStaff}`);
console.log(`Active today: ${data.activeToday}`);Staff Directory API
/api/staff/directoryGet a list of all staff members with optional filtering by department and search term. Includes basic profile information and performance metrics.
Query Parameters
department(optional) - Filter by departmentsearch(optional) - Search by name or usernamesortBy(optional) - Sort by: name, rank, minutes (default: name)sortOrder(optional) - asc or desc (default: asc)Response
{
"directory": [
{
"id": "staff_44223311",
"userId": "44223311",
"displayName": "Ashxr_11",
"username": "Ashxr_11",
"department": "Executive",
"role": "Owner",
"rank": 255,
"headshot": "https://thumbnails.roblox.com/...",
"totalMinutes": 1250,
"totalSessions": 42,
"sessionsHosted": 18
}
]
}Example
const params = new URLSearchParams({
department: 'Management',
sortBy: 'minutes',
sortOrder: 'desc'
});
const response = await fetch(`https://yoursite.com/api/staff/directory?${params}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app'
}
});
const data = await response.json();Staff Profile API
/api/staff/profileGet detailed profile information for a specific staff member including metrics, quotas, recent sessions, and rank information.
Query Parameters
userId(required) - Roblox user IDResponse
{
"user": {
"userId": "44223311",
"displayName": "Ashxr_11",
"username": "Ashxr_11",
"department": "Executive",
"role": "Owner",
"rank": 255,
"headshot": "https://thumbnails.roblox.com/..."
},
"metrics": {
"totalMinutes": 1250,
"totalSessions": 42,
"sessionsHosted": 18
},
"quotas": {
"weekly": {
"required": 60,
"completed": 125,
"percentage": 208
},
"monthly": {
"required": 240,
"completed": 520,
"percentage": 217
}
},
"recentSessions": [
{
"id": "session_abc123",
"name": "Training Session",
"startTimeUtc": "2025-12-28T20:00:00.000Z",
"minutes": 45,
"role": "host"
}
],
"rank": {
"overall": 1,
"inDepartment": 1
}
}Example
const userId = '44223311';
const response = await fetch(`https://yoursite.com/api/staff/profile?userId=${userId}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app'
}
});
const data = await response.json();
console.log(`${data.user.displayName} - Rank #${data.rank.overall}`);Activity Overview API
/api/activity/overviewGet activity metrics, quotas, and recent sessions for a specific user with support for different time periods.
Query Parameters
userId(required) - Roblox user IDperiod(optional) - daily, weekly, or monthly (default: weekly)Response
{
"aggregate": {
"userId": "44223311",
"activeMinutes": 1250,
"idleMinutes": 120,
"sessionsHosted": 42,
"sessionsAttended": 65,
"messages": 234,
"lastUpdated": "2025-12-28T01:30:00.000Z"
},
"quotas": {
"weekly": {
"required": 60,
"completed": 85,
"percentage": 141
},
"monthly": {
"required": 240,
"completed": 320,
"percentage": 133
}
},
"recentSessions": [
{
"id": "session_abc123",
"name": "Training Session",
"startTimeUtc": "2025-12-28T20:00:00.000Z",
"minutes": 45,
"role": "host"
}
]
}Example
const userId = '44223311';
const response = await fetch(
`https://yoursite.com/api/activity/overview?userId=${userId}&period=weekly`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app'
}
}
);
const data = await response.json();
console.log(`Active: ${data.aggregate.activeMinutes} min`);
console.log(`Quota: ${data.quotas.weekly.percentage}%`);Sessions API
/api/sessionsGet a list of sessions with optional time-based filtering. Returns session details including status, host, servers, and attendance.
Query Parameters
startAfter(optional) - ISO 8601 timestamp - Sessions starting after this timestartBefore(optional) - ISO 8601 timestamp - Sessions starting before this timeResponse
{
"sessions": [
{
"id": "session_abc123",
"name": "Training Session",
"presetName": "Training",
"startTimeUtc": "2025-12-28T20:00:00.000Z",
"endTimeUtc": "2025-12-28T21:00:00.000Z",
"status": "upcoming",
"hostUserId": "44223311",
"hostUsername": "Ashxr_11",
"servers": [],
"roles": [],
"logs": []
}
]
}Session Status Values
upcomingSession hasn't started yetactiveSession is currently ongoingcompletedSession has endedcancelledSession was cancelledExample
// Get today's sessions
const startOfDay = new Date();
startOfDay.setHours(0, 0, 0, 0);
const endOfDay = new Date();
endOfDay.setHours(23, 59, 59, 999);
const params = new URLSearchParams({
startAfter: startOfDay.toISOString(),
startBefore: endOfDay.toISOString()
});
const response = await fetch(`https://yoursite.com/api/sessions?${params}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app'
}
});
const data = await response.json();
console.log(`Sessions today: ${data.sessions.length}`);Headshot URLs
All staff endpoints automatically include avatar headshot URLs for visual identification. These are direct links to Roblox's thumbnail service.
URL Format
https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds={userId}&size=150x150&format=Png&isCircular=falseAvailable Sizes
48x48Small thumbnail60x60Medium thumbnail150x150Large thumbnail (default)420x420Extra largeUsage in Responses
The headshot URL is included in all staff-related API responses:
{
"userId": "44223311",
"displayName": "Ashxr_11",
"headshot": "https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds=44223311&size=150x150&format=Png&isCircular=false"
}Error Handling
All API errors follow a consistent format with meaningful error messages and appropriate HTTP status codes.
Error Response Format
{
"error": "Error message description",
"message": "Additional context or guidance (optional)"
}Common Errors
401UnauthorizedInvalid or missing authentication
{ "error": "Unauthorized" }400Bad RequestMissing required parameters
{
"error": "userId parameter required",
"message": "When using API key authentication, you must provide userId as a query parameter"
}429Rate Limit ExceededToo many requests
{
"error": "Rate limit exceeded",
"retryAfter": 30
}500Internal Server ErrorServer-side error
{ "error": "Internal server error" }Error Handling Example
async function makeApiRequest(endpoint) {
try {
const response = await fetch(`https://yoursite.com/api${endpoint}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'X-Source': 'my-app'
}
});
if (!response.ok) {
const error = await response.json();
if (response.status === 429) {
console.log(`Rate limited. Retry after ${error.retryAfter}s`);
// Implement retry logic
} else if (response.status === 401) {
console.error('Invalid API key');
// Handle authentication error
} else {
console.error(`API Error: ${error.error}`);
if (error.message) {
console.error(`Details: ${error.message}`);
}
}
return null;
}
return await response.json();
} catch (error) {
console.error('Network error:', error);
return null;
}
}