API Reference
Complete API documentation for OpenShortPath endpoints.
Base URL
All API endpoints are prefixed with /api/v1.
Authentication
Include the JWT token in the Authorization header:
Endpoints
Create Short URL
Create a new short URL.
Endpoint: POST /api/v1/shorten
Authentication: Required (JWT)
Request Body:
Note: The slug field is optional. If not provided, a random 5-character slug will be generated.
Response:
Status Codes:
201 Created: Short URL created successfully400 Bad Request: Invalid request body or domain not available401 Unauthorized: Authentication required409 Conflict: Short URL with domain and slug already exists500 Internal Server Error: Server error
List Short URLs
Get a paginated list of short URLs for the authenticated user.
Endpoint: GET /api/v1/short-urls
Authentication: Required (JWT)
Query Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 20, max: 100)
Example Request:
Response:
Status Codes:
200 OK: Success401 Unauthorized: Authentication required500 Internal Server Error: Server error
Get Short URL
Get a single short URL by ID.
Endpoint: GET /api/v1/short-urls/:id
Authentication: Required (JWT)
Response:
Status Codes:
200 OK: Success401 Unauthorized: Authentication required404 Not Found: Short URL not found500 Internal Server Error: Server error
Update Short URL
Update a short URL by ID.
Endpoint: PUT /api/v1/short-urls/:id
Authentication: Required (JWT)
Request Body:
Note: All fields are optional. Only provided fields will be updated.
Response:
Status Codes:
200 OK: Short URL updated successfully400 Bad Request: Invalid request body or domain not available401 Unauthorized: Authentication required404 Not Found: Short URL not found409 Conflict: Short URL with domain and slug already exists500 Internal Server Error: Server error
Delete Short URL
Delete a short URL by ID.
Endpoint: DELETE /api/v1/short-urls/:id
Authentication: Required (JWT)
Response: No content (204)
Status Codes:
204 No Content: Short URL deleted successfully401 Unauthorized: Authentication required404 Not Found: Short URL not found500 Internal Server Error: Server error
Error Responses
All error responses follow this format: