# Change blocks in a client document

Inserts, replaces, moves or deletes blocks of a client document by block id, in order and all or none, and saves the result as a new version. expectedVersion must be the version last read: if the document changed since, the answer is a conflict naming the current version and nothing is saved. A replace of a section must list all the blocks the section holds, and a delete of a section that holds blocks needs cascade true; otherwise the change is refused naming the blocks it would remove. The result must still be a valid document, otherwise the change is refused with the problems found. An archived document cannot be changed. Answers with the new version's content and outline.

**PATCH** /v1/client-documents/{documentId}/blocks



## Parameters
- documentId (path, required): string
- Idempotency-Key (header, required): Opaque idempotency key, at most 255 characters, scoped to (tenant, principal, operation). A missing key is validation_failed.

## Request body
- expectedVersion (required): integer
- operations (required): array

## Responses
- **200** Change blocks in a client document — document (required): object; version (required): object; content (required): object; outline (required): array
- **202** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ApprovalRequiredError:; allOf: ErrorEnvelope
- **400** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ValidationFailedError:; allOf: ErrorEnvelope
- **401** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — UnauthorizedError:; allOf: ErrorEnvelope
- **403** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ForbiddenError:; allOf: ErrorEnvelope
- **404** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — NotFoundError:; allOf: ErrorEnvelope
- **409** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — ConflictError:; allOf: ErrorEnvelope
- **429** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — RateLimitedError:; allOf: ErrorEnvelope
- **503** Error envelope. `error.code` carries the typed outcome and `error.type` resolves to its description. — UnavailableError:; allOf: ErrorEnvelope

## Example
```bash
curl --request PATCH \
  --url 'https://api.scopable.io/v1/client-documents/{documentId}/blocks' \
  --header 'Authorization: Bearer $SCOPABLE_API_KEY' \
  --data '<JSON request body>'
```

OpenAPI source: https://api.scopable.io/v1/openapi.json