Skip to content

Files API

Manage file uploads and downloads in the CMS.

Upload a File

Upload a new file.

Endpoint: POST /api/v1/file

Request Body:

The request should be a multipart form-data request with the file.

Example Request:

bash
curl -X POST "https://access.flatnode.io/api/v1/file" \
  -H "Authorization: Bearer your-token-here" \
  -F "file=@/path/to/file.jpg"

Response: 201 Created

json
{
  "data": {
    "Id": 789,
    "filename": "file.jpg",
    "path": "/storage/files/..."
  }
}

Get a File

Retrieve file metadata by ID.

Endpoint: GET /api/v1/file/{id}

Example Request:

bash
curl -X GET "https://access.flatnode.io/api/v1/file/789" \
  -H "Authorization: Bearer your-token-here"

Response: 200 OK

Returns file metadata.

Download a File

Download a file, optionally with a specific variant.

Endpoint: GET /api/v1/file/{file}/download/{variant?}

Parameters:

  • file - File ID
  • variant (optional) - Variant name (e.g., "thumbnail", "preview")

Example Request:

bash
curl -X GET "https://access.flatnode.io/api/v1/file/789/download" \
  -H "Authorization: Bearer your-token-here" \
  -o downloaded-file.jpg

Response: 200 OK

Returns the file content with appropriate headers.

Update a File

Update file metadata.

Endpoint: PATCH /api/v1/file/{id} or PUT /api/v1/file/{id}

Example Request:

bash
curl -X PATCH "https://access.flatnode.io/api/v1/file/789" \
  -H "Authorization: Bearer your-token-here" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated File Title"
  }'

Response: 200 OK

Delete a File

Delete a file.

Endpoint: DELETE /api/v1/file/{id}

Example Request:

bash
curl -X DELETE "https://access.flatnode.io/api/v1/file/789" \
  -H "Authorization: Bearer your-token-here"

Response: 200 OK or 204 No Content