-
Notifications
You must be signed in to change notification settings - Fork 0
API
Complete API reference for NEXUS Support System.
- Ticket Routes - Ticket management endpoints
- User Routes - User management endpoints
- Analytics Routes - Analytics endpoints
- Search Routes - Search functionality
- Notification Routes - Notification system
- Ticket Controller - Ticket business logic
- User Controller - User management logic
- Analytics Controller - Analytics processing
- Search Controller - Search implementation
- Ticket Model - Ticket data structure
- User Model - User data structure
- Analytics Model - Analytics data model
http://localhost:3000/api
Most endpoints require authentication using JWT tokens. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
- Register a user or login
- Receive JWT token in response
- Include token in subsequent requests
{
"success": true,
"data": {
// response data
}
}{
"success": false,
"error": "Error message description"
}-
200- OK: Request successful -
201- Created: Resource created successfully -
400- Bad Request: Invalid request data -
401- Unauthorized: Authentication required or failed -
404- Not Found: Resource not found -
500- Internal Server Error: Server error
Register a new user account.
Endpoint: POST /users/register
Authentication: Not required
Request Body:
{
"username": "john_doe",
"email": "john@example.com",
"password": "securePassword123",
"role": "user"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | Unique username (3-30 characters) |
| string | Yes | Valid email address | |
| password | string | Yes | Password (min 6 characters) |
| role | string | No | User role: admin, support_agent, user (default: user) |
Response (201):
{
"success": true,
"data": {
"user": {
"id": "5f8d0d55b54764421b7156e4",
"username": "john_doe",
"email": "john@example.com",
"role": "user"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}Error Response (400):
{
"success": false,
"error": "User already exists"
}Authenticate a user and receive JWT token.
Endpoint: POST /users/login
Authentication: Not required
Request Body:
{
"username": "john_doe",
"password": "securePassword123"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | Username |
| password | string | Yes | User password |
Response (200):
{
"success": true,
"data": {
"user": {
"id": "5f8d0d55b54764421b7156e4",
"username": "john_doe",
"email": "john@example.com",
"role": "user"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}Error Response (401):
{
"success": false,
"error": "Invalid credentials"
}Get information about the authenticated user.
Endpoint: GET /users/me
Authentication: Required
Response (200):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e4",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"githubUsername": null,
"createdAt": "2020-10-20T14:30:00.000Z"
}
}Create a new support ticket.
Endpoint: POST /tickets
Authentication: Not required (can be configured as required)
Request Body:
{
"title": "Login page not responding",
"description": "Users cannot access the login page after clicking the button",
"priority": "high",
"category": "bug",
"tags": ["frontend", "auth", "urgent"],
"createdBy": "John Doe",
"createdByEmail": "john@example.com"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Ticket title |
| description | string | Yes | Detailed description |
| priority | string | No | Priority: low, medium, high, critical (default: medium) |
| category | string | No | Category (default: general) |
| tags | array | No | Array of tag strings |
| createdBy | string | Yes | Name of ticket creator |
| createdByEmail | string | Yes | Email of ticket creator |
Response (201):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"title": "Login page not responding",
"description": "Users cannot access the login page after clicking the button",
"status": "open",
"priority": "high",
"category": "bug",
"createdBy": "John Doe",
"createdByEmail": "john@example.com",
"assignedTo": null,
"githubIssueNumber": null,
"githubIssueUrl": null,
"comments": [],
"tags": ["frontend", "auth", "urgent"],
"createdAt": "2020-10-20T14:30:00.000Z",
"updatedAt": "2020-10-20T14:30:00.000Z",
"resolvedAt": null
}
}Retrieve all tickets with optional filtering.
Endpoint: GET /tickets
Authentication: Not required (can be configured as required)
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| status | string | No | Filter by status: open, in_progress, resolved, closed
|
| priority | string | No | Filter by priority: low, medium, high, critical
|
| category | string | No | Filter by category |
| assignedTo | string | No | Filter by assignee |
Example Request:
GET /api/tickets?status=open&priority=high
Response (200):
{
"success": true,
"count": 5,
"data": [
{
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"title": "Login page not responding",
"status": "open",
"priority": "high",
"createdAt": "2020-10-20T14:30:00.000Z"
}
]
}Retrieve a specific ticket by ticket ID.
Endpoint: GET /tickets/:ticketId
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Example Request:
GET /api/tickets/TCK-K4J9X2M1
Response (200):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"title": "Login page not responding",
"description": "Users cannot access the login page after clicking the button",
"status": "open",
"priority": "high",
"category": "bug",
"createdBy": "John Doe",
"createdByEmail": "john@example.com",
"assignedTo": null,
"githubIssueNumber": null,
"githubIssueUrl": null,
"comments": [],
"tags": ["frontend", "auth", "urgent"],
"createdAt": "2020-10-20T14:30:00.000Z",
"updatedAt": "2020-10-20T14:30:00.000Z",
"resolvedAt": null
}
}Error Response (404):
{
"success": false,
"error": "Ticket not found"
}Update an existing ticket.
Endpoint: PUT /tickets/:ticketId
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Request Body:
{
"status": "in_progress",
"priority": "high",
"assignedTo": "support_agent",
"tags": ["frontend", "auth", "urgent", "assigned"]
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | string | No | Updated title |
| description | string | No | Updated description |
| status | string | No | Updated status |
| priority | string | No | Updated priority |
| category | string | No | Updated category |
| assignedTo | string | No | Assignee username |
| tags | array | No | Updated tags array |
Response (200):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"title": "Login page not responding",
"status": "in_progress",
"priority": "high",
"assignedTo": "support_agent",
"updatedAt": "2020-10-20T15:00:00.000Z"
}
}Delete a ticket permanently.
Endpoint: DELETE /tickets/:ticketId
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Response (200):
{
"success": true,
"data": {}
}Add a comment to a ticket.
Endpoint: POST /tickets/:ticketId/comments
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Request Body:
{
"author": "Support Agent",
"authorEmail": "agent@example.com",
"content": "This issue has been reproduced. Working on a fix."
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| author | string | Yes | Comment author name |
| authorEmail | string | Yes | Comment author email |
| content | string | Yes | Comment content |
Response (200):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"comments": [
{
"author": "Support Agent",
"authorEmail": "agent@example.com",
"content": "This issue has been reproduced. Working on a fix.",
"createdAt": "2020-10-20T15:30:00.000Z"
}
]
}
}Manually link a ticket to a GitHub issue.
Endpoint: POST /tickets/:ticketId/link-github
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Request Body:
{
"issueNumber": 123,
"issueUrl": "https://github.com/owner/repo/issues/123"
}Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| issueNumber | number | Yes | GitHub issue number |
| issueUrl | string | Yes | GitHub issue URL |
Response (200):
{
"success": true,
"data": {
"_id": "5f8d0d55b54764421b7156e5",
"ticketId": "TCK-K4J9X2M1",
"githubIssueNumber": 123,
"githubIssueUrl": "https://github.com/owner/repo/issues/123"
}
}Process GitHub webhook events (Issues, Issue Comments).
Endpoint: POST /github/webhook
Authentication: Webhook signature verification
Headers:
| Header | Required | Description |
|---|---|---|
| X-GitHub-Event | Yes | Event type (issues, issue_comment) |
| X-Hub-Signature-256 | Yes | HMAC signature for verification |
Webhook Events:
-
issues:
opened,closed,reopened,edited,labeled -
issue_comment:
created
Response (200):
{
"success": true
}Error Response (401):
{
"error": "Invalid signature"
}Sync a ticket to GitHub (create or update issue).
Endpoint: POST /github/sync-ticket/:ticketId
Authentication: Not required (can be configured as required)
URL Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ticketId | string | Yes | Unique ticket identifier |
Response (200) - New Issue Created:
{
"success": true,
"data": {
"id": 123456789,
"number": 123,
"state": "open",
"title": "Login page not responding",
"body": "Users cannot access the login page after clicking the button",
"html_url": "https://github.com/owner/repo/issues/123",
"user": {
"login": "bot-username"
},
"labels": [],
"created_at": "2020-10-20T16:00:00.000Z"
}
}Response (200) - Issue Updated:
{
"success": true,
"message": "Issue updated on GitHub"
}Error Response (500):
{
"success": false,
"error": "GitHub API error"
}Check if the API server is running.
Endpoint: GET /health
Authentication: Not required
Response (200):
{
"status": "ok",
"timestamp": "2020-10-20T16:30:00.000Z"
}| Code | Description |
|---|---|
E001 |
Invalid authentication token |
E002 |
Token expired |
E003 |
User not found |
E004 |
Invalid credentials |
E005 |
Ticket not found |
E006 |
Duplicate ticket ID |
E007 |
Invalid ticket status |
E008 |
Invalid priority level |
E009 |
GitHub API error |
E010 |
Webhook verification failed |
E011 |
Database connection error |
E012 |
Validation error |
The API implements rate limiting to prevent abuse:
- Limit: 100 requests per 15 minutes per IP address
-
Headers Returned:
-
X-RateLimit-Limit: Request limit -
X-RateLimit-Remaining: Remaining requests -
X-RateLimit-Reset: Reset time (Unix timestamp)
-
Rate Limit Exceeded Response (429):
{
"error": "Too many requests"
}For endpoints that return lists, implement pagination:
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | number | 1 | Page number |
| limit | number | 10 | Items per page |
Example:
GET /api/tickets?page=2&limit=20
Response:
{
"success": true,
"data": [...],
"pagination": {
"page": 2,
"limit": 20,
"total": 100,
"pages": 5
}
}The API supports Cross-Origin Resource Sharing. Configure allowed origins in server.js.
Default configuration allows all origins in development. Restrict in production.
{
"action": "opened",
"issue": {
"id": 123456789,
"number": 123,
"title": "Bug report",
"body": "Description of the bug",
"state": "open",
"user": {
"login": "username",
"id": 123456
},
"html_url": "https://github.com/owner/repo/issues/123"
},
"repository": {
"name": "repo",
"owner": {
"login": "owner"
}
}
}{
"action": "created",
"issue": {
"number": 123,
"title": "Bug report"
},
"comment": {
"id": 456789,
"body": "Comment content",
"user": {
"login": "username"
},
"created_at": "2020-10-20T16:00:00.000Z"
}
}# Create ticket
curl -X POST http://localhost:3000/api/tickets \
-H "Content-Type: application/json" \
-d '{
"title": "Test Ticket",
"description": "Test description",
"createdBy": "Test User",
"createdByEmail": "test@example.com"
}'
# Get tickets
curl http://localhost:3000/api/tickets
# Get specific ticket
curl http://localhost:3000/api/tickets/TCK-ABC123
# Add comment
curl -X POST http://localhost:3000/api/tickets/TCK-ABC123/comments \
-H "Content-Type: application/json" \
-d '{
"author": "User",
"authorEmail": "user@example.com",
"content": "Test comment"
}'// Create ticket
fetch('http://localhost:3000/api/tickets', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Test Ticket',
description: 'Test description',
createdBy: 'Test User',
createdByEmail: 'test@example.com'
})
})
.then(response => response.json())
.then(data => console.log(data));
// Get tickets
fetch('http://localhost:3000/api/tickets')
.then(response => response.json())
.then(data => console.log(data));Current API version: v1.0.0
Include version in URL for future compatibility:
/api/v1/tickets
- Initial release
- Basic CRUD operations for tickets
- GitHub webhook integration
- User authentication
- Comment system