Create Short URL (Authenticated)
Create a permanent shortened URL associated with your account.Endpoint
Headers
Bearer token obtained from
/api/auth/login or /api/auth/register.Format: Bearer <token>Request Body
The long URL to shorten. Must start with
http://, https://, or ftp://. Maximum 2048 characters.Response
Unique identifier for this short URL.
The original long URL.
The generated 7-character alphanumeric code (e.g.,
aB3xYz7).Fully-qualified short URL ready to share (e.g.,
https://short.ly/aB3xYz7).ISO 8601 timestamp of creation.
Expiration timestamp.
null for permanent (authenticated) links.Either
TEMPORARY or PERMANENT.Current status:
ACTIVE, EXPIRED, or DELETED.Total number of times this link has been followed.
Running average redirect latency in milliseconds.
null until first redirect.Last HTTP status code of the destination URL.
null until first availability check.When the destination was last checked for availability.
Status Codes
Short URL successfully created.
Invalid URL format or validation error.
Missing or invalid JWT token.
Example Response
Create Short URL (Anonymous)
Create a temporary shortened URL without authentication. The link expires after 8 hours.Endpoint
Request Body
The long URL to shorten. Must start with
http://, https://, or ftp://. Maximum 2048 characters.Response
Same as authenticated endpoint, butexpiresAt will be set to 8 hours from creation, and linkType will be TEMPORARY.
Status Codes
Short URL successfully created.
Invalid URL format or validation error.
Example Response
List My URLs
Retrieve all shortened URLs owned by the authenticated user, sorted by newest first.Endpoint
Headers
Bearer token obtained from
/api/auth/login or /api/auth/register.Response
Array of short URL objects (same structure as create response).Status Codes
Returns list of user’s URLs.
Missing or invalid JWT token.
Example Response
Delete Short URL
Soft-delete a shortened URL. The link will be marked asDELETED and will no longer redirect.
Endpoint
Path Parameters
The unique identifier of the short URL to delete.
Headers
Bearer token obtained from
/api/auth/login or /api/auth/register.Response
No response body.Status Codes
Short URL successfully deleted.
Missing or invalid JWT token, or attempting to delete another user’s URL.
Short URL with the specified ID not found.
Sync Anonymous URLs
Bulk-sync anonymous URLs from localStorage to the authenticated user’s account. This endpoint is called after registration or login to convert temporary links to permanent ones.Endpoint
Headers
Bearer token obtained from
/api/auth/login or /api/auth/register.Request Body
List of original URLs to sync. Maximum 100 URLs per request. Duplicates (URLs already owned by the user) are silently skipped.
Response
Returns the user’s complete updated URL list after syncing (same structure asGET /api/urls).
Status Codes
URLs successfully synced. Returns updated list of all user URLs.
Invalid request (empty array, more than 100 URLs).
Missing or invalid JWT token.
Example Response
Business Rules
Anonymous vs Authenticated Links
- Anonymous links (
POST /api/urls/public):- Expire after 8 hours
linkType:TEMPORARY- Stored in browser localStorage
- Automatically synced upon login/registration
- Authenticated links (
POST /api/urls):- Never expire (
expiresAt:null) linkType:PERMANENT- Associated with user account
- Can be listed and deleted
- Never expire (