Media Files

The Flextype Files API organized around Representational State Transfer (REST) for delivering files from Flextype to apps, websites and other. Files are delivered as JSON data.

Endpoints

Method Endpoint Description
GET /api/media/files Fetch file or files collection.
POST /api/media/files Upload file.
PUT /api/media/files Move file.
PUT /api/media/files/copy Copy file.
DELETE /api/media/files Delete file.
PATCH /api/media/files/meta Updates file meta information.
POST /api/media/files/meta Add file meta information.
DELETE /api/media/files/meta Delete file meta information.

Fetch file

Fetch single file
Request
GET /api/media/files?id=YOUR_MEDIA_FILES_ID&token=YOUR_MEDIA_FILES_TOKEN
Query
Name Description
id REQUIRED File ID.
options OPTIONAL Array of options.
token REQUIRED Valid Files Token.
Result

Returns the item object for the given unique identifier.

Examples

Fetch file entries/movies/sg-1/season-5/episode-21/cover.jpg

Request
GET /api/media/files?id=entries/movies/sg-1/season-5/episode-21/cover.jpg&token=6f047babd1894064fbf7662080a9a2f0
Response
200 OK
{
    "data": {
        "title": "Episode 21",
        "filename": "cover.jpg",
        "basename": "cover",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21",
        "url": "project/uploads/entries/movies/sg-1/season-5/episode-21/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21/cover.jpg"
    }
}
Fetch files collection
Request
GET /api/media/files?id=YOUR_MEDIA_FILES_ID&options[collection]=true&token=YOUR_MEDIA_FILES_TOKEN
Query
Name Description
id REQUIRED Folder ID.
options OPTIONAL Array of options.
token REQUIRED Valid Files Token.
Result

Returns an array of item objects.

Examples

Fetch Movies Folders Collection entries/movies/sg-1/season-5/episode-21

Request
GET /api/media/files?id=entries/movies/sg-1/season-5/episode-21&token=6f047babd1894064fbf7662080a9a2f0
Response
200 OK
{
    "data": {
        "cover.jpg": {
            "title": "Episode 21",
            "filename": "cover.jpg",
            "basename": "cover",
            "extension": "jpg",
            "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21",
            "url": "project/uploads/entries/movies/sg-1/season-5/episode-21/cover.jpg",
            "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21/cover.jpg"
        }
    }
}

Upload file

Request
POST /api/media/files
Body
Name Description
folder REQUIRED The folder you're targetting.
file REQUIRED Raw file data (multipart/form-data).
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns the file object for the file that was just uploaded.

Examples

Upload new file to entries/movies/sg-1/season-5/episode-21

Request
POST /api/media/files
Body
curl -i -X POST \
  -H "Content-Type: multipart/form-data" \
  -F "token=efe1e36e4d60fcd547e22eb9f795dff92" \
  -F "access_token=efe1e36e4d60fcd547e22eb9f795dff91" \
  -F "folder=entries/movies/sg-1/season-5/episode-21" \
  -F "file=@/users/awilum/documents/new-covers/new-cover.jpg" \
  https://localhost:8888/flextype/api/media/files
Response
200 OK
{
  "data": {
    "title": "New Cover",
    "description": "",
    "type": "image/jpeg",
    "filesize": 342298,
    "uploaded_on": 1596107422,
    "exif": {
      "html": "width=\"1600\" height=\"900\"",
      "Height": 900,
      "Width": 1600,
      "IsColor": 1
    },
    "filename": "new-cover.jpg",
    "basename": "new-cover",
    "extension": "jpg",
    "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21",
    "url": "project/uploads/entries/movies/sg-1/season-5/episode-21/new-cover.jpg",
    "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21/new-cover.jpg"
  }
}

Move file

Request
PUT /api/media/files
Body
Name Description
id REQUIRED Unique identifier of the file.
new_id REQUIRED New Unique identifier of the file.
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns the folders object for the file that was just moved.

Examples

Move file entries/movies/sg-1/season-5/episode-21/cover.jpg to the entries/movies/sg-1/season-5/episode-21/new-cover.jpg

Request
PUT /api/media/files
Body
{
    "id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/episode-21/new-cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Episode 21",
        "filename": "new-cover.jpg",
        "basename": "new-cover",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21",
        "url": "project/uploads/entries/movies/sg-1/season-5/episode-21/new-cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21/new-cover.jpg"
    }
}

