🎫 Simple Ticket System API

Complete API Documentation for Developers

Base URL: https://ticket.sozlerkosku.com/api
Login Register

Welcome to Simple Ticket System API 🎫

A powerful RESTful API for managing support tickets with user and support roles. Built with Laravel 11 and Laravel Sanctum for secure authentication.

🔐
Secure Auth
Sanctum tokens
🎫
Ticket Management
Full CRUD operations
👥
Role Based
User & Support roles
📝
JSON API
RESTful design

📋 Getting Started

All API requests should be made to the base URL: https://ticket.sozlerkosku.com/api

Authentication: Most endpoints require a Bearer token in the Authorization header. Get your token by registering or logging in.

🔐 Authentication

POST /register Register a new user ▼
Request Body:
name (string, required) - User's full name
email (string, required) - User's email address
password (string, required) - Password (min 6 characters)
password_confirmation (string, required) - Password confirmation
role (string, required) - Either "user" or "support"
curl -X POST https://ticket.sozlerkosku.com/api/register \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "name": "John Doe", "email": "john@example.com", "password": "password123", "password_confirmation": "password123", "role": "user" }'
✅ Success Response (201):
{ "user": { "id": 1, "name": "John Doe", "email": "john@example.com", "role": "user", "created_at": "2025-11-03T09:52:44.000000Z", "updated_at": "2025-11-03T09:52:44.000000Z" }, "token": "1|UYZBXbpyCDFjAGJ5PZPbpFyXWyc0PaZj7ZGTG9yjfacda3e5" }
POST /login Login and get authentication token ▼
Request Body:
email (string, required) - User's email
password (string, required) - User's password
curl -X POST https://ticket.sozlerkosku.com/api/login \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "email": "john@example.com", "password": "password123" }'
✅ Success Response (200):
{ "user": { "id": 1, "name": "John Doe", "email": "john@example.com", "role": "user" }, "token": "2|xyz789abcdefghijklmnopqrstuvwxyz" }
❌ Error Response (422):
{ "message": "The given data was invalid.", "errors": { "email": [ "The provided credentials are incorrect." ] } }
GET /user Get current user info Auth Required ▼
curl -X GET https://ticket.sozlerkosku.com/api/user \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"
POST /logout Logout and invalidate token Auth Required ▼
curl -X POST https://ticket.sozlerkosku.com/api/logout \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"

🎫 User Tickets

GET /tickets Get all my tickets Auth Required ▼
curl -X GET https://ticket.sozlerkosku.com/api/tickets \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"
POST /tickets Create a new ticket Auth Required ▼
Request Body:
title (string, required) - Ticket title
content (string, required) - Ticket description/message
curl -X POST https://ticket.sozlerkosku.com/api/tickets \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "title": "Kargo gelmedi", "content": "Siparişim 3 gündür görünmüyor." }'
✅ Success Response (201):
{ "id": 1, "user_id": 1, "title": "Kargo gelmedi", "content": "Siparişim 3 gündür görünmüyor.", "status": "created", "created_at": "2025-11-03T09:52:44.000000Z", "updated_at": "2025-11-03T09:52:44.000000Z" }
GET /tickets/{id} Get specific ticket details Auth Required ▼
URL Parameters:
id (integer, required) - Ticket ID
curl -X GET https://ticket.sozlerkosku.com/api/tickets/1 \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"
POST /tickets/{id}/reply Reply to a ticket Auth Required ▼
URL Parameters:
id (integer, required) - Ticket ID
Request Body:
message (string, required) - Reply message
curl -X POST https://ticket.sozlerkosku.com/api/tickets/1/reply \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "message": "Teşekkür ederim bilgilendirme için." }'
POST /tickets/{id}/close Close a ticket Auth Required ▼
URL Parameters:
id (integer, required) - Ticket ID
curl -X POST https://ticket.sozlerkosku.com/api/tickets/1/close \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"
DELETE /tickets/{id} Delete a ticket (soft delete) Auth Required ▼
URL Parameters:
id (integer, required) - Ticket ID

Note: This performs a soft delete. The ticket will be marked as deleted but not permanently removed from the database. Both ticket owners and support users can delete tickets.

curl -X DELETE https://ticket.sozlerkosku.com/api/tickets/1 \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Accept: application/json"
✅ Success Response (200):
{ "message": "Ticket deleted successfully" }

👨‍💼 Support Endpoints

GET /support/tickets Get all open tickets Support Only ▼
curl -X GET https://ticket.sozlerkosku.com/api/support/tickets \ -H "Authorization: Bearer YOUR_SUPPORT_TOKEN" \ -H "Accept: application/json"
POST /support/tickets/{id}/answer Answer a ticket Support Only ▼
URL Parameters:
id (integer, required) - Ticket ID
Request Body:
message (string, required) - Answer message
curl -X POST https://ticket.sozlerkosku.com/api/support/tickets/1/answer \ -H "Authorization: Bearer YOUR_SUPPORT_TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "message": "Kargonuz bugün teslim edilecektir." }'

⚠️ Error Responses

Common HTTP Status Codes:

  • 200 OK: Successful GET, PUT, PATCH requests
  • 201 Created: Successful POST requests (resource created)
  • 401 Unauthorized: Missing or invalid authentication token
  • 403 Forbidden: Insufficient permissions (e.g., support-only endpoint)
  • 422 Unprocessable Entity: Validation errors
  • 404 Not Found: Resource doesn't exist
401 Unauthorized Missing or invalid token ▼
{ "message": "Unauthenticated." }
403 Forbidden Insufficient permissions ▼
{ "message": "Unauthorized. Support role required." }
422 Validation Error Invalid request data ▼
{ "message": "The given data was invalid.", "errors": { "title": [ "The title field is required." ], "email": [ "The email must be a valid email address." ] } }

🚀 Quick Start Guide

Testing Workflow:

  1. Register a user: Use POST /register with role "user"
  2. Save the token: Copy the token from the response
  3. Create a ticket: Use POST /tickets with the user token
  4. Register support: Use POST /register with role "support"
  5. Answer ticket: Use POST /support/tickets/{id}/answer

💡 Tips:

  • Replace YOUR_TOKEN with your actual authentication token
  • All requests require Accept: application/json header
  • Support endpoints require a user with role "support"
  • Use -v flag with curl for verbose output
  • Copy curl commands using the "Copy" button for easy testing

📚 Example: Complete Workflow

1. Register a user:

curl -X POST https://ticket.sozlerkosku.com/api/register \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"name":"John Doe","email":"john@example.com","password":"password123","password_confirmation":"password123","role":"user"}'

2. Save the token from response, then create a ticket:

curl -X POST https://ticket.sozlerkosku.com/api/tickets \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"title":"Test Ticket","content":"This is a test ticket"}'