curl --request POST \
--url https://api.hq.zone/v1/api/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"body_b64": "<string>",
"content_type": "<string>",
"filename": "<string>",
"caption": "<string>",
"category": "<string>",
"channel_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"tags": [
"<string>"
]
}
'import requests
url = "https://api.hq.zone/v1/api/documents"
payload = {
"body_b64": "<string>",
"content_type": "<string>",
"filename": "<string>",
"caption": "<string>",
"category": "<string>",
"channel_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"tags": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
body_b64: '<string>',
content_type: '<string>',
filename: '<string>',
caption: '<string>',
category: '<string>',
channel_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
scope: '<string>',
tags: ['<string>']
})
};
fetch('https://api.hq.zone/v1/api/documents', 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.hq.zone/v1/api/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'body_b64' => '<string>',
'content_type' => '<string>',
'filename' => '<string>',
'caption' => '<string>',
'category' => '<string>',
'channel_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'scope' => '<string>',
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.hq.zone/v1/api/documents"
payload := strings.NewReader("{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.hq.zone/v1/api/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/v1/api/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"deduplicated": true,
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"download_url": "<string>",
"sha256": "<string>",
"size_bytes": 1,
"enriched": true
}Upload a document
Uploads a document by sending its bytes inline as base64 in the JSON body (capped at roughly 12 MiB of file content), together with filename, content type, scope (private, channel, or team; defaults to private), and optional channel_id, category, tags, and caption. The operation is content-addressed and idempotent per owner and scope: re-uploading identical bytes returns the existing document rather than creating a duplicate, and any newly supplied tags, caption, or category are merged onto that existing row (reflected by deduplicated and enriched flags in the response). channel_id is required when scope is channel and rejected otherwise. Returns the document id, download URL, SHA-256, and size. Requires the documents:write scope.
curl --request POST \
--url https://api.hq.zone/v1/api/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"body_b64": "<string>",
"content_type": "<string>",
"filename": "<string>",
"caption": "<string>",
"category": "<string>",
"channel_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"tags": [
"<string>"
]
}
'import requests
url = "https://api.hq.zone/v1/api/documents"
payload = {
"body_b64": "<string>",
"content_type": "<string>",
"filename": "<string>",
"caption": "<string>",
"category": "<string>",
"channel_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"tags": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
body_b64: '<string>',
content_type: '<string>',
filename: '<string>',
caption: '<string>',
category: '<string>',
channel_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
scope: '<string>',
tags: ['<string>']
})
};
fetch('https://api.hq.zone/v1/api/documents', 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.hq.zone/v1/api/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'body_b64' => '<string>',
'content_type' => '<string>',
'filename' => '<string>',
'caption' => '<string>',
'category' => '<string>',
'channel_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'scope' => '<string>',
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.hq.zone/v1/api/documents"
payload := strings.NewReader("{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.hq.zone/v1/api/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hq.zone/v1/api/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"body_b64\": \"<string>\",\n \"content_type\": \"<string>\",\n \"filename\": \"<string>\",\n \"caption\": \"<string>\",\n \"category\": \"<string>\",\n \"channel_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"scope\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"deduplicated": true,
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"download_url": "<string>",
"sha256": "<string>",
"size_bytes": 1,
"enriched": true
}Authorizations
Personal Access Token. Send as Authorization: Bearer hq_pat_....
Body
Base64-encoded payload. 16 MiB cap on the JSON body limits raw to ~12 MiB - the multipart streaming path lands in pass 2.
Free-form user category; the auto-categoriser may overwrite this in a follow-up worker pass once we have Haiku wired.
Required iff scope == "channel".
private | channel | team. Defaults to private.
Response
Document saved
True iff this hashed identical to an existing document in this tenant - we still record the new metadata row but the Trove object is shared. The UI surfaces this as a "saved (dedup'd against existing copy)" hint.
x >= 0True iff this was a same-owner/same-scope dedup AND the caller supplied new metadata (tags/caption/category) that we actually merged onto the existing row. Lets the UI say "already in your library - details updated" honestly vs a bare "already there".