# com.livtet.shelf.addBooks

> Batch the same upsert as shelf.addItem. Entries that fail validation are counted in `failed` instead of aborting the call.

- Kind: procedure
- Authority: shelf.livtet.com
- Lexicon: 1
- Published by [biblio.livtet.com](https://lexicon.garden/identity/did:plc:e2x3ihw2ntxt7pcgzmtu3abi), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/com.livtet.shelf.addBooks)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/com.livtet.shelf.addBooks/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/com.livtet.shelf.addBooks/analytics)

## Procedure (`com.livtet.shelf.addBooks`)

Type: procedure · POST

### Input (application/json)

- `books` (array, required): Catalog editions to place on the shelf.
  - Constraints: maxLength: 100
  - `items` (ref)
    - Reference: `com.atproto.repo.strongRef`
- `shelf` (string · at-uri, required): AT-URI of the shelf record.

### Output (application/json)

- `added` (integer, required): Shelf items written.
  - Constraints: minimum: 0
- `failed` (integer, required): Entries rejected before writing (bad strongRef, duplicate rkey, ...).
  - Constraints: minimum: 0

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Batch the same upsert as shelf.addItem. Entries that fail validation are counted in `failed` instead of aborting the call.",
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "books": {
              "description": "Catalog editions to place on the shelf.",
              "items": {
                "ref": "com.atproto.repo.strongRef",
                "type": "ref"
              },
              "maxLength": 100,
              "type": "array"
            },
            "shelf": {
              "description": "AT-URI of the shelf record.",
              "format": "at-uri",
              "type": "string"
            }
          },
          "required": [
            "shelf",
            "books"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "added": {
              "description": "Shelf items written.",
              "minimum": 0,
              "type": "integer"
            },
            "failed": {
              "description": "Entries rejected before writing (bad strongRef, duplicate rkey, ...).",
              "minimum": 0,
              "type": "integer"
            }
          },
          "required": [
            "added",
            "failed"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "description": "Put up to 100 books on one shelf in a single request; the shelfItems are written in parallel with Record.save_all.",
  "id": "com.livtet.shelf.addBooks",
  "lexicon": 1
}
```