Move file entries/movies/sg-1/season-5/episode-21/cover.jpg to the entries/movies/sg-1/season-5/cover.jpg

Request
PUT /api/media/files
Body
{
	"id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Episode 21",
        "filename": "cover.jpg",
        "basename": "cover",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5",
        "url": "project/uploads/entries/movies/sg-1/season-5/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/new-cover.jpg"
    }
}

Copy File

Request
PUT /api/media/files/copy
Body
Name Description
id REQUIRED Unique identifier of the file.
new_id REQUIRED New Unique identifier of the file.
token REQUIRED Valid Folders token.
access_token REQUIRED Valid Access token.
Result

Returns the file object for the file that was just copied.

Examples

Copy for entry entries/movies/sg-1/season-5/cover.jpg to entries/movies/sg-1/season-5/episode-21/cover.jpg

Request
PUT /api/media/files/copy
Body
{
	"id": "entries/movies/sg-1/season-5/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Episode 21",
        "filename": "cover.jpg",
        "basename": "cover",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21",
        "url": "project/uploads/entries/movies/sg-1/season-5/episode-21/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/episode-21/cover-4.jpg"
    }
}

Delete file

Request
DELETE /api/media/files
Body
Name Description
id REQUIRED Unique identifier of the file.
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns an empty body with HTTP status 204

Examples

Delete entry entries/movies/sg-1/season-5/episode-21/new-cover.jpg

Request
DELETE /api/media/files
Body
{
	"id": "entries/movies/sg-1/season-5/episode-21/new-cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}

Update File Meta

Request
PUT /api/media/files
Body
Name Description
id REQUIRED Unique identifier of the file.
field REQUIRED Field name.
value REQUIRED Field value.
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns the file object for the file that was just updated.

Examples

Update title for file entries/movies/sg-1/season-5/cover.jpg

Request
PATCH /api/media/files/meta
Body
{
    "field": "title",
    "value": "Season 5",
	"id": "entries/movies/sg-1/season-5/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Season 5",
        "filename": "cover.jpg",
        "basename": "cover-4",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5",
        "url": "project/uploads/entries/movies/sg-1/season-5/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/cover.jpg"
    }
}

Add File Meta

Request
POST /api/media/files
Body
Name Description
id REQUIRED Unique identifier of the file.
field REQUIRED Field name.
value REQUIRED Field value.
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns the file object for the file that was just updated.

Examples

Add tags for file entries/movies/sg-1/season-5/cover.jpg

Request
PATCH /api/media/files/meta
Body
{
    "field": "tags",
    "value": "sg-1, season-5",
	"id": "entries/movies/sg-1/season-5/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Season 5",
        "tags": "sg-1, season-5",
        "filename": "cover.jpg",
        "basename": "cover-4",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5",
        "url": "project/uploads/entries/movies/sg-1/season-5/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/cover.jpg"
    }
}

Delete File Meta

Request
DELETE /api/media/files
Body
Name Description
id REQUIRED Unique identifier of the file.
field REQUIRED Field name.
token REQUIRED Valid Files token.
access_token REQUIRED Valid Access token.
Result

Returns the file object for the file that was just updated.

Examples

Delete tags meta field for file entries/movies/sg-1/season-5/cover.jpg

Request
DELETE /api/media/files/meta
Body
{
    "field": "tags",
	"id": "entries/movies/sg-1/season-5/cover.jpg",
    "new_id": "entries/movies/sg-1/season-5/episode-21/cover.jpg",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "title": "Season 5",
        "filename": "cover.jpg",
        "basename": "cover-4",
        "extension": "jpg",
        "dirname": "/htdocs/flextype/project/uploads/entries/movies/sg-1/season-5",
        "url": "project/uploads/entries/movies/sg-1/season-5/cover.jpg",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/sg-1/season-5/cover.jpg"
    }
}

Media Folders

The Flextype Folders API organized around Representational State Transfer (REST) for delivering folders from Flextype to apps, websites and other. Folders are delivered as JSON data.

Endpoints

Method Endpoint Description
GET /api/media/folders Fetch folder(folders)
POST /api/media/folders Create folder
PUT /api/media/folders Move folder
PUT /api/media/folders/copy Copy folder
DELETE /api/media/folders Delete folder

