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"
}
}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.
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"
}
}Authorizations
ROOTKey API key (rk_live_... for production, rk_test_... for the test network).
Body
Address of the vault that will own the file. ownerWallet is accepted as an alias.
"0xdf67CA8286510997567685c0385ECeAb11C23C92"
The file's name, with its extension. This is the name the file shows in the vault.
255"contract.pdf"
The file's size in bytes. The bytes you upload must be exactly this long.
x >= 02621440
The SHA-256 of the whole file, as 64 hexadecimal characters. This is the hash that gets anchored.
^[0-9a-fA-F]{64}$"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
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"
Upload a new version of this file instead of a new file. The file must be in the same vault.
Optional expiry date-time for the smart contract
Response
Upload started. mode says how to send the bytes: single carries one signed URL, multipart carries a part plan.
Was this page helpful?

