{"id":444451,"date":"2026-04-03T02:43:16","date_gmt":"2026-04-03T00:43:16","guid":{"rendered":"https:\/\/www.kafinea.com\/documentation\/uncategorized\/rest-api-file-management\/"},"modified":"2026-04-03T02:43:16","modified_gmt":"2026-04-03T00:43:16","password":"","slug":"rest-api-file-management","status":"publish","type":"docs","link":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/","title":{"rendered":"REST API &#8211; File Management"},"content":{"rendered":"<p>Uploading a file involves several steps: create a document, upload the file, then link them.<\/p>\n<hr>\n<h2>Step 1: Get the Folder&#8217;s Webservice ID<\/h2>\n<p>To create a document, you need the Webservice ID of the target folder. Use a <code>query<\/code> operation: <\/p>\n<p><strong>Curl example:<\/strong><\/p>\n<pre><code class=\"language-bash\">curl \"https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=query&sessionName=YOUR_SESSION_ID&query=SELECT%20id%20FROM%20DocumentFolders%20WHERE%20foldername%20LIKE%20'Default'%20LIMIT%201%20;\"\n<\/code><\/pre>\n<p><strong>Request:<\/strong><\/p>\n<pre><code class=\"language-sql\">SELECT id FROM DocumentFolders WHERE foldername LIKE 'Default' LIMIT 1 ;\n<\/code><\/pre>\n<hr>\n<h2>Step 2: Create a Document Entity<\/h2>\n<p>Create a <code>Documents<\/code> type entity via the <code>create<\/code> operation.<\/p>\n<blockquote>\n<p><strong>POST<\/strong> <code>https:\/\/apps.kafinea.com\/{instance}\/webservice.php<\/code><\/p>\n<\/blockquote>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Type<\/th>\n<th>Required<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>operation<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Must be  <code>create<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>sessionName<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Session ID<\/td>\n<\/tr>\n<tr>\n<td><code>element<\/code><\/td>\n<td>JSON<\/td>\n<td>yes<\/td>\n<td>Document JSON object (see fields below)<\/td>\n<\/tr>\n<tr>\n<td><code>elementType<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Must be  <code>Documents<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><strong><code>element<\/code> object fields:<\/strong><\/p>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Type<\/th>\n<th>Required<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>notes_title<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Document entity name<\/td>\n<\/tr>\n<tr>\n<td><code>folderid<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Folder Webservice ID (step 1)<\/td>\n<\/tr>\n<tr>\n<td><code>filename<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>File name<\/td>\n<\/tr>\n<tr>\n<td><code>filetype<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>MIME type (e.g., <code>application\/pdf<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>filesize<\/code><\/td>\n<td>int<\/td>\n<td>yes<\/td>\n<td>File size in bytes<\/td>\n<\/tr>\n<tr>\n<td><code>filestatus<\/code><\/td>\n<td>int<\/td>\n<td>yes<\/td>\n<td><code>1<\/code>  for active<\/td>\n<\/tr>\n<tr>\n<td><code>filelocationtype<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td><code>I<\/code>  for internal storage<\/td>\n<\/tr>\n<tr>\n<td><code>assigned_user_id<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Assigned user&#8217;s Webservice ID<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><strong>Curl example:<\/strong><\/p>\n<pre><code class=\"language-bash\">curl -X POST https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php \\\n  -d \"operation=create\" \\\n  -d \"sessionName=YOUR_SESSION_ID\" \\\n  -d 'element={\"notes_title\":\"Mon document\",\"folderid\":\"65x1\",\"filename\":\"rapport.pdf\",\"filetype\":\"application\/pdf\",\"filesize\":12345,\"filestatus\":1,\"filelocationtype\":\"I\",\"assigned_user_id\":\"19x1\"}' \\\n  -d \"elementType=Documents\"\n<\/code><\/pre>\n<hr>\n<h2>Step 3: Upload the file (FileUpload)<\/h2>\n<p>This operation uploads the file and links it to the created document. It can also be used alone to add images to products (replace <code>attachmentType<\/code> with <code>Image<\/code> and <code>parentId<\/code> with the product&#8217;s Webservice ID). <\/p>\n<blockquote>\n<p><strong>POST<\/strong> <code>https:\/\/apps.kafinea.com\/{instance}\/webservice.php<\/code><\/p>\n<\/blockquote>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Type<\/th>\n<th>Required<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>operation<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Must be  <code>FileUpload<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>sessionName<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Session ID<\/td>\n<\/tr>\n<tr>\n<td><code>parentId<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Document Webservice ID (step 2)<\/td>\n<\/tr>\n<tr>\n<td><code>attachmentType<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td><code>Attachment<\/code>  for a file, <code>Image<\/code> for an image<\/td>\n<\/tr>\n<tr>\n<td><code>fileName<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>File name<\/td>\n<\/tr>\n<tr>\n<td><code>fileContents<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>File content encoded in base64<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><strong>Curl example:<\/strong><\/p>\n<pre><code class=\"language-bash\">curl -X POST https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php \\\n  -d \"operation=FileUpload\" \\\n  -d \"sessionName=YOUR_SESSION_ID\" \\\n  -d \"parentId=15x7890\" \\\n  -d \"attachmentType=Attachment\" \\\n  -d \"fileName=rapport.pdf\" \\\n  -d \"fileContents=$(base64 -w0 rapport.pdf)\"\n<\/code><\/pre>\n<hr>\n<h2>Retrieve a file (files_retrieve)<\/h2>\n<p>Retrieves a file previously added to Kafinea. You need the WebserviceID of the <strong>file<\/strong> (not to be confused with that of the Document entity). <\/p>\n<blockquote>\n<p><strong>GET<\/strong> <code>https:\/\/apps.kafinea.com\/{instance}\/webservice.php<\/code><\/p>\n<\/blockquote>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Type<\/th>\n<th>Required<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>operation<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Must be  <code>files_retrieve<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>sessionName<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Session ID<\/td>\n<\/tr>\n<tr>\n<td><code>id<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>File Webservice ID<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><strong>Curl example:<\/strong><\/p>\n<pre><code class=\"language-bash\">curl \"https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=files_retrieve&sessionName=YOUR_SESSION_ID&id=28x5678\"\n<\/code><\/pre>\n<hr>\n<h2>Related references \ud83d\udd17<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.kafinea.com\/en\/documentation\/api\/rest-api-crud-operations\/\">CRUD Operations<\/a><\/li>\n<li><a href=\"https:\/\/www.kafinea.com\/en\/documentation\/api\/rest-api-entity-relationships\/\">Related Operations<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Uploading a file involves several steps: create a document, upload the file, then link them. Step 1: Get the Folder&#8217;s Webservice ID To create a document, you need the Webservice ID of the target folder. Use a query operation: Curl example: curl &#8220;https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=query&#038;sessionName=YOUR_SESSION_ID&#038;query=SELECT%20id%20FROM%20DocumentFolders%20WHERE%20foldername%20LIKE%20&#8217;Default&#8217;%20LIMIT%201%20;&#8221; Request: SELECT id FROM DocumentFolders WHERE foldername LIKE &#8216;Default&#8217; LIMIT 1 ;&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"doc_category":[759],"doc_tag":[],"class_list":["post-444451","docs","type-docs","status-publish","hentry","doc_category-api"],"year_month":"2026-08","word_count":448,"total_views":"1","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"David Valminos","author_nicename":"david","author_url":"https:\/\/www.kafinea.com\/en\/author\/david\/"},"doc_category_info":[{"term_name":"API","term_url":"https:\/\/www.kafinea.com\/en\/help\/api\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Help - REST API - File Management &#8226; Kafinea<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Help - REST API - File Management &#8226; Kafinea\" \/>\n<meta property=\"og:description\" content=\"Uploading a file involves several steps: create a document, upload the file, then link them. Step 1: Get the Folder&#8217;s Webservice ID To create a document, you need the Webservice ID of the target folder. Use a query operation: Curl example: curl &quot;https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=query&amp;sessionName=YOUR_SESSION_ID&amp;query=SELECT%20id%20FROM%20DocumentFolders%20WHERE%20foldername%20LIKE%20&#039;Default&#039;%20LIMIT%201%20;&quot; Request: SELECT id FROM DocumentFolders WHERE foldername LIKE &#039;Default&#039; LIMIT 1 ;...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/\" \/>\n<meta property=\"og:site_name\" content=\"Kafinea\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-file-management\\\/\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-file-management\\\/\",\"name\":\"Help - REST API - File Management &#8226; Kafinea\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#website\"},\"datePublished\":\"2026-04-03T00:43:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-file-management\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-file-management\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-file-management\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"REST API &#8211; File Management\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\",\"name\":\"Kafinea\",\"description\":\"Une solution unique pour toutes vos ambitions\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#organization\",\"name\":\"Kafinea\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/Logo-Kafinea-SVG-orange-bleu.svg\",\"contentUrl\":\"https:\\\/\\\/www.kafinea.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/Logo-Kafinea-SVG-orange-bleu.svg\",\"width\":296.31,\"height\":66.48,\"caption\":\"Kafinea\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/company\\\/kafinea\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Help - REST API - File Management &#8226; Kafinea","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/","og_locale":"en_US","og_type":"article","og_title":"Help - REST API - File Management &#8226; Kafinea","og_description":"Uploading a file involves several steps: create a document, upload the file, then link them. Step 1: Get the Folder&#8217;s Webservice ID To create a document, you need the Webservice ID of the target folder. Use a query operation: Curl example: curl \"https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=query&sessionName=YOUR_SESSION_ID&query=SELECT%20id%20FROM%20DocumentFolders%20WHERE%20foldername%20LIKE%20'Default'%20LIMIT%201%20;\" Request: SELECT id FROM DocumentFolders WHERE foldername LIKE 'Default' LIMIT 1 ;...","og_url":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/","og_site_name":"Kafinea","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/","url":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/","name":"Help - REST API - File Management &#8226; Kafinea","isPartOf":{"@id":"https:\/\/www.kafinea.com\/en\/#website"},"datePublished":"2026-04-03T00:43:16+00:00","breadcrumb":{"@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-file-management\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.kafinea.com\/en\/"},{"@type":"ListItem","position":2,"name":"REST API &#8211; File Management"}]},{"@type":"WebSite","@id":"https:\/\/www.kafinea.com\/en\/#website","url":"https:\/\/www.kafinea.com\/en\/","name":"Kafinea","description":"Une solution unique pour toutes vos ambitions","publisher":{"@id":"https:\/\/www.kafinea.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kafinea.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.kafinea.com\/en\/#organization","name":"Kafinea","url":"https:\/\/www.kafinea.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kafinea.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.kafinea.com\/wp-content\/uploads\/2024\/10\/Logo-Kafinea-SVG-orange-bleu.svg","contentUrl":"https:\/\/www.kafinea.com\/wp-content\/uploads\/2024\/10\/Logo-Kafinea-SVG-orange-bleu.svg","width":296.31,"height":66.48,"caption":"Kafinea"},"image":{"@id":"https:\/\/www.kafinea.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/company\/kafinea\/"]}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"David Valminos","author_link":"https:\/\/www.kafinea.com\/en\/author\/david\/"},"uagb_comment_info":0,"uagb_excerpt":"Uploading a file involves several steps: create a document, upload the file, then link them. Step 1: Get the Folder&#8217;s Webservice ID To create a document, you need the Webservice ID of the target folder. Use a query operation: Curl example: curl \"https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php?operation=query&sessionName=YOUR_SESSION_ID&query=SELECT%20id%20FROM%20DocumentFolders%20WHERE%20foldername%20LIKE%20'Default'%20LIMIT%201%20;\" Request: SELECT id FROM DocumentFolders WHERE foldername LIKE 'Default' LIMIT 1 ;...","_links":{"self":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs\/444451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/comments?post=444451"}],"version-history":[{"count":0,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs\/444451\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/media?parent=444451"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/doc_category?post=444451"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/doc_tag?post=444451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}