RESTful API for file sharing and bookmark management with JSON responses.
/apiMost endpoints require authentication. You can authenticate in four ways:
Use an API key for secure, long-term access without exposing your password.
curl -H "X-API-Key: p404_5d106b399073f06b3c91cb9a2cd8011e92531cb6d44596af57a37d5776e9f2b0" \
https://4-0-4.io/api/user/bookmarks
curl https://4-0-4.io/api/user/bookmarks?api_key=p404_5d106b399073f06b3c91cb9a2cd8011e92531cb6d44596af57a37d5776e9f2b0
curl -X POST -H "Content-Type: application/json" \
-d '{"api_key":"p404_5d106b399073f06b3c91cb9a2cd8011e92531cb6d44596af57a37d5776e9f2b0","title":"My Bookmark","url":"https://example.com"}' \
https://4-0-4.io/api/links
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass","title":"My Bookmark","url":"https://example.com"}' \
https://4-0-4.io/api/links
curl -u "testuser:testpass" \
https://4-0-4.io/api/links
curl -X POST -d "username=testuser&password=testpass&title=My Bookmark&url=https://example.com" \
https://4-0-4.io/api/links
All API responses are in JSON format with the following structure:
{
"status": "success",
"message": "Operation completed successfully",
"data": { ... }
}
{
"status": "error",
"message": "Error description"
}
/api or /api/docsReturns this API documentation in JSON format.
Authentication: None required
curl https://4-0-4.io/api
/api/auth/loginAuthenticate user credentials and get user information.
Authentication: Username/password required
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass"}' \
https://4-0-4.io/api/auth/login
{
"status": "success",
"message": "Authentication successful",
"data": {
"user_id": 11,
"username": "testuser",
"is_admin": false
}
}
/api/auth/keysGenerate a new API key for the authenticated user.
Authentication: Username/password required (cannot use API key to create another key)
name (optional): Name for the API key (default: "API Key")expires_at (optional): Expiration date (YYYY-MM-DD HH:MM:SS, default: 1 year)curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass","name":"Production API Key"}' \
https://4-0-4.io/api/auth/keys
{
"status": "success",
"message": "API key generated successfully",
"data": {
"id": 1,
"key": "p404_abc123def456...",
"name": "Production API Key",
"expires_at": "2026-07-02 12:00:00"
}
}
Important: Store this key securely! It will not be shown again.
/api/auth/keysList all API keys for the authenticated user.
Authentication: Username/password or API key
curl -u "testuser:testpass" https://4-0-4.io/api/auth/keys
{
"status": "success",
"data": [
{
"id": 5,
"key_prefix": "p404_5d106b3",
"name": "test",
"created_at": "2025-07-21 17:35:25",
"last_used_at": null,
"expires_at": "2026-07-21 17:35:25",
"is_active": 1
}
]
}
/api/auth/keys/{id}Revoke (deactivate) an API key. The key will stop working immediately but remain in the database for audit purposes.
Authentication: Username/password or API key (different from the one being deleted)
curl -X DELETE -u "testuser:testpass" https://4-0-4.io/api/auth/keys/5
{
"status": "success",
"message": "API key revoked successfully"
}
/api/auth/keys/{id}/permanentPermanently delete a revoked API key from the database. This can only be done on keys that are already revoked.
Authentication: Username/password or API key (different from the one being deleted)
curl -X DELETE -u "testuser:testpass" https://4-0-4.io/api/auth/keys/1/permanent
{
"status": "success",
"message": "API key deleted permanently"
}
Note: This action is irreversible. The key must be revoked first before it can be permanently deleted.
/api/linksGet all public bookmarks.
Authentication: None required
curl https://4-0-4.io/api/links
{
"status": "success",
"data": [
{
"id": 1,
"title": "Example Site",
"url": "https://example.com",
"description": "A sample website",
"created_at": "2025-07-02 12:00:00"
}
]
}
/api/linksCreate a new bookmark.
Authentication: Required
title (required): Bookmark titleurl (required): URL to bookmarkdescription (optional): Bookmark descriptionis_public (optional): Make bookmark public (0 or 1, default: 0)curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass","title":"My Site","url":"https://mysite.com","description":"My personal website","is_public":1}' \
https://4-0-4.io/api/links
/api/user/bookmarksGet all bookmarks for the authenticated user (both public and private).
Authentication: Required
curl -u "testuser:testpass" https://4-0-4.io/api/user/bookmarks
/api/links/{id}Delete a bookmark. Only the owner or admin can delete bookmarks.
Authentication: Required
curl -X DELETE -u "testuser:testpass" https://4-0-4.io/api/links/123
/api/filesGet list of all public files with metadata.
Authentication: None required
curl https://4-0-4.io/api/files
{
"status": "success",
"data": [
{
"slug": "abc123def456",
"original_name": "example.txt",
"size": 1024,
"mime": "text/plain",
"extension": "txt",
"downloads": 5,
"created_at": "2025-07-02 12:00:00",
"expires_at": "2025-08-02 12:00:00",
"download_url": "/file/abc123def456",
"preview_url": "/preview/abc123def456"
}
]
}
/api/filesUpload a new file.
Authentication: Required
Content-Type: multipart/form-data
file (required): File to upload (max 100MB)password (optional): Password to encrypt the fileexpires_at (optional): Expiration date (YYYY-MM-DD HH:MM:SS)username (required): Your usernamepassword (required): Your passwordcurl -X POST -F "file=@example.txt" -F "username=testuser" -F "password=testpass" \
https://4-0-4.io/api/files
{
"status": "success",
"message": "File uploaded",
"data": {
"slug": "abc123def456",
"download_url": "/file/abc123def456",
"preview_url": "/preview/abc123def456"
}
}
/api/files/{slug}Download a file by its slug. This will initiate the file download.
Authentication: None required (unless file is password protected)
curl -O https://4-0-4.io/api/files/abc123def456
/api/user/filesGet all files uploaded by the authenticated user.
Authentication: Required
curl -u "testuser:testpass" https://4-0-4.io/api/user/files
/api/files/{slug}Delete a file. Only the owner or admin can delete files.
Authentication: Required
curl -X DELETE -u "testuser:testpass" https://4-0-4.io/api/files/abc123def456
Here's a complete example of uploading a file and creating a bookmark:
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass"}' \
https://4-0-4.io/api/auth/login
curl -X POST -F "file=@document.pdf" -F "username=testuser" -F "password=testpass" \
https://4-0-4.io/api/files
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"testuser","password":"testpass","title":"Important Document","url":"https://4-0-4.io/file/abc123def456","is_public":1}' \
https://4-0-4.io/api/links
curl -u "testuser:testpass" https://4-0-4.io/api/user/files
curl -u "testuser:testpass" https://4-0-4.io/api/user/bookmarks
http:// prepended if no protocol is specified