curl --request POST \
--url https://api.tightknit.ai/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form file_category=calendar-event-cover \
--form filename=cover.png \
--form 'description=Launch cover'import requests
url = "https://api.tightknit.ai/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"file_category": "calendar-event-cover",
"filename": "cover.png",
"description": "Launch cover"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('file_category', 'calendar-event-cover');
form.append('filename', 'cover.png');
form.append('description', 'Launch cover');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.tightknit.ai/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tightknit.ai/v1/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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tightknit.ai/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tightknit.ai/v1/files")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tightknit.ai/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"object": "file",
"id": "file_2b3c4d5e6f7g",
"name": "cover.png",
"title": "<string>",
"mimetype": "image/png",
"size": 1,
"url": "<string>",
"thumbnail_url": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"type": "about:blank",
"title": "Not found",
"status": 404,
"code": "not_found",
"detail": "<string>",
"param": "<string>",
"request_id": "req_9f2b8c1d4e5a6b7c8d9e0f1a2b3c4d5e"
}Upload a file
Uploads one file as multipart form data. file_category says where the file will be used; in v1, an event’s cover_image_file_id is the only field that takes the returned id. Refused with a 400: an empty file, a type its category does not take, and an image whose format, dimensions or size do not fit its category. A file over the community’s upload size limit is refused with a 413 or a 400.
curl --request POST \
--url https://api.tightknit.ai/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form file_category=calendar-event-cover \
--form filename=cover.png \
--form 'description=Launch cover'import requests
url = "https://api.tightknit.ai/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"file_category": "calendar-event-cover",
"filename": "cover.png",
"description": "Launch cover"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('file_category', 'calendar-event-cover');
form.append('filename', 'cover.png');
form.append('description', 'Launch cover');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.tightknit.ai/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tightknit.ai/v1/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=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tightknit.ai/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tightknit.ai/v1/files")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tightknit.ai/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_category\"\r\n\r\ncalendar-event-cover\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"filename\"\r\n\r\ncover.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nLaunch cover\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"object": "file",
"id": "file_2b3c4d5e6f7g",
"name": "cover.png",
"title": "<string>",
"mimetype": "image/png",
"size": 1,
"url": "<string>",
"thumbnail_url": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"type": "about:blank",
"title": "Not found",
"status": 404,
"code": "not_found",
"detail": "<string>",
"param": "<string>",
"request_id": "req_9f2b8c1d4e5a6b7c8d9e0f1a2b3c4d5e"
}Authorizations
A Tightknit admin API key, sent as Authorization: Bearer <key>.
Body
The file bytes.
What the file is for. Each category takes an image validated against that slot. One of:
calendar-event-cover: an event’s cover image, itscover_image_file_id.calendar-events-banner: the banner of the community site’s events page.site-logo: the community site’s square logo icon.site-combination-logo: the community site’s horizontal logo.site-favicon: the icon browsers show in the community site’s tab.site-social-image: the image shown when a link to the community site is shared.home-page-banner: the banner of the community site’s home page.members-banner: the banner of the community site’s members page.content-library-banner: the banner of the community site’s content library.feed-banner: a feed’s banner.group-banner: a group’s banner.groups-banner: the banner of the community site’s groups page.community-icon: the square logo used as the community’s avatar.community-home-banner: the banner of the Community Home members see when they open Tightknit in Slack.award-badge: an award’s badge image.award-overlay-frame: the frame an award lays over its holders’ profile photos.award-cert-template: the template an award’s certificates are drawn on.content-resource-cover: a content resource’s cover image.content-collection-cover: a content collection’s cover image.login-marketing-panel: the image beside the sign-in form on the community site’s login page.composition-image: an image in a Message Blaster message.
calendar-event-cover, calendar-events-banner, site-logo, site-combination-logo, site-favicon, site-social-image, home-page-banner, members-banner, content-library-banner, feed-banner, group-banner, groups-banner, community-icon, community-home-banner, award-badge, award-overlay-frame, award-cert-template, content-resource-cover, content-collection-cover, login-marketing-panel, composition-image "calendar-event-cover"
The stored name, whose extension declares the file type.
100^(?!\.+$)[a-zA-Z0-9_.-]+$"cover.png"
Alt text or a short description, stored as the title. Defaults to filename.
1 - 150^\P{Cc}*$/u"Launch cover"
Response
Success
A file the community stored, uploaded or generated.
Always file.
file Unique identifier for the object.
"file_2b3c4d5e6f7g"
The file’s stored name, including its extension.
"cover.png"
Alt text or a short description of the file. An upload without one takes the filename. Null when none was recorded.
The file’s media type.
"image/png"
The file’s size in bytes.
x >= 0Where to download the file.
A smaller preview of the file. Null when it has none.
When the file was stored.
Was this page helpful?

