---
title: "Register a file in a space and get a presigned upload URL"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Register a file in a space and get a presigned upload URL

Path: CloudRaker Paperwork API › Space Files

`POST /spaces/{spaceId}/files`

Reserves a file metadata record in the space and returns { id, uploadUrl, uploadExpiresAt, file }. `uploadUrl` is a secure PUT URL valid for 15 minutes (see `uploadExpiresAt`, ISO 8601). Two-step upload: PUT the raw file bytes to `uploadUrl` with a `Content-Type` request header EXACTLY equal to the `mimeType` you sent at create (a mismatch rejects the PUT), then poll `getFile` until `status` reaches a terminal value — `stored` (uploaded, no processing requested), `processed` (processing succeeded), or `failed` (see `processingError`); `waiting`/`processing` mean keep polling. Request body: `fileName` (required), `mimeType` (required, drives both the record and the required PUT Content-Type), `size` (bytes, optional), optional `processingKind` — one of doc-simple | doc-ocr | doc-auto | audio-transcribe | audio-transcribe-and-diarize — selecting how the stored file is post-processed; `indexVectors` and `indexOntology` (both default true) are opt-out booleans for semantic and ontology indexing — both are FORCED false for a desk (`me:<userId>`) space, whose files are never indexed. `parentType`/`parentId` in the body are ignored: the API forces the parent to this :spaceId. Authorization: requires `space:contribute` on :spaceId (missing permission → 403; org admins bypass). An invalid body returns 422.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`createSpaceFile.path.spaceId`; string, required)

## Request body

_Required._

- `fileName` (`createSpaceFile.fileName`; string, required)
  - minLength 1; example `"invoice.pdf"`
- `mimeType` (`createSpaceFile.mimeType`; string, required) — Drives both the record and the required upload `Content-Type`.
  - minLength 1; example `"application/pdf"`
- `size` (`createSpaceFile.size`; integer, optional) — Size in bytes.
  - min 0; max 9007199254740991
- `processingKind` (`createSpaceFile.processingKind`; string, optional) — How the stored file is post-processed. Omit for automatic selection by mime.
  - one of `"doc-simple"`, `"doc-ocr"`, `"doc-auto"`, `"audio-transcribe"`, `"audio-transcribe-and-diarize"`
- `indexVectors` (`createSpaceFile.indexVectors`; boolean, optional) — Semantic indexing.
  - default `true`
- `indexOntology` (`createSpaceFile.indexOntology`; boolean, optional) — Knowledge-graph indexing.
  - default `true`

## Example request

