curl --request POST \
--url https://api.rootkey.ai/api-v1/platform/files/uploads \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ownerVault": "0xdf67CA8286510997567685c0385ECeAb11C23C92",
"fileName": "contract.pdf",
"size": 2621440,
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentType": "application/pdf",
"parentId": "<string>",
"expirationDate": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.rootkey.ai/api-v1/platform/files/uploads"
payload = {
"ownerVault": "0xdf67CA8286510997567685c0385ECeAb11C23C92",
"fileName": "contract.pdf",
"size": 2621440,
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentType": "application/pdf",
"parentId": "<string>",
"expirationDate": "2023-11-07T05:31:56Z"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ownerVault: '0xdf67CA8286510997567685c0385ECeAb11C23C92',
fileName: 'contract.pdf',
size: 2621440,
sha256: '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
contentType: 'application/pdf',
parentId: '<string>',
expirationDate: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.rootkey.ai/api-v1/platform/files/uploads', 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.rootkey.ai/api-v1/platform/files/uploads",
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([
'ownerVault' => '0xdf67CA8286510997567685c0385ECeAb11C23C92',
'fileName' => 'contract.pdf',
'size' => 2621440,
'sha256' => '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
'contentType' => 'application/pdf',
'parentId' => '<string>',
'expirationDate' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.rootkey.ai/api-v1/platform/files/uploads"
payload := strings.NewReader("{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.rootkey.ai/api-v1/platform/files/uploads")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rootkey.ai/api-v1/platform/files/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"uploadId": "upl_3f2b8c1e5a7d4e9b9c2a1d6e8f0a4b7c",
"fileId": "<string>",
"mode": "single",
"expiresAt": "2023-11-07T05:31:56Z",
"upload": {
"method": "PUT",
"url": "<string>",
"headers": {},
"expiresAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}Start an upload
Starts a direct upload: you declare the file’s name, size and SHA-256, and ROOTKey answers with a signed URL (or a part plan, for a large file) to send the bytes to. Nothing is anchored and nothing is consumed from your plan until you complete the upload. Read Direct file uploads first for the whole flow. A personal access token with the rootkey.write scope can call it, in an organization that lets agents write.
curl --request POST \
--url https://api.rootkey.ai/api-v1/platform/files/uploads \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ownerVault": "0xdf67CA8286510997567685c0385ECeAb11C23C92",
"fileName": "contract.pdf",
"size": 2621440,
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentType": "application/pdf",
"parentId": "<string>",
"expirationDate": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.rootkey.ai/api-v1/platform/files/uploads"
payload = {
"ownerVault": "0xdf67CA8286510997567685c0385ECeAb11C23C92",
"fileName": "contract.pdf",
"size": 2621440,
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"contentType": "application/pdf",
"parentId": "<string>",
"expirationDate": "2023-11-07T05:31:56Z"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ownerVault: '0xdf67CA8286510997567685c0385ECeAb11C23C92',
fileName: 'contract.pdf',
size: 2621440,
sha256: '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
contentType: 'application/pdf',
parentId: '<string>',
expirationDate: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.rootkey.ai/api-v1/platform/files/uploads', 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.rootkey.ai/api-v1/platform/files/uploads",
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([
'ownerVault' => '0xdf67CA8286510997567685c0385ECeAb11C23C92',
'fileName' => 'contract.pdf',
'size' => 2621440,
'sha256' => '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
'contentType' => 'application/pdf',
'parentId' => '<string>',
'expirationDate' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.rootkey.ai/api-v1/platform/files/uploads"
payload := strings.NewReader("{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.rootkey.ai/api-v1/platform/files/uploads")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rootkey.ai/api-v1/platform/files/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ownerVault\": \"0xdf67CA8286510997567685c0385ECeAb11C23C92\",\n \"fileName\": \"contract.pdf\",\n \"size\": 2621440,\n \"sha256\": \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n \"contentType\": \"application/pdf\",\n \"parentId\": \"<string>\",\n \"expirationDate\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"uploadId": "upl_3f2b8c1e5a7d4e9b9c2a1d6e8f0a4b7c",
"fileId": "<string>",
"mode": "single",
"expiresAt": "2023-11-07T05:31:56Z",
"upload": {
"method": "PUT",
"url": "<string>",
"headers": {},
"expiresAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"requestId": "<string>",
"message": "<string>",
"errorCode": "<string>",
"docUrl": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}Authorizations
Headers
The organization a personal access token acts in: the id of one of the organizations that GET /organizations lists. Required with a personal access token on every endpoint that works inside an organization; without it the request gets organization_header_required. Ignored with an API key, which belongs to exactly one organization.
Body
The file's media type. ROOTKey keeps it for types that browsers do not execute (PDF, images, plain text, CSV, JSON, archives, office documents, audio and video) and stores anything else as application/octet-stream. The Content-Type in the response says which.
"application/pdf"
Response
Upload started. mode says how to send the bytes: single carries one signed URL, multipart carries a part plan.
Was this page helpful?