Skip to main content
GET
/
api
/
files
List Files
curl --request GET \
  --url https://api.example.com/api/files
{
  "files": [
    {
      "id": {},
      "name": "<string>",
      "location": "<string>",
      "user_id": {},
      "size": {},
      "public": true,
      "created_at": {},
      "updated_at": {}
    }
  ],
  "error": "<string>"
}

Authentication

This endpoint requires Bearer token authentication.
Authorization: Bearer YOUR_JWT_TOKEN

Request

No parameters required. The endpoint automatically returns files for the authenticated user based on the JWT token.

Response

files
array
Array of file objects belonging to the user
id
uint
Unique file identifier
name
string
Original filename
location
string
Relative file path: {username}/{filename}
user_id
uint
ID of the file owner (matches authenticated user)
size
int64
File size in bytes
public
boolean
Whether the file is publicly accessible
created_at
timestamp
File creation timestamp
updated_at
timestamp
Last modification timestamp

Error Responses

error
string
Error message describing the failure

401 Unauthorized

{
  "error": "User not authenticated"
}

500 Internal Server Error

{
  "error": "Failed to retrieve files"
}

Examples

curl -X GET https://api.defdrive.com/api/files \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Success Response Example

{
  "files": [
    {
      "id": 42,
      "name": "document.pdf",
      "location": "johndoe/document.pdf",
      "user_id": 15,
      "size": 2048576,
      "public": false,
      "created_at": "2026-03-04T10:30:00Z",
      "updated_at": "2026-03-04T10:30:00Z"
    },
    {
      "id": 43,
      "name": "image.png",
      "location": "johndoe/image.png",
      "user_id": 15,
      "size": 524288,
      "public": true,
      "created_at": "2026-03-03T14:20:00Z",
      "updated_at": "2026-03-03T15:45:00Z"
    },
    {
      "id": 44,
      "name": "backup.zip",
      "location": "johndoe/backup.zip",
      "user_id": 15,
      "size": 10485760,
      "public": false,
      "created_at": "2026-03-01T09:15:00Z",
      "updated_at": "2026-03-01T09:15:00Z"
    }
  ]
}
The response includes all files owned by the authenticated user, regardless of their public/private status. Files are returned in the order they were created.

Build docs developers (and LLMs) love