> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cloudraker.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cloudraker.com/_mcp/server.

# Files and uploads

Uploading a file into a space is a two-step, presigned flow: you **register** the file to get a short-lived upload URL, then **PUT** the bytes straight to storage. Registering requires `space:contribute` on the space; reading requires `space:read`.

Uploads never stream through the gateway — you always PUT to a presigned upload URL from your own environment. This is the right path for large files and for anything you want to keep in a space (unlike the transient [`/process` API](/developers/process-api)).

## The flow

#### Register the file

`POST /spaces/{spaceId}/files` returns a presigned upload URL.

#### Upload the bytes

`PUT` the raw file to that URL, with `Content-Type` exactly matching the `mimeType` you registered.

#### Poll until terminal

`GET /spaces/{spaceId}/files/{fileId}` until `status` settles, then read the download URLs.

## 1. Register

### Request

POST [https://api.cloudraker.com/spaces/\{spaceId}/files](https://api.cloudraker.com/spaces/\{spaceId}/files)

```curl
curl -X POST https://api.cloudraker.com/spaces/spaceId/files \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "fileName": "invoice_2024_04.pdf",
  "mimeType": "application/pdf"
}'
```

```python
import requests

url = "https://api.cloudraker.com/spaces/spaceId/files"

payload = {
    "fileName": "invoice_2024_04.pdf",
    "mimeType": "application/pdf"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/spaces/spaceId/files';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"fileName":"invoice_2024_04.pdf","mimeType":"application/pdf"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/spaces/spaceId/files"

	payload := strings.NewReader("{\n  \"fileName\": \"invoice_2024_04.pdf\",\n  \"mimeType\": \"application/pdf\"\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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/spaces/spaceId/files")

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  \"fileName\": \"invoice_2024_04.pdf\",\n  \"mimeType\": \"application/pdf\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/spaces/spaceId/files")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"fileName\": \"invoice_2024_04.pdf\",\n  \"mimeType\": \"application/pdf\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/spaces/spaceId/files', [
  'body' => '{
  "fileName": "invoice_2024_04.pdf",
  "mimeType": "application/pdf"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/spaces/spaceId/files");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"fileName\": \"invoice_2024_04.pdf\",\n  \"mimeType\": \"application/pdf\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "fileName": "invoice_2024_04.pdf",
  "mimeType": "application/pdf"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/spaces/spaceId/files")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

Body fields:

* **`fileName`** (required)
* **`mimeType`** (required) — drives both the stored record and the exact `Content-Type` the PUT must send.
* **`size`** — bytes, optional.
* **`processingKind`** — optional; same five values as `/process` (`doc-simple`, `doc-ocr`, `doc-auto`, `audio-transcribe`, `audio-transcribe-and-diarize`).
* **`indexVectors`** / **`indexOntology`** — optional booleans, both default **`true`** (the file is indexed for search and the knowledge graph unless you opt out).

Any `parentType`/`parentId` in the body are ignored — the parent is forced to `:spaceId`.

### Response — `201`

```json
{
  "id": "…",
  "uploadUrl": "https://…storage…/…",
  "uploadExpiresAt": "2026-07-20T12:15:00.000Z",
  "file": { }
}
```

`uploadUrl` is a presigned upload URL valid for **15 minutes** (`uploadExpiresAt`).

## 2. Upload the bytes

PUT the raw file directly to `uploadUrl`. This goes directly to object storage, not through the gateway. The `Content-Type` must be **exactly** the `mimeType` you registered — a mismatch rejects the PUT.

```bash
curl -X PUT "<uploadUrl>" \
  -H "Content-Type: application/pdf" \
  --data-binary @./invoice.pdf
```

## 3. Poll until terminal

### Request

GET [https://api.cloudraker.com/spaces/\{spaceId}/files/\{fileId}](https://api.cloudraker.com/spaces/\{spaceId}/files/\{fileId})

```curl
curl https://api.cloudraker.com/spaces/spaceId/files/fileId \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json"
```

```python
import requests

url = "https://api.cloudraker.com/spaces/spaceId/files/fileId"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.get(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/spaces/spaceId/files/fileId';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/spaces/spaceId/files/fileId"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", 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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/spaces/spaceId/files/fileId")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.cloudraker.com/spaces/spaceId/files/fileId")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.cloudraker.com/spaces/spaceId/files/fileId', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/spaces/spaceId/files/fileId");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/spaces/spaceId/files/fileId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

Poll `status` until it settles:

| Status                   | Meaning                               |
| ------------------------ | ------------------------------------- |
| `waiting` / `processing` | Keep polling                          |
| `stored`                 | Uploaded; no processing was requested |
| `processed`              | Processing succeeded                  |
| `failed`                 | See `processingError`                 |

Once terminal, the record's `urls` object carries minted download links (valid \~1 hour):

* **`urls.file`** — the original file
* **`urls.processedMd`** — extracted markdown (once produced)
* **`urls.processedJson`** — structured / grounded JSON (once produced)

## List files in a space

### Request

GET [https://api.cloudraker.com/spaces/\{spaceId}/files](https://api.cloudraker.com/spaces/\{spaceId}/files)

```curl
curl https://api.cloudraker.com/spaces/spaceId/files \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json"
```

```python
import requests

url = "https://api.cloudraker.com/spaces/spaceId/files"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.get(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/spaces/spaceId/files';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/spaces/spaceId/files"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", 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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/spaces/spaceId/files")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.cloudraker.com/spaces/spaceId/files")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.cloudraker.com/spaces/spaceId/files', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/spaces/spaceId/files");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/spaces/spaceId/files")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

`?limit` defaults to 50, max 200. Files have **no cursor** — the list returns a single most-recent page. See [Pagination and filtering](/developers/pagination-filtering).

## Retry a failed file

### Request

POST [https://api.cloudraker.com/spaces/\{spaceId}/files/\{fileId}/reprocess](https://api.cloudraker.com/spaces/\{spaceId}/files/\{fileId}/reprocess)

```curl
curl -X POST https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{}'
```

```python
import requests

url = "https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess"

	payload := strings.NewReader("{}")

	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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess")

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 = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/spaces/spaceId/files/fileId/reprocess")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

Resets the file to `waiting`. Returns `409` if the file isn't currently `failed`.

Accessing a file id from the wrong space returns `404` — existence is hidden across spaces (a `space:read` leak-guard). Org admins bypass space checks.

## Org-level template files

Organization template files use the same presigned shape under `POST /organization/templates`.

## Where to go next

#### [Process API](/developers/process-api)

Skip the space entirely for one-shot processing with an auto-expiring TTL.

#### [Pagination and filtering](/developers/pagination-filtering)

How listing works across files, objects, and runs.