# setSpaceGrant

Share a folder or file (and everything in it) with one teammate (`userId`, an active member of your organization) as VIEWER, EDITOR or MANAGER, or stop sharing with `role` null. Needs MANAGER. Library never shares outside the organization. Requires the user's explicit approval: it changes who can see the file.

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

## Variables

- `input`: `SetSpaceGrantInput!` (required)
  - `itemId`: `ID!` (required)
  - `userId`: `ID!` (required)
  - `role`: `SpaceRole` (one of `VIEWER`, `EDITOR`, `MANAGER`). Null stops sharing with them.

## Response (data, an example)

```json
{
  "spacesMutation": {
    "setGrant": {
      "audience": "ORGANIZATION",
      "entries": [
        {
          "person": {
            "id": "<ID>",
            "name": "…"
          },
          "role": "VIEWER",
          "isOwner": true
        }
      ]
    }
  }
}
```

## 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": "setSpaceGrant",
    "variables": {
      "input": {
        "itemId": "<itemId>",
        "userId": "<userId>"
      }
    }
  }'
```
