Files API
POST https://admin.threekit.com/api/files
Takes posted files and uploads any not already present on CDN, creates database entries for each file and returns in response.body.files
REST Endpoint
POST https://admin.threekit.com/api/files
Query Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | true | Includes form data for files under the field 'files' |
» additionalProperties | body | string(binary) | false | File to upload |
Body Parameters
property1: string
property2: string
Response Codes
property1: string
property2: string
Status | Meaning | Description | Schema |
---|---|---|---|
201 | Created | Successful post request, response body will include files field containing an array of the created model entries | None |
400 | Bad Request | Request was poorly formed | None |
401 | Unauthorized | User has not authenticated and must authenticate before using this service | None |
403 | Forbidden | User has authenticated but lacks authorization to use this service | None |
Example Implementations
Code
CURL
curl --request POST \
--url https://admin.threekit.com/api/files \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--form property1=string \
--form property2=string
Node.JS
var http = require("https");
var options = {
"method": "POST",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files",
"headers": {
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property1\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property2\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n");
req.end();
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property1\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property2\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => array(
"content-type: multipart/form-data; boundary=---011000010111000001101001"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Example responses
{
"message": "Successful post request",
"files": [
{
"id": "7bde2d6c-7b9e-4933-832e-5da64879b4f0",
"userId": "320b39bb-0653-4ad7-ac68-7d5f016b0da3",
"filename": "MyPicture.jpg",
"createdAt": "2018-11-22T19:16:51.907Z",
"size": 3574392,
"hash": "sha256-9603b80dbcc6577f6b839e2a5e456f6df8a1434a06ca5b295f283b623be25efe",
"extension": ".jpg",
"type": "image/jpeg",
"encodings": {
"raw": {
"size": 3574392
}
}
}
]
}
{
"message": "Post request was poorly formed",
"error": {
"type": "missing_files_error",
"message": "Files must be included under the 'files' field to perform request"
}
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
GET https://admin.threekit.com/api/files/{id}
curl --request POST \
--url https://admin.threekit.com/api/files \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--form property1=string \
--form property2=string
var http = require("https");
var options = {
"method": "POST",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files",
"headers": {
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property1\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property2\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n");
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property1\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"property2\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n",
CURLOPT_HTTPHEADER => array(
"content-type: multipart/form-data; boundary=---011000010111000001101001"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"message": "Successful post request",
"files": [
{
"id": "7bde2d6c-7b9e-4933-832e-5da64879b4f0",
"userId": "320b39bb-0653-4ad7-ac68-7d5f016b0da3",
"filename": "MyPicture.jpg",
"createdAt": "2018-11-22T19:16:51.907Z",
"size": 3574392,
"hash": "sha256-9603b80dbcc6577f6b839e2a5e456f6df8a1434a06ca5b295f283b623be25efe",
"extension": ".jpg",
"type": "image/jpeg",
"encodings": {
"raw": {
"size": 3574392
}
}
}
]
}
{
"message": "Post request was poorly formed",
"error": {
"type": "missing_files_error",
"message": "Files must be included under the 'files' field to perform request"
}
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
Searches and retrieves a file with the given id if it exists
REST Endpoint
GET https://admin.threekit.com/api/files/{id}
Response Codes
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | Successful get request, response body will include the file entry with the requested id | None |
401 | Unauthorized | User has not authenticated and must authenticate before using this service | None |
403 | Forbidden | User has authenticated but lacks authorization to use this service | None |
404 | Not Found | File cannot be found | None |
Example Implementations
Code
CURL
curl --request GET \
--url https://admin.threekit.com/api/files/
Node.JS
var http = require("https");
var options = {
"method": "GET",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files/",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Example responses
{
"message": "Successful get request",
"files": [
{
"id": "7bde2d6c-7b9e-4933-832e-5da64879b4f0",
"userId": "320b39bb-0653-4ad7-ac68-7d5f016b0da3",
"filename": "MyPicture.jpg",
"createdAt": "2018-11-22T19:16:51.907Z",
"size": 3574392,
"hash": "sha256-9603b80dbcc6577f6b839e2a5e456f6df8a1434a06ca5b295f283b623be25efe",
"extension": ".jpg",
"type": "image/jpeg",
"encodings": {
"raw": {
"size": 3574392
}
}
}
]
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to request this file"
}
}
{
"message": "Requested file does not exist",
"error": {
"type": "file_not_found_error",
"message": "User has requested a non-existent file"
}
}
GET https://admin.threekit.com/api/files/report
curl --request GET \
--url https://admin.threekit.com/api/files/
var http = require("https");
var options = {
"method": "GET",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files/",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"message": "Successful get request",
"files": [
{
"id": "7bde2d6c-7b9e-4933-832e-5da64879b4f0",
"userId": "320b39bb-0653-4ad7-ac68-7d5f016b0da3",
"filename": "MyPicture.jpg",
"createdAt": "2018-11-22T19:16:51.907Z",
"size": 3574392,
"hash": "sha256-9603b80dbcc6577f6b839e2a5e456f6df8a1434a06ca5b295f283b623be25efe",
"extension": ".jpg",
"type": "image/jpeg",
"encodings": {
"raw": {
"size": 3574392
}
}
}
]
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to request this file"
}
}
{
"message": "Requested file does not exist",
"error": {
"type": "file_not_found_error",
"message": "User has requested a non-existent file"
}
}
Returns the count and total size of all files associated with an org
REST Endpoint
GET https://admin.threekit.com/api/files/report
Response Codes
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | Successful get request, response body will include the number of files associated with an org, and the total size of those files (in mb) | None |
401 | Unauthorized | User has not authenticated and must authenticate before using this service | None |
403 | Forbidden | User has authenticated but lacks authorization to use this service | None |
Example Implementations
Code
CURL
curl --request GET \
--url https://admin.threekit.com/api/files/report
Node.JS
var http = require("https");
var options = {
"method": "GET",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files/report",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files/report",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Example responses
{
"message": "Successful get request",
"files": [
{
"count": 3324,
"size": 98372
}
]
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to request this file"
}
}
curl --request GET \
--url https://admin.threekit.com/api/files/report
var http = require("https");
var options = {
"method": "GET",
"hostname": "admin.threekit.com",
"port": null,
"path": "/api/files/report",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://admin.threekit.com/api/files/report",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"message": "Successful get request",
"files": [
{
"count": 3324,
"size": 98372
}
]
}
{
"message": "Error getting authentication",
"error": {
"type": "authentication_error",
"message": "User has not been authenticated, must authenticate before performing this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to make this request"
}
}
{
"message": "User lacks authorization to make this request",
"error": {
"type": "authorization_error",
"message": "User has not been authorized to request this file"
}
}