Loading...
 
Skip to main content

History: Api Galleries Doc

Source of version: 19 (current)

Copy to clipboard
{DIV(class="content-section d-none" id="get-galleries")}
!!! Get all galleries.
Retrieve all galleries with optional filters and pagination.

{TABS(name="doc-get-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/galleries" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "accept: application/json" \
     --data-urlencode "galleryId=1" \
     --data-urlencode "maxRecords=2" \
     --data-urlencode "sort_mode=created_desc" \
     --data-urlencode "user=admin"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries?' . http_build_query([
    'galleryId' => 1,
    'maxRecords' => 2,
    'sort_mode' => 'created_desc',
    'user' => 'admin'
]);

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($status === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo "Error: HTTP status code $status\n";
        echo $response;
    }
}
curl_close($ch);
?>


{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const params = new URLSearchParams({
  galleryId: 1,
  maxRecords: 2,
  sort_mode: 'created_desc',
  user: 'admin'
});

fetch('https://example.com/api/galleries?' + params.toString(), {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Bearer <API_TOKEN>'
  }
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "List Galleries",
  "parentId": 1,
  "offset": 0,
  "maxRecords": 2,
  "count": 3,
  "result": [
    {
      "isgal": 1,
      "id": 7,
      "parentId": 1,
      "name": "TestArchive",
      "description": "",
      "size": 0,
      "created": 1752861115,
      "filename": "TestArchive",
      "type": "default",
      "creator": "admin",
      "author": "",
      "hits": null,
      "lastDownload": 0,
      "votes": null,
      "points": null,
      "path": "",
      "reference_url": "",
      "is_reference": "",
      "hash": "",
      "search_data": "TestArchive",
      "metadata": "",
      "lastModif": 1754752642,
      "last_user": "",
      "lockedby": "",
      "comment": "",
      "deleteAfter": "",
      "maxhits": "",
      "archiveId": 0,
      "ocr_state": "",
      "visible": "y",
      "public": "y",
      "show_source": "o",
      "files": 8,
      "fileId": 7,
      "galleryId": 1,
      "filesize": 0,
      "filetype": "default",
      "user": "admin",
      "lastModifUser": "",
      "icon_fileId": null,
      "parentName": "File Galleries",
      "perms": {
        "tiki_p_admin_file_galleries": "y",
        "tiki_p_download_files": "y",
        "tiki_p_upload_files": "y",
        "tiki_p_remove_files": "y",
        "tiki_p_list_file_galleries": "y",
        "tiki_p_view_file_gallery": "y",
        "tiki_p_create_file_galleries": "y",
        "tiki_p_edit_gallery_file": "y",
        "tiki_p_assign_perm_file_gallery": "y",
        "tiki_p_batch_upload_file_dir": "y",
        "tiki_p_batch_upload_files": "y",
        "tiki_p_view_fgal_explorer": "y",
        "tiki_p_view_fgal_path": "y",
        "tiki_p_upload_javascript": "y",
        "tiki_p_upload_svg": "y"
      },
      "podcast_filename": ""
    },
    {
      "isgal": 1,
      "id": 6,
      "parentId": 1,
      "name": "Test Gallery Archives",
      "description": "",
      "size": 0,
      "created": 1752859250,
      "filename": "Test Gallery Archives",
      "type": "default",
      "creator": "admin",
      "author": "",
      "hits": null,
      "lastDownload": 0,
      "votes": null,
      "points": null,
      "path": "",
      "reference_url": "",
      "is_reference": "",
      "hash": "",
      "search_data": "Test Gallery Archives",
      "metadata": "",
      "lastModif": 1752880273,
      "last_user": "",
      "lockedby": "",
      "comment": "",
      "deleteAfter": "",
      "maxhits": "",
      "archiveId": 0,
      "ocr_state": "",
      "visible": "y",
      "public": "y",
      "show_source": "o",
      "files": 4,
      "fileId": 6,
      "galleryId": 1,
      "filesize": 0,
      "filetype": "default",
      "user": "admin",
      "lastModifUser": "",
      "icon_fileId": null,
      "parentName": "File Galleries",
      "perms": {
        "tiki_p_admin_file_galleries": "y",
        "tiki_p_download_files": "y",
        "tiki_p_upload_files": "y",
        "tiki_p_remove_files": "y",
        "tiki_p_list_file_galleries": "y",
        "tiki_p_view_file_gallery": "y",
        "tiki_p_create_file_galleries": "y",
        "tiki_p_edit_gallery_file": "y",
        "tiki_p_assign_perm_file_gallery": "y",
        "tiki_p_batch_upload_file_dir": "y",
        "tiki_p_batch_upload_files": "y",
        "tiki_p_view_fgal_explorer": "y",
        "tiki_p_view_fgal_path": "y",
        "tiki_p_upload_javascript": "y",
        "tiki_p_upload_svg": "y"
      },
      "podcast_filename": ""
    }
  ]
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __galleryId__ ''integer Optional'': The gallery ID to filter by
* __offset__ ''integer Optional'': The offset to start from
* __maxRecords__ ''integer Optional'': The maximum number of records to return
* __sort_mode__ ''string Optional'': The sort mode. Possible values are:
** ~~#9011ff:__created_desc__~~, ~~#9011ff:__created_asc__~~, ~~#9011ff:__name_desc__~~, ~~#9011ff:__name_asc__~~
* __user__ ''string Optional'': The user (username) who created the gallery
* __find__ ''string Optional'': The search string to find galleries

{DIV}

{DIV(class="content-section d-none" id="create-galleries")}
!!! Create a new Gallery.
Create a new gallery.

{TABS(name="doc-create-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "name=Test Gallery" \
     --data-urlencode "type=default" \
     --data-urlencode "description=Test Gallery Description" \
     --data-urlencode "parentId=0"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries';
$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$data = http_build_query([
    'name' => 'Test Gallery',
    'type' => 'default',
    'description' => 'Test Gallery Description',
    'parentId' => 0
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new URLSearchParams();
formData.append("name", "Test Gallery");
formData.append("type", "default");
formData.append("description", "Test Gallery Description");
formData.append("parentId", "0");

fetch("https://example.com/api/galleries", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "info": {
    "galleryId": 11,
    "name": "Test Gallery",
    "type": "default",
    "direct": null,
    "template": null,
    "description": "Test Gallery Description",
    "created": 1760288475,
    "visible": "y",
    "lastModif": 1760288475,
    "user": "admin",
    "hits": null,
    "votes": null,
    "points": null,
    "maxRows": 10,
    "public": "y",
    "show_id": "o",
    "show_icon": "y",
    "show_name": "n",
    "show_size": "y",
    "show_description": "o",
    "max_desc": 0,
    "show_created": "o",
    "show_hits": "o",
    "show_lastDownload": "n",
    "parentId": 1,
    "lockable": "n",
    "show_lockedby": "a",
    "archives": 0,
    "sort_mode": null,
    "show_modified": "y",
    "show_author": "o",
    "show_creator": "o",
    "subgal_conf": "",
    "show_last_user": "o",
    "show_comment": "o",
    "show_files": "o",
    "show_explorer": "y",
    "show_path": "y",
    "show_slideshow": "n",
    "show_ocr_state": "n",
    "default_view": "list",
    "quota": 0,
    "size": null,
    "wiki_syntax": "",
    "backlinkPerms": "n",
    "show_backlinks": "n",
    "show_deleteAfter": "n",
    "show_checked": "y",
    "show_share": "n",
    "image_max_size_x": 0,
    "image_max_size_y": 0,
    "show_source": "o",
    "icon_fileId": null,
    "ocr_lang": "",
    "display_name_generation": null
  }
}

{CODE}
{DIV}

{TABS}

!!!! Request Body

* __name__ ''string'' ~~#fe0000:*~~: The name of the gallery
* __type__ ''string optional'': The type of the gallery. Possible values are:
** ~~#9011ff:__default__~~, ~~#9011ff:__podcast__~~, ~~#9011ff:__vidcast__~~, ~~#9011ff:__direct__~~
* __description__ ''string optional'': The description of the gallery
* __parentId__ ''integer optional'': The parent ID of the gallery

{DIV}

{DIV(class="content-section d-none" id="get-info-galleries")}
!!! Retrieve gallery information.
Retrieve detailed information about a specific gallery.

{TABS(name="doc-get-info-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{galleryId}
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/galleries/11" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/11';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
fetch("https://example.com/api/galleries/11", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>"
  }
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));


{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "galleryId": 11,
  "name": "Test Gallery",
  "type": "default",
  "direct": null,
  "template": null,
  "description": "Test Gallery Description",
  "created": 1760288475,
  "visible": "y",
  "lastModif": 1760288475,
  "user": "admin",
  "hits": null,
  "votes": null,
  "points": null,
  "maxRows": 10,
  "public": "y",
  "show_id": "o",
  "show_icon": "y",
  "show_name": "n",
  "show_size": "y",
  "show_description": "o",
  "max_desc": 0,
  "show_created": "o",
  "show_hits": "o",
  "show_lastDownload": "n",
  "parentId": 1,
  "lockable": "n",
  "show_lockedby": "a",
  "archives": 0,
  "sort_mode": null,
  "show_modified": "y",
  "show_author": "o",
  "show_creator": "o",
  "subgal_conf": "",
  "show_last_user": "o",
  "show_comment": "o",
  "show_files": "o",
  "show_explorer": "y",
  "show_path": "y",
  "show_slideshow": "n",
  "show_ocr_state": "n",
  "default_view": "list",
  "quota": 0,
  "size": null,
  "wiki_syntax": "",
  "backlinkPerms": "n",
  "show_backlinks": "n",
  "show_deleteAfter": "n",
  "show_checked": "y",
  "show_share": "n",
  "image_max_size_x": 0,
  "image_max_size_y": 0,
  "show_source": "o",
  "icon_fileId": null,
  "ocr_lang": "",
  "display_name_generation": null
}

{CODE}
{DIV}

{TABS}

!!!! Parameters

* __galleryId__ ''integer'' ~~#fe0000:*~~: The ID of the gallery to retrieve

{DIV}

{DIV(class="content-section d-none" id="update-galleries")}
!!! Update an existing gallery.
Update an existing gallery.

{TABS(name="doc-update-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{galleryId}/update
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/11/update" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "name=Test Gallery Updated" \
     --data-urlencode "type=default" \
     --data-urlencode "description=Test Gallery Updated Description"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/11/update';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$data = http_build_query([
    'name' => 'Test Gallery Updated',
    'type' => 'default',
    'description' => 'Test Gallery Updated Description'
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new URLSearchParams();
formData.append("name", "Test Gallery Updated");
formData.append("type", "default");
formData.append("description", "Test Gallery Updated Description");

fetch("https://example.com/api/galleries/11/update", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer xxxx",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "info": {
    "galleryId": 11,
    "name": "Test Gallery Updated",
    "type": "default",
    "direct": null,
    "template": null,
    "description": "Test Gallery Updated Description",
    "created": 1760288475,
    "visible": "y",
    "lastModif": 1760292310,
    "user": "admin",
    "hits": null,
    "votes": null,
    "points": null,
    "maxRows": 10,
    "public": "y",
    "show_id": "o",
    "show_icon": "y",
    "show_name": "n",
    "show_size": "y",
    "show_description": "o",
    "max_desc": 0,
    "show_created": "o",
    "show_hits": "o",
    "show_lastDownload": "n",
    "parentId": 1,
    "lockable": "n",
    "show_lockedby": "a",
    "archives": 0,
    "sort_mode": null,
    "show_modified": "y",
    "show_author": "o",
    "show_creator": "o",
    "subgal_conf": "",
    "show_last_user": "o",
    "show_comment": "o",
    "show_files": "o",
    "show_explorer": "y",
    "show_path": "y",
    "show_slideshow": "n",
    "show_ocr_state": "n",
    "default_view": "list",
    "quota": 0,
    "size": null,
    "wiki_syntax": "",
    "backlinkPerms": "n",
    "show_backlinks": "n",
    "show_deleteAfter": "n",
    "show_checked": "y",
    "show_share": "n",
    "image_max_size_x": 0,
    "image_max_size_y": 0,
    "show_source": "o",
    "icon_fileId": null,
    "ocr_lang": "",
    "display_name_generation": null
  }
}

{CODE}
{DIV}

{TABS}

!!!! Parameters

* __galleryId__ ''integer'' ~~#fe0000:*~~: The ID of the gallery to update

!!!! Request Body

* __name__ ''string'' ~~#fe0000:*~~: The name of the gallery
* __type__ ''string optional'': The type of the gallery. Possible values are:
** ~~#9011ff:__default__~~, ~~#9011ff:__podcast__~~, ~~#9011ff:__vidcast__~~, ~~#9011ff:__direct__~~
* __description__ ''string optional'': The description of the gallery

{DIV}

{DIV(class="content-section d-none" id="move-galleries")}
!!! Move a gallery.
Move a gallery to a different parent gallery.

{TABS(name="doc-move-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{galleryId}/move
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/11/move" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "newParentId=7"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/11/move';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$data = http_build_query([
    'newParentId' => 7
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new URLSearchParams();
formData.append("newParentId", "7");

fetch("https://example.com/api/galleries/11/move", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Move File Gallery",
  "message": "The file gallery 11 has been moved"
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __galleryId__ ''integer'' ~~#fe0000:*~~: The ID of the gallery to move

!!!! Request Body

* __newParentId__ ''integer'' ~~#fe0000:*~~: The destination gallery ID to which the gallery will be moved

{DIV}

{DIV(class="content-section d-none" id="duplicate-galleries")}
!!! Create a duplicate of an existing gallery.
Create a duplicate of an existing gallery.

{TABS(name="doc-duplicate-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{galleryId}/duplicate
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/11/duplicate" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "name=Test Gallery Duplicated" \
     --data-urlencode "description=Test Gallery Duplicated Description"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/11/duplicate';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$data = http_build_query([
    'name' => 'Test Gallery Duplicated',
    'description' => 'Test Gallery Duplicated Description'
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new URLSearchParams();
formData.append("name", "Test Gallery Duplicated");
formData.append("description", "Test Gallery Duplicated Description");

fetch("https://example.com/api/galleries/11/duplicate", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Duplicate File Gallery",
  "message": "File Gallery duplicated successfully",
  "id": "13"
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __galleryId__ ''integer'' ~~#fe0000:*~~: The ID of the gallery to duplicate

!!!! Request Body

* __name__ ''string'' ~~#fe0000:*~~: The name of the new duplicated gallery
* __description__ ''string'' ~~#fe0000:*~~: The description of the duplicated gallery

{DIV}

{DIV(class="content-section d-none" id="delete-galleries")}
!!! Delete a gallery
Delete a gallery.

{TABS(name="doc-delete-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{id}/delete
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request DELETE \
     --url "https://example.com/api/galleries/13/delete" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "galleryId=7" \
     --data-urlencode "recurse=true"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/13/delete';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$data = http_build_query([
    'galleryId' => 7,
    'recurse' => true
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new URLSearchParams();
formData.append("galleryId", "7");
formData.append("recurse", "true");

fetch("https://example.com/api/galleries/13/delete", {
  method: "DELETE",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Fetch error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Delete File Gallery",
  "message": "The file gallery 13 has been deleted"
}
{CODE}
{DIV}

{TABS}

!!!! Parameters

* __id__ ''integer'' ~~#fe0000:*~~: The ID of the gallery to delete

!!!! Request Body

* __galleryId__ ''integer'' ~~#fe0000:*~~: The parent gallery ID of the gallery being removed
* __recurse__ ''boolean'' optional: Whether to also remove sub-galleries and files (~~#9011ff:__true__~~ as default). Possible values are:
** ~~#9011ff:__true__~~ : remove all
** ~~#9011ff:__false__~~ : only this gallery

{DIV}

{DIV(class="content-section d-none" id="upload-galleries")}
!!! Upload a file into a gallery
Upload a file into a gallery or update an existing file.

{TABS(name="doc-upload-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/upload
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/upload" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: multipart/form-data" \
     --form "galleryId=11" \
     --form "fileId=" \
     --form "data=@Wiki_Syntax.pdf;type=application/pdf" \
     --form "user=admin" \
     --form "title=Wiki Syntax Title" \
     --form "name=Wiki Syntax" \
     --form "description=Wiki Syntax Description"

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/upload';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$postFields = [
    'galleryId' => 11,
    'fileId' => '',
    'data' => new CURLFile('/path/to/Wiki_Syntax.pdf', 'application/pdf', 'Wiki_Syntax.pdf'),
    'user' => 'admin',
    'title' => 'Wiki Syntax Title',
    'name' => 'Wiki Syntax',
    'description' => 'Wiki Syntax Description'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new FormData();
formData.append("galleryId", "11");
formData.append("fileId", "");
formData.append("data", new File([""], "Wiki_Syntax.pdf", { type: "application/pdf" }));
formData.append("user", "admin");
formData.append("title", "Wiki Syntax Title");
formData.append("name", "Wiki Syntax");
formData.append("description", "Wiki Syntax Description");

fetch("https://example.com/api/galleries/upload", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer <API_TOKEN>"
  },
  body: formData
})
.then(response => {
  if (!response.ok) throw new Error("HTTP " + response.status);
  return response.json();
})
.then(data => console.log(data))
.catch(error => console.error("Upload error:", error));

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "size": 91735,
  "name": "Wiki_Syntax.pdf",
  "title": "Wiki Syntax Title",
  "description": "Wiki Syntax Description",
  "type": "application/pdf",
  "fileId": "36",
  "galleryId": 11,
  "md5sum": "fa7e725936a48fe1c484e92fe394ddf2",
  "ticket": "9GKE_wo037vq-dwfF6uOYXUsF4VA_g8qqH7cqOcbPU0",
  "syntax": "{file type=\"gallery\" fileId=\"36\" showicon=\"y\"}",
  "info": {
    "fileId": 36,
    "galleryId": 11,
    "name": "Wiki Syntax Title",
    "description": "Wiki Syntax Description",
    "created": 1760298353,
    "filename": "Wiki_Syntax.pdf",
    "filesize": 91735,
    "filetype": "application/pdf",
    "user": "admin",
    "hash": "fa7e725936a48fe1c484e92fe394ddf2",
    "lastModif": 1760298353,
    "lastModifUser": "admin"
  }
}

{CODE}
{DIV}

{TABS}


!!!! Request body

* __galleryId__ ''integer'' : The gallery ID where the file will be uploaded
* __fileId__ ''integer'' optional: The file ID to update — if provided, replaces the existing file
* __data__ ''file'' ~~#fe0000:*~~: File path to upload
* __user__ ''string'' optional: The user uploading the file
* __title__ ''string'' optional: The title of the file
* __name__ ''string'' optional: The name of the file
* __description__ ''string'' optional: The description of the file

{DIV}


{DIV(class="content-section d-none" id="download-galleries")}
!!! Download a file
Download a file by its file ID.

{TABS(name="doc-download-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{fileId}/download
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/galleries/36/download" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --output "Wiki_Syntax.pdf"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/36/download';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $filePath = __DIR__ . '/Wiki_Syntax.pdf';
        file_put_contents($filePath, $response);
        echo "File downloaded successfully to: $filePath\n";
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
import fs from "fs";
import fetch from "node-fetch";

const url = "https://example.com/api/galleries/36/download";
const headers = {
  "Accept": "application/json",
  "Authorization": "Bearer <API_TOKEN>"
};

fetch(url, { method: "GET", headers })
  .then(response => {
    if (!response.ok) throw new Error("HTTP " + response.status);
    return response.arrayBuffer();
  })
  .then(buffer => {
    const filePath = "./Wiki_Syntax.pdf";
    fs.writeFileSync(filePath, Buffer.from(buffer));
    console.log("File downloaded successfully:", filePath);
  })
  .catch(error => console.error("Download error:", error));
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
Binary file response (application/pdf or other file type)
{CODE}
{DIV}

{TABS}


!!!! Parameters

* __fileId__ ''integer'' ~~#fe0000:*~~: The ID of the file to download

{DIV}

{DIV(class="content-section d-none" id="list-files-galleries")}
!!! Retrieve All Files of a Gallery
Retrieve all files belonging to a specific gallery.

{TABS(name="doc-list-files-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/{galleryId}/list_files
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/galleries/11/list_files" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --data-urlencode "maxRecords=5" \
     --data-urlencode "sort_mode=name_asc" \
     --data-urlencode "user=admin"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$base_url = 'https://example.com/api/galleries/11/list_files';

$params = [
    'maxRecords' => 5,
    'sort_mode' => 'name_asc',
    'user' => 'admin'
];

$url = $base_url . '?' . http_build_query($params);

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const params = new URLSearchParams({
  maxRecords: '5',
  sort_mode: 'name_asc',
  user: 'admin'
});

fetch('https://example.com/api/galleries/11/list_files?' + params.toString(), {
    method: 'GET',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>'
    }
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "List files",
  "galleryId": 11,
  "offset": -1,
  "maxRecords": 5,
  "count": 1,
  "result": [
    {
      "isgal": 0,
      "id": 36,
      "parentId": 11,
      "name": "Wiki Syntax Title",
      "description": "Wiki Syntax Description",
      "size": 91735,
      "created": 1760298353,
      "filename": "Wiki_Syntax.pdf",
      "type": "application/pdf",
      "creator": "admin",
      "author": "",
      "hits": 0,
      "lastDownload": 0,
      "votes": 0,
      "points": "0.00",
      "path": null,
      "reference_url": "",
      "is_reference": "",
      "hash": "fa7e725936a48fe1c484e92fe394ddf2",
      "search_data": "",
      "metadata": "{\"basiconly\":true,\"Basic Information\":{\"File Data\":{\"size\":{\"newval\":91735,\"label\":\"File Size\",\"suffix\":\"bytes\"},\"type\":{\"newval\":\"application\\/pdf\",\"label\":\"File Type\"},\"charset\":{\"newval\":\"charset=binary\",\"label\":\"Character Set\"},\"devices\":{\"newval\":\"PDF document, version 1.4, 5 pages\",\"label\":\"Devices\"}}}}",
      "lastModif": 1760298353,
      "last_user": "admin",
      "lockedby": "",
      "comment": "",
      "deleteAfter": 0,
      "maxhits": 0,
      "archiveId": 0,
      "ocr_state": null,
      "visible": "",
      "public": "",
      "source": "",
      "files": "",
      "fileId": 36,
      "galleryId": 11,
      "filesize": 91735,
      "filetype": "application/pdf",
      "user": "admin",
      "lastModifUser": "admin",
      "icon_fileId": 0,
      "perms": {
        "tiki_p_admin_file_galleries": "y",
        "tiki_p_download_files": "y",
        "tiki_p_upload_files": "y",
        "tiki_p_remove_files": "y",
        "tiki_p_list_file_galleries": "y",
        "tiki_p_view_file_gallery": "y",
        "tiki_p_create_file_galleries": "y",
        "tiki_p_edit_gallery_file": "y",
        "tiki_p_assign_perm_file_gallery": "y",
        "tiki_p_batch_upload_file_dir": "y",
        "tiki_p_batch_upload_files": "y",
        "tiki_p_view_fgal_explorer": "y",
        "tiki_p_view_fgal_path": "y",
        "tiki_p_upload_javascript": "y",
        "tiki_p_upload_svg": "y"
      },
      "wiki_syntax": "",
      "share": null,
      "podcast_filename": null
    }
  ]
}
{CODE}
{DIV}

{TABS}


!!!! Parameters

* __galleryId__ ''integer'' ~~#fe0000:*~~: The gallery ID to retrieve files from
* __offset__ ''integer optional'' : Start offset for the number of records to return
* __maxRecords__ ''integer optional'' : Maximum number of records to return
* __sort_mode__ ''string optional'' : The sort mode. Possible values are:
** ~~#9011ff:__created_desc__~~, ~~#9011ff:__created_asc__~~, ~~#9011ff:__name_desc__~~, ~~#9011ff:__name_asc__~~
* __user__ ''string optional'' : Username who created the gallery
* __find__ ''string optional'' : Search string to find files

{DIV}

{DIV(class="content-section d-none" id="file-info-galleries")}
!!! Retrieve file information

Retrieve detailed information about a specific file stored in a gallery.

{TABS(name="doc-file-info-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/{fileId}
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request GET \
     --url "https://example.com/api/galleries/files/36" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/36';
$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);
?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
fetch('https://example.com/api/galleries/files/36', {
    method: 'GET',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>'
    }
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "File Info",
  "fileId": 36,
  "info": {
    "fileId": 36,
    "galleryId": 11,
    "name": "Wiki Syntax Title",
    "description": "Wiki Syntax Description",
    "created": 1760298353,
    "filename": "Wiki_Syntax.pdf",
    "filesize": 91735,
    "filetype": "application/pdf",
    "user": "admin",
    "author": "",
    "hits": 0,
    "maxhits": 0,
    "lastDownload": 0,
    "votes": 0,
    "points": "0.00",
    "path": null,
    "reference_url": "",
    "is_reference": "",
    "hash": "fa7e725936a48fe1c484e92fe394ddf2",
    "metadata": "{\"basiconly\":true,\"Basic Information\":{\"File Data\":{\"size\":{\"newval\":91735,\"label\":\"File Size\",\"suffix\":\"bytes\"},\"type\":{\"newval\":\"application/pdf\",\"label\":\"File Type\"}}}}",
    "lastModif": 1760298353,
    "lastModifUser": "admin"
  }
}

{CODE}
{DIV}

{TABS}


!!!! Parameters

* __fileId__ ''integer'' ~~#fe0000:*~~: The file ID to retrieve information for

{DIV}

{DIV(class="content-section d-none" id="file-update-galleries")}
!!! Update file

Update file information or upload a new version of an existing file in a gallery.

{TABS(name="doc-file-update-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/{fileId}/update
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/files/36/update" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: multipart/form-data" \
     --form "data=@Basic_Data_types.pdf;type=application/pdf" \
     --form "user=admin" \
     --form "title=Data Types Title" \
     --form "name=Data Types Name" \
     --form "description=Data Types Description"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/36/update';
$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$postFields = [
    'data' => new CURLFile('Basic_Data_types.pdf', 'application/pdf'),
    'user' => 'admin',
    'title' => 'Data Types Title',
    'name' => 'Data Types Name',
    'description' => 'Data Types Description'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const formData = new FormData();
formData.append('data', new File([''], 'Basic_Data_types.pdf', { type: 'application/pdf' }));
formData.append('user', 'admin');
formData.append('title', 'Data Types Title');
formData.append('name', 'Data Types Name');
formData.append('description', 'Data Types Description');

fetch('https://example.com/api/galleries/files/36/update', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>'
    },
    body: formData
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "size": 74379,
  "name": "Basic_Data_types.pdf",
  "title": "Data Types Title",
  "description": "Data Types Description",
  "type": "application/pdf",
  "fileId": 36,
  "galleryId": 11,
  "md5sum": "85e3fb25232dc91a7bd14b6a3b2ff86d",
  "ticket": "9GKE_wo037vq-dwfF6uOYXUsF4VA_g8qqH7cqOcbPU0",
  "syntax": "{file type=\"gallery\" fileId=\"36\" showicon=\"y\"}",
  "info": {
    "fileId": 36,
    "galleryId": 11,
    "name": "Data Types Title",
    "description": "Data Types Description",
    "created": 1760298353,
    "filename": "Basic_Data_types.pdf",
    "filesize": 74379,
    "filetype": "application/pdf",
    "user": "admin",
    "author": "",
    "hits": 0,
    "maxhits": 0,
    "lastDownload": 0,
    "votes": 0,
    "points": "0.00",
    "path": null,
    "reference_url": "",
    "is_reference": "",
    "hash": "85e3fb25232dc91a7bd14b6a3b2ff86d",
    "search_data": "",
    "metadata": "{\"basiconly\":true,\"Basic Information\":{\"File Data\":{\"size\":{\"newval\":74379,\"label\":\"File Size\",\"suffix\":\"bytes\"},\"type\":{\"newval\":\"application\\/pdf\",\"label\":\"File Type\"},\"charset\":{\"newval\":\"charset=binary\",\"label\":\"Character Set\"},\"devices\":{\"newval\":\"PDF document, version 1.4, 2 pages\",\"label\":\"Devices\"}}}}",
    "lastModif": 1760384759,
    "lastModifUser": "admin",
    "lockedby": "",
    "comment": "",
    "archiveId": 0,
    "deleteAfter": 0,
    "ocr_state": null,
    "ocr_lang": null,
    "ocr_data": null
  }
}
{CODE}
{DIV}

{TABS}


!!!! Parameters

* __fileId__ ''integer'' ~~#fe0000:*~~: The file ID to update

!!!! Request body

* __data__ ''file optional'': File to upload (omit to keep current file unchanged)
* __user__ ''string optional'': The user who uploaded the file
* __title__ ''string optional'': The title of the file
* __name__ ''string optional'': The name of the file
* __description__ ''string optional'': The description of the file

{DIV}

{DIV(class="content-section d-none" id="file-duplicate-galleries")}
!!! Duplicate an existing file

Duplicate an existing file to a new location or with a new name/description.

{TABS(name="doc-file-duplicate-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/{fileId}/duplicate
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/files/36/duplicate" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "newName=Duplicated Data Types Name" \
     --data-urlencode "description=Duplicated Data Types Description"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/36/duplicate';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$postFields = http_build_query([
    'newName' => 'Duplicated Data Types Name',
    'description' => 'Duplicated Data Types Description'
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const params = new URLSearchParams({
  newName: 'Duplicated Data Types Name',
  description: 'Duplicated Data Types Description'
});

fetch('https://example.com/api/galleries/files/36/duplicate', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: params.toString()
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Duplicate file",
  "message": "File duplicated successfully",
  "id": "45"
}
{CODE}
{DIV}

{TABS}


!!!! Parameters

* __fileId__ ''integer'' ~~#fe0000:*~~: The ID of the file to duplicate

!!!! Request body

* __galleryId__ ''integer optional'': Destination gallery ID for the duplicated file (defaults to current gallery if omitted)
* __newName__ ''string optional'': New name for the duplicated file
* __description__ ''string optional'': New description for the duplicated file

{DIV}

{DIV(class="content-section d-none" id="file-lock-galleries")}
!!! Lock one or multiple files

Lock one or multiple files to prevent updating or deletion.

{TABS(name="doc-file-lock-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/lock
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/files/lock" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "items[]=36" \
     --data-urlencode "items[]=45"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/lock';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$postFields = http_build_query([
    'items' => [36, 45]
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const params = new URLSearchParams();
params.append('items[]', '36');
params.append('items[]', '45');

fetch('https://example.com/api/galleries/files/lock', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: params.toString()
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Lock files",
  "count": 2,
  "locked": [
    "36",
    "45"
  ]
}
{CODE}
{DIV}

{TABS}


!!!! Request body

* __items[]__ ''array'' ~~#fe0000:*~~: Array of file IDs to lock
  
{DIV}

{DIV(class="content-section d-none" id="file-unlock-galleries")}
!!! Unlock one or multiple files

Unlock one or multiple files to allow updating or deletion.

{TABS(name="doc-file-unlock-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/unlock
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request POST \
     --url "https://example.com/api/galleries/files/unlock" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>" \
     --header "Content-Type: application/x-www-form-urlencoded" \
     --data-urlencode "items[]=36" \
     --data-urlencode "items[]=45"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/unlock';

$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>',
    'Content-Type: application/x-www-form-urlencoded'
];

$postFields = http_build_query([
    'items' => [36, 45]
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
const params = new URLSearchParams();
params.append('items[]', '36');
params.append('items[]', '45');

fetch('https://example.com/api/galleries/files/unlock', {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: params.toString()
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Unlock files",
  "count": 2,
  "unlocked": [
    "36",
    "45"
  ]
}
{CODE}
{DIV}

{TABS}


!!!! Request body

* __items[]__ ''array'' ~~#fe0000:*~~: Array of file IDs to unlock

{DIV}


{DIV(class="content-section d-none" id="file-delete-galleries")}
!!! Remove a specific file from a gallery.

Remove a specific file from a gallery.

{TABS(name="doc-file-delete-galleries" tabs="Request URL| cURL | PHP | JavaScript | Response" toggle="y" inside_pretty="n")}

{DIV()}
{CODE(caption="Request URL - galleries" colors="http" theme="default")}
https://example.com/api/galleries/files/{fileId}/delete
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="cURL - galleries" colors="http" theme="default")}
curl --request DELETE \
     --url "https://example.com/api/galleries/files/45/delete" \
     --header "accept: application/json" \
     --header "Authorization: Bearer <API_TOKEN>"
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="PHP - galleries" colors="php" theme="default")}
<?php

$url = 'https://example.com/api/galleries/files/45/delete';
$headers = [
    'Accept: application/json',
    'Authorization: Bearer <API_TOKEN>'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_code === 200) {
        $data = json_decode($response, true);
        print_r($data);
    } else {
        echo 'Error: HTTP status code ' . $http_code;
    }
}

curl_close($ch);

?>
{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Javascript - galleries" colors="javascript" theme="default")}
fetch('https://example.com/api/galleries/files/45/delete', {
    method: 'DELETE',
    headers: {
      'Accept': 'application/json',
      'Authorization': 'Bearer <API_TOKEN>'
    }
  })
  .then(res => {
    if (!res.ok) throw new Error("HTTP " + res.status);
    return res.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log('Fetch error: ' + err.message);
  });

{CODE}
{DIV}

/////
{DIV()}
{CODE(caption="Response - galleries" colors="json" theme="default")}
{
  "title": "Delete File",
  "message": "The file 45 has been deleted"
}
{CODE}
{DIV}

{TABS}


!!!! Parameters

* __fileId__ ''integer'' ~~#fe0000:*~~: The ID of the file to delete

{DIV}

Show PHP error messages