RESTful API for file sharing and bookmark management with JSON responses.
/api
Most 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_your_64_character_api_key_here" \
https://4-0-4.io/api/user/bookmarks
curl https://4-0-4.io/api/user/bookmarks?api_key=p404_your_64_character_api_key_here
curl -X POST -H "Content-Type: application/json" \
-d '{"api_key":"p404_your_64_character_api_key_here","title":"My Bookmark","url":"https://example.com"}' \
https://4-0-4.io/api/links
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"your_username","password":"your_password","title":"My Bookmark","url":"https://example.com"}' \
https://4-0-4.io/api/links
curl -u "your_username:your_password" \
https://4-0-4.io/api/links
curl -X POST -d "username=your_username&password=your_password&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/docs
Returns this API documentation in JSON format.
Authentication: None required
curl https://4-0-4.io/api
/api/auth/login
Authenticate 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": 1,
"username": "testuser",
"is_admin": false
}
}
/api/auth/keys
Generate 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/keys
List 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": 1,
"name": "Production API Key",
"key_prefix": "p404_abc123",
"created_at": "2025-07-02 12:00:00",
"last_used_at": "2025-07-02 13:30:00",
"expires_at": "2026-07-02 12:00:00",
"is_active": true
}
]
}
/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/1
{
"status": "success",
"message": "API key revoked successfully"
}
/api/auth/keys/{id}/permanent
Permanently 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/links
Get 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/links
Create 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/bookmarks
Get 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/files
Get 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/files
Upload 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/files
Get 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