# beginSpaceUpload

Start uploading a file of any type into a folder you can edit (or as `replacesItemId`'s next version). PUT the bytes to `uploadUrl` with exactly `contentType`, then call completeSpaceUpload.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "beginSpaceUpload", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `input`: `BeginSpaceUploadInput!` (required)
  - `spaceId`: `ID!` (required)
  - `folderId`: `ID`
  - `fileName`: `String!` (required)
  - `sizeBytes`: `Float!` (required)
  - `contentType`: `String`
  - `replacesItemId`: `ID`. Upload a new version of this file instead of a new file.
  - `assetOfItemId`: `ID`. Upload a picture this file's editor holds (an AI edit, a photo drawn with its edits): filed under the file, never listed, and trashed, moved and shared with it. It goes in the file's own space, whatever spaceId says.

## Response (data, an example)

```json
{
  "spacesMutation": {
    "beginUpload": {
      "uploadId": "<ID>",
      "uploadUrl": "…",
      "contentType": "…",
      "expiresAt": "2026-01-01T00:00:00.000Z"
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "beginSpaceUpload",
    "variables": {
      "input": {
        "spaceId": "<spaceId>",
        "fileName": "<String>",
        "sizeBytes": 1.5
      }
    }
  }'
```