```json
{
  "fileName": "invoice.pdf",
  "mimeType": "application/pdf",
  "size": 9007199254740991,
  "processingKind": "doc-simple",
  "indexVectors": true,
  "indexOntology": true
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/files' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "fileName": "invoice.pdf",
  "mimeType": "application/pdf",
  "size": 9007199254740991,
  "processingKind": "doc-simple",
  "indexVectors": true,
  "indexOntology": true
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/files';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    fileName: 'invoice.pdf',
    mimeType: 'application/pdf',
    size: 9007199254740991,
    processingKind: 'doc-simple',
    indexVectors: true,
    indexOntology: true
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

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

payload = {
    "fileName": "invoice.pdf",
    "mimeType": "application/pdf",
    "size": 9007199254740991,
    "processingKind": "doc-simple",
    "indexVectors": True,
    "indexOntology": True
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 201

File record created, with its presigned upload URL.

#### Example

```json
{
  "id": "string",
  "uploadUrl": "string",
  "uploadExpiresAt": "2019-08-24T14:15:22Z",
  "file": {
    "id": "a1b2c3d4",
    "fileName": "invoice.pdf",
    "parentType": "space",
    "parentId": "string",
    "mimeType": "application/pdf",
    "size": 0,
    "status": "waiting",
    "processingKind": "doc-simple",
    "processingError": "string",
    "processingProgress": {
      "state": "queued",
      "pagesTotal": -9007199254740991,
      "pagesDone": -9007199254740991
    },
    "parentFileId": "string",
    "artifacts": [
      "string"
    ],
    "indexVectors": true,
    "indexOntology": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "storedAt": "2019-08-24T14:15:22Z",
    "processedAt": "2019-08-24T14:15:22Z",
    "urls": {
      "file": "string",
      "processedJson": "string",
      "processedMd": "string",
      "previewPdf": "string"
    }
  }
}
```

- `id` (`createSpaceFile.response.201.id`; string, required)
- `uploadUrl` (`createSpaceFile.response.201.uploadUrl`; string, required) — Presigned upload URL, valid 15 minutes. PUT the raw bytes there with a `Content-Type` header EXACTLY equal to the `mimeType` sent at create.
- `uploadExpiresAt` (`createSpaceFile.response.201.uploadExpiresAt`; string, required)
  - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
- `file` (`createSpaceFile.response.201.file`; object, required)
  - `id` (`createSpaceFile.response.201.file.id`; string, required)
    - example `"a1b2c3d4"`
  - `fileName` (`createSpaceFile.response.201.file.fileName`; string, required)
    - example `"invoice.pdf"`
  - `parentType` (`createSpaceFile.response.201.file.parentType`; string, required)
    - example `"space"`
  - `parentId` (`createSpaceFile.response.201.file.parentId`; string, required)
  - `mimeType` (`createSpaceFile.response.201.file.mimeType`; string, required)
    - example `"application/pdf"`
  - `size` (`createSpaceFile.response.201.file.size`; number | null, required) — Size in bytes, null until stored.
  - `status` (`createSpaceFile.response.201.file.status`; string, required) — Terminal values are `stored` (uploaded, no processing requested), `processed` and `failed`; `waiting` and `processing` mean keep polling.
    - one of `"waiting"`, `"stored"`, `"processing"`, `"processed"`, `"failed"`
  - `processingKind` (`createSpaceFile.response.201.file.processingKind`; any of, required)
    - any of:
      - `string`: one of `"doc-simple"`, `"doc-ocr"`, `"doc-auto"`, `"audio-transcribe"`, `"audio-transcribe-and-diarize"`
      - `null`
  - `createdAt` (`createSpaceFile.response.201.file.createdAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `processingError` (`createSpaceFile.response.201.file.processingError`; string, optional)
  - `processingProgress` (`createSpaceFile.response.201.file.processingProgress`; object, optional) — Present while `status` is `processing`. `queued` means that the organization is at its concurrent parse limit and no page of this file is in parse.
    - `state` (`createSpaceFile.response.201.file.processingProgress.state`; string, required)
      - one of `"queued"`, `"processing"`
    - `pagesTotal` (`createSpaceFile.response.201.file.processingProgress.pagesTotal`; integer, required)
      - min -9007199254740991; max 9007199254740991
    - `pagesDone` (`createSpaceFile.response.201.file.processingProgress.pagesDone`; integer, required)
      - min -9007199254740991; max 9007199254740991
  - `parentFileId` (`createSpaceFile.response.201.file.parentFileId`; string, optional) — Source file this one was generated from (e.g. a redacted or signed copy).
  - `artifacts` (`createSpaceFile.response.201.file.artifacts`; array<string>, optional) — Parsing byproducts present, e.g. `structured`, `transcript`.
  - `indexVectors` (`createSpaceFile.response.201.file.indexVectors`; boolean, optional)
  - `indexOntology` (`createSpaceFile.response.201.file.indexOntology`; boolean, optional)
  - `storedAt` (`createSpaceFile.response.201.file.storedAt`; string, optional)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `processedAt` (`createSpaceFile.response.201.file.processedAt`; string, optional)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `urls` (`createSpaceFile.response.201.file.urls`; object, optional) — Minted download links, each valid ~1 hour. Present on single-file reads only — list responses mint none.
    - `file` (`createSpaceFile.response.201.file.urls.file`; string, optional) — The stored original.
    - `processedJson` (`createSpaceFile.response.201.file.urls.processedJson`; string, optional) — Structured/grounded JSON.
    - `processedMd` (`createSpaceFile.response.201.file.urls.processedMd`; string, optional) — Extracted markdown.
    - `previewPdf` (`createSpaceFile.response.201.file.urls.previewPdf`; string, optional)


Source: https://docs.cloudraker.com/paperwork/api/space-files/create-space-file/index.md