Fetch Folder

Fetch single folder
Request
GET /api/media/folders?id=YOUR_FOLDER_ID&options=[]&token=YOUR_FOLDERS_TOKEN
Query
Name Description
id REQUIRED Folder id.
options OPTIONAL Array of options.
token REQUIRED Valid Folders Token.
Result

Returns the item object for the given unique identifier.

Examples

Fetch Movies Folder

Request
GET /api/media/folders?id=movies&token=6f047babd1894064fbf7662080a9a2f0
Fetch folders collection
Request
GET /api/entries?id=YOUR_FOLDER_ID&options[collection]=true&token=YOUR_FOLDERS_TOKEN
Query
Name Description
id REQUIRED Folder id.
options OPTIONAL Array of options.
token REQUIRED Valid Folders Token.
Result

Returns an array of item objects.

Examples

Fetch Movies Folders Collection

Request
GET /api/media/folders?id=entries/movies&collection=true&token=6f047babd1894064fbf7662080a9a2f0

Create folder

Request
POST /api/media/folders
Body
Name Description
id REQUIRED New folder id.
token REQUIRED Valid Folders token.
access_token REQUIRED Valid Access token.
Result

Returns the folder object for the folder that was just created.

Examples

Create new folder entries/movies/platform

Request
POST /api/media/folders
Body
{
	"id": "entries/movies/platform",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "id": "entries/movies/platform",
        "full_id": "/htdocs/flextype/project/uploads/entries/movies/platform",
        "url": "project/uploads/entries/movies/platform",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/platform"
    }
}

Move folder

Request
PUT /api/media/folders
Body
Name Description
id REQUIRED Unique identifier of the folder.
new_id REQUIRED New Unique identifier of the folder.
token REQUIRED Valid Entries token.
access_token REQUIRED Valid Access token.
Result

Returns the folders object for the folders that was just moved.

Examples

Rename entry entries/movies/platform to the entries/movies/the-platform

Request
PUT /api/media/folders
Body
{
    "id": "entries/movies/platform",
    "new_id": "entries/movies/the-platform",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "id": "entries/movies/the-platform",
        "full_id": "/htdocs/flextype/project/uploads/entries/movies/the-platform",
        "url": "project/uploads/entries/movies/the-platform",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/the-platform"
    }
}

Move entry entries/movies/the-platform to the entries/movies/2019/the-platform

Request
PUT /api/media/folders
Body
{
	"id": "entries/movies/the-platform",
    "new_id": "entries/movies/2019/the-platform",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "id": "entries/movies/2019/the-platform",
        "full_id": "/htdocs/flextype/project/uploads/entries/movies/2019/the-platform",
        "url": "project/uploads/entries/movies/2019/the-platform",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/2019/the-platform"
    }
}

Copy folder

Request
PUT /api/media/folders/copy
Body
Name Description
id REQUIRED Unique identifier of the folder.
new_id REQUIRED New Unique identifier of the folder.
token REQUIRED Valid Folders token.
access_token REQUIRED Valid Access token.
Result

Returns the folders object for the folders that was just copied.

Examples

Copy for entry entries/movies/2019/the-platform to entries/movies/horror/the-platform

Request
PUT /api/media/folders/copy
Body
{
	"id": "entries/movies/2019/the-platform",
    "new_id": "entries/movies/horror/the-platform",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}
Response
200 OK
{
    "data": {
        "id": "entries/movies/horror/the-platform",
        "full_id": "/htdocs/flextype/project/uploads/entries/movies/horror/the-platform",
        "url": "project/uploads/entries/movies/horror/the-platform",
        "full_url": "https://localhost:8888/flextype/project/uploads/entries/movies/horror/the-platform"
    }
}

Delete folder

Request
DELETE /api/media/folders
Body
Name Description
id REQUIRED Unique identifier of the folder.
token REQUIRED Valid Folders token.
access_token REQUIRED Valid Access token.
Result

Returns an empty body with HTTP status 204

Examples

Delete entry entires/movies/horror/the-platform

Request
DELETE /api/media/folders
Body
{
	"id": "entries/movies/horror/the-platform",
	"token": "f3acf199a9ac120d3bfd604e1e382456",
	"access_token": "bbc4417d171e38099bd129aeca279018"
}