# net.olamaelcu.livtet.biblio.ensureEdition

> Publish the edition records a reader is about to reference, and return the uri+cid a shelf record's strongRef needs. The AppView calls this when a reader acts — shelves a book, marks a status — never on a page render: a crawl must not republish the catalogue, and a strongRef cannot be written before the record exists. The caller authenticates with an atproto service token minted by its own PDS, so the request proves an intent rather than a page view.

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

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/net.olamaelcu.livtet.biblio.ensureEdition)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/net.olamaelcu.livtet.biblio.ensureEdition/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:e2x3ihw2ntxt7pcgzmtu3abi/net.olamaelcu.livtet.biblio.ensureEdition/analytics)

## Procedure (`net.olamaelcu.livtet.biblio.ensureEdition`)

Type: procedure · POST

### Input (application/json)

- `identifiers` (array): Edition identifiers as search returns them. At most 100 entries across identifiers and uris.
  - Constraints: maxLength: 100
  - `items` (ref)
    - Reference: `community.lexicon.media.book.defs#identifier`
- `uris` (array): Edition uris as resolveEditions returns them (the `atproto` identifier), when the caller already has them.
  - Constraints: maxLength: 100
  - `items` (string · at-uri)
- `waitMs` (integer): How long the AppView may wait for a record to be written before the uri is reported as pending. Defaults to 2000; capped at 5000.
  - Constraints: minimum: 0, maximum: 5000

### Output (application/json)

- `editions` (array, required): Editions whose records exist now. The cid is what a strongRef must carry.
  - `items` (object)
- `pending` (array, required): Uris whose publication was requested but not written within waitMs. The caller may retry; the request stays queued.
  - `items` (string · at-uri)

### Errors

- `AuthRequired`: The service token was missing or rejected.
- `InvalidRequest`: The body named no identifier or uri, or too many.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Publish the edition records a reader is about to reference, and return the uri+cid a shelf record's strongRef needs. The AppView calls this when a reader acts — shelves a book, marks a status — never on a page render: a crawl must not republish the catalogue, and a strongRef cannot be written before the record exists. The caller authenticates with an atproto service token minted by its own PDS, so the request proves an intent rather than a page view.",
      "errors": [
        {
          "description": "The service token was missing or rejected.",
          "name": "AuthRequired"
        },
        {
          "description": "The body named no identifier or uri, or too many.",
          "name": "InvalidRequest"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "identifiers": {
              "description": "Edition identifiers as search returns them. At most 100 entries across identifiers and uris.",
              "items": {
                "ref": "community.lexicon.media.book.defs#identifier",
                "type": "ref"
              },
              "maxLength": 100,
              "type": "array"
            },
            "uris": {
              "description": "Edition uris as resolveEditions returns them (the `atproto` identifier), when the caller already has them.",
              "items": {
                "format": "at-uri",
                "type": "string"
              },
              "maxLength": 100,
              "type": "array"
            },
            "waitMs": {
              "description": "How long the AppView may wait for a record to be written before the uri is reported as pending. Defaults to 2000; capped at 5000.",
              "maximum": 5000,
              "minimum": 0,
              "type": "integer"
            }
          },
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "editions": {
              "description": "Editions whose records exist now. The cid is what a strongRef must carry.",
              "items": {
                "properties": {
                  "cid": {
                    "format": "cid",
                    "type": "string"
                  },
                  "uri": {
                    "format": "at-uri",
                    "type": "string"
                  }
                },
                "required": [
                  "uri",
                  "cid"
                ],
                "type": "object"
              },
              "type": "array"
            },
            "pending": {
              "description": "Uris whose publication was requested but not written within waitMs. The caller may retry; the request stays queued.",
              "items": {
                "format": "at-uri",
                "type": "string"
              },
              "type": "array"
            }
          },
          "required": [
            "editions",
            "pending"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "net.olamaelcu.livtet.biblio.ensureEdition",
  "lexicon": 1
}
```
