Upload Session Documents
curl --request POST \
--url https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"keys": [
"<string>"
]
}
'import requests
url = "https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload"
payload = { "keys": ["<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({keys: ['<string>']})
};
fetch('https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload', 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.raydocs.com/extractions/sessions/{sessionId}/documents/upload",
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([
'keys' => [
'<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.raydocs.com/extractions/sessions/{sessionId}/documents/upload"
payload := strings.NewReader("{\n \"keys\": [\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.raydocs.com/extractions/sessions/{sessionId}/documents/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"keys\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload")
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 \"keys\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspace_id": 123,
"filename": "<string>",
"mime": "<string>",
"size": 123,
"sha256": "<string>",
"status": "uploaded",
"source_type": "upload",
"source_url": "<string>",
"parsings": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"config_hash": "<string>",
"status": "queued",
"parser_version": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z"
}
]
}Extraction Sessions
Create Document
Create/reuse workspace documents from upload keys and attach them to a session.
POST
/
extractions
/
sessions
/
{sessionId}
/
documents
/
upload
Upload Session Documents
curl --request POST \
--url https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"keys": [
"<string>"
]
}
'import requests
url = "https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload"
payload = { "keys": ["<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({keys: ['<string>']})
};
fetch('https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload', 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.raydocs.com/extractions/sessions/{sessionId}/documents/upload",
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([
'keys' => [
'<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.raydocs.com/extractions/sessions/{sessionId}/documents/upload"
payload := strings.NewReader("{\n \"keys\": [\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.raydocs.com/extractions/sessions/{sessionId}/documents/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"keys\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload")
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 \"keys\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspace_id": 123,
"filename": "<string>",
"mime": "<string>",
"size": 123,
"sha256": "<string>",
"status": "uploaded",
"source_type": "upload",
"source_url": "<string>",
"parsings": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"config_hash": "<string>",
"status": "queued",
"parser_version": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z"
}
]
}This endpoint is Step 3 of a 3-step upload process. Files must first be uploaded to temporary storage via signed URL before being associated with a session. See the complete upload guide for the full flow.
How It Works
This endpoint handles upload attach: create or reuse workspace documents from uploaded key(s). To attach already existing documents, usePOST /extractions/sessions/{sessionId}/documents/attach.
Authentication & Scope
Requires thesessions-write ability.
Request
This endpoint expects JSON (not binary upload).POST /extractions/sessions/770e8400-e29b-41d4-a716-446655440000/documents/upload HTTP/1.1
Host: api.raydocs.com
Authorization: Bearer <token>
Content-Type: application/json
{
"keys": ["tmp/721c7d17-f810-41a8-8c1c-a7e8cd2e52d0"]
}
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | uuid | Yes | The session ID |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
keys | array[string] | Yes | Upload key list from signed URL flow |
Supported Formats
- PDF (
.pdf) - Microsoft Word (
.docx,.doc) - Images (
.png,.jpg,.jpeg,.tiff) - PowerPoint (
.pptx)
Response
200 OK – Documents attached.
{
"data": [
{
"id": "880e8400-e29b-41d4-a716-446655440000",
"workspace_id": "660e8400-e29b-41d4-a716-446655440000",
"filename": "invoice.pdf",
"sha256": "6de7f6f5894c9f3fd1f6f8a4d1b3115d0d9b4b19d7a8a661f9fe90f9c2d80c3b",
"status": "uploaded",
"created_at": "2024-01-15T10:30:00Z"
}
]
}
Upload/import is storage-only. Parsing is requested explicitly (reparse endpoint) or at extraction run time when required.
Deduplication is content-based at workspace scope. If uploaded bytes match an existing document (
sha256), the API reuses that document and only creates the session attachment.422 Unprocessable Entity – Invalid key or unsupported file format.
Quick Reference: Complete Upload Flow
1
Get signed upload URL
curl -X POST 'https://api.raydocs.com/vapor/signed-storage-url' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"visibility": "private"}'
url, key, and headers for the S3 upload.2
Upload file to S3
curl -X PUT "${SIGNED_URL}" \
-H 'Content-Type: application/pdf' \
--data-binary @invoice.pdf
3
Create document record (this endpoint)
curl -X POST 'https://api.raydocs.com/extractions/sessions/{sessionId}/documents/upload' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"keys": ["tmp/abc123-..."]}'
For detailed code examples in JavaScript and Python, see the Uploading Documents cookbook.
Authorizations
Path Parameters
Body
application/json
Temporary upload keys returned by /vapor/signed-storage-url
Response
Documents attached
Show child attributes
Show child attributes
