Tickets API
Endpoints for ticket management, assignments, comments, search, and statistics.
Tickets API
The Tickets API provides endpoints for managing tickets, assignments, comments, and ticket-related statistics.
Endpoints
List Tickets
GET /api/tickets
Query Parameters:
- page (number) — default 1
- limit (number) — default 20, max 100
- sort (string) —
title
,priority
,status
,createdAt
,updatedAt
(defaultupdatedAt
) - order (string) —
asc
,desc
(defaultdesc
) - search (string)
- status (string) —
backlog
,todo
,in_progress
,in_review
,done
,cancelled
- priority (string) —
lowest
,low
,medium
,high
,highest
- type (string) —
TASK
,BUG
,FEATURE
,IMPROVEMENT
,EPIC
- assignee (string)
- reporter (string)
- project (string)
- workspace (string)
- group (string)
Response:
{
"data": [
{
"id": "ticket_123",
"title": "Fix login authentication bug",
"description": "Users are unable to login with valid credentials",
"key": "WEB-45",
"type": "BUG",
"status": "in_progress",
"priority": "high",
"stage": "DEVELOPMENT",
"projectId": "project_456",
"workspaceId": "workspace_789",
"assigneeId": "user_101",
"reporterId": "user_102",
"groupId": "group_103",
"assignee": {"id": "user_101", "name": "Jane Smith", "email": "jane@example.com", "image": "https://example.com/jane.jpg"},
"reporter": {"id": "user_102", "name": "John Doe", "email": "john@example.com", "image": "https://example.com/john.jpg"},
"dueDate": "2024-02-01T00:00:00Z",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-20T14:30:00Z",
"_count": {"comments": 5, "attachments": 2, "timeLogs": 3}
}
],
"pagination": {"page": 1, "limit": 20, "total": 45, "totalPages": 3}
}
Create Ticket
POST /api/tickets
Request Body:
{
"title": "Implement user dashboard",
"description": "Create a comprehensive user dashboard with analytics and recent activity",
"type": "FEATURE",
"priority": "medium",
"projectId": "project_456",
"assigneeId": "user_101",
"dueDate": "2024-02-15T00:00:00Z",
"labelIds": ["label_1", "label_2"]
}
Get Ticket
GET /api/tickets/[id]
Update Ticket
PUT /api/tickets/[id]
Delete Ticket
DELETE /api/tickets/[id]
Update Ticket Status
PUT /api/tickets/[id]/status
Request Body:
{ "status": "done" }
Assign Ticket
PUT /api/tickets/[id]/assignee
Request Body:
{ "assigneeId": "user_105" }
Get Ticket Statistics
GET /api/tickets/stats
Query Parameters:
- period (string) —
week
,month
,quarter
,year
(defaultmonth
) - project (string)
- assignee (string)
Search Tickets
GET /api/tickets/search
Query Parameters:
- q (string, required) — Search query
- limit (number) — default 20, max 100
- project (string)
- status (string)
Data Models
interface Ticket { id: string; title: string; description?: string; key?: string; type?: 'TASK' | 'BUG' | 'FEATURE' | 'IMPROVEMENT' | 'EPIC'; status?: 'backlog' | 'todo' | 'in_progress' | 'in_review' | 'done' | 'cancelled'; priority?: 'lowest' | 'low' | 'medium' | 'high' | 'highest'; stage?: 'PLANNING' | 'DEVELOPMENT' | 'TESTING' | 'DEPLOYMENT' | 'COMPLETED'; projectId?: string; workspaceId?: string; assigneeId?: string; reporterId?: string; groupId?: string; dueDate?: Date; createdAt: Date; updatedAt: Date }
interface TicketWithDetails extends Ticket { assignee?: Pick<User, 'id' | 'name' | 'email' | 'image'> | null; reporter?: Pick<User, 'id' | 'name' | 'email' | 'image'> | null; project?: Project | null; workspace?: Workspace | null; group?: Group | null; labels: Label[]; comments: (Comment & { author: Pick<User, 'id' | 'name' | 'email' | 'image'> })[]; _count: { comments: number; attachments: number; timeLogs: number } }
interface TicketStats { period: 'week' | 'month' | 'quarter' | 'year'; startDate: Date; endDate: Date; total: number; byStatus: Record<string, number>; byPriority: Record<string, number>; byType: Record<string, number>; metrics: { averageCompletionTime: string; completionRate: number; overdue: number; createdThisPeriod: number; completedThisPeriod: number } }
Error Responses
{"error": {"code": "UNAUTHORIZED", "message": "Authentication required"}}
{"error": {"code": "FORBIDDEN", "message": "Insufficient permissions to access this ticket"}}
{"error": {"code": "NOT_FOUND", "message": "Ticket not found"}}
{"error": {"code": "VALIDATION_ERROR", "message": "Invalid input data", "details": {"title": ["Title is required"], "assigneeId": ["Invalid assignee ID"]}}}
Examples
curl -X POST "https://codimir.com/api/tickets" -H "Content-Type: application/json" -H "Cookie: next-auth.session-token=..." -d '{"title":"Login page crashes on mobile","description":"The login page crashes when accessed on mobile devices","type":"BUG","priority":"high","projectId":"project_456","assigneeId":"user_101"}'
curl -X GET "https://codimir.com/api/tickets?status=in_progress&priority=high&assignee=user_101&page=1&limit=10" -H "Cookie: next-auth.session-token=..."
curl -X PUT "https://codimir.com/api/tickets/ticket_123/status" -H "Content-Type: application/json" -H "Cookie: next-auth.session-token=..." -d '{"status":"done"}'
curl -X POST "https://codimir.com/api/tickets/ticket_123/comments" -H "Content-Type: application/json" -H "Cookie: next-auth.session-token=..." -d '{"content":"Fixed the issue and deployed to staging"}'