> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get the shopper's library

> Return every digital title the signed-in shopper holds in this store, with download links.

## Request

```http theme={null}
GET /library
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
```

## Headers

| Header | Type | Description |
| - | - | - |
| `Authorization` | string | Provide the customer token as `Bearer <jwt>`. Must be a real, signed-in account. |
| `x-shop-id` | string | Identify the shop context. |

<Note>
  A guest session (the anonymous user from `POST /auth/ghost`) or a request with no token gets `403` with `code: "login_required"`. Send the shopper through the login flow, then call this again. Buying a digital item also needs a real account, because access is tied to the buyer's email. The response is sent with `Cache-Control: no-store` because every `downloadUrl` carries a credential.
</Note>

## Response fields

`data.items` has one row per title. When several purchases reach the same title (for example a lifetime copy and the all-access pass), the best one is shown.

| Field | Type | Description |
| - | - | - |
| `entitlementId` | string | The access record id. Pass it to [Turn auto-renew on or off](/api-reference/endpoint/library/set-auto-renew). |
| `productId` | string | The digital product id. |
| `name`, `author`, `images` | mixed | Title details for display. |
| `format`, `size` | string, number | `pdf`, `epub`, `mobi` or `zip`, and the size in bytes. |
| `source` | string | `purchase` (bought outright), `pass` (a 30-day pass for this title), `all_access` (the store pass) or `granted` (given by the seller). |
| `kind` | string | `lifetime` or `pass`. |
| `status` | string | `active` or `expired`. Revoked access is not listed. |
| `accessUntil` | string \| null | End of a pass. `null` for lifetime access. |
| `daysLeft` | number \| null | Whole days left. `null` for lifetime access, `0` once expired. |
| `autoRenew` | boolean | Whether the pass renews automatically. |
| `autoRenewCard` | object \| null | `{ brand, last4 }` of the saved card while auto-renew is on. |
| `renewMode` | string \| null | What buying again would buy: `pass` (this title for 30 days) or `all_access`. `null` when the row cannot be renewed. |
| `downloadUrl` | string \| null | Opens the file, see [Download a purchased file](/api-reference/endpoint/downloads/download). `null` once the access has expired, and always `null` for a 30-day pass or the all-access pass, which are read online. |
| `canDownload` | boolean | `true` only for active titles bought outright. |
| `canRead` | boolean | `true` for active PDFs: open them with [Read a title online](/api-reference/endpoint/library/read-book). |
| `readOnly` | boolean | `true` for a 30-day pass or the all-access pass. |

`data.pass` is the store's current [all-access pass](/api-reference/endpoint/digital/get-pass), or `null`, so the library page can offer a renewal without a second call.

## Successful response

```json theme={null}
{
    "status": 200,
    "success": true,
    "message": "Library retrieved",
    "data": {
        "items": [
            {
                "entitlementId": "6702d3f0e1b3a40012cd3001",
                "productId": "6702c1a4e1b3a40012cd2001",
                "name": "The Lagos Cookbook",
                "author": "Ngozi Okafor",
                "images": ["https://cdn.salesive.com/d/lagos-cookbook-cover.jpg"],
                "format": "pdf",
                "size": 8421376,
                "source": "pass",
                "kind": "pass",
                "status": "active",
                "accessUntil": "2026-11-11T08:00:00.000Z",
                "daysLeft": 30,
                "autoRenew": true,
                "autoRenewCard": { "brand": "visa", "last4": "4081" },
                "renewMode": "pass",
                "readOnly": true,
                "canDownload": false,
                "canRead": true,
                "downloadUrl": null
            }
        ],
        "pass": {
            "name": "All-access pass",
            "description": "Every book in the store for 30 days.",
            "price": 7500,
            "periodDays": 30,
            "productCount": 12
        }
    }
}
```

## Renewing

A pass is renewed by buying it again: add `{ "digitalId": "<productId>", "mode": "pass" }` (or `{ "allAccess": true }` when `renewMode` is `all_access`) with [Add item to cart](/api-reference/endpoint/cart/add-item) and check out as usual. The new purchase extends the same access record, adding 30 days to whatever is left.

## Error response

```json theme={null}
{
    "status": 403,
    "success": false,
    "message": "Please log in to see your library",
    "code": "login_required",
    "data": {}
}
```

Other codes: `400 shop_required` (no store context) and `500 library_error`.


## OpenAPI

````yaml api-reference/openapi.json GET /library
openapi: 3.1.0
info:
  title: Salesive Store API
  description: >-
    REST interface for querying products, categories, and merchandising banners
    exposed by Salesive storefronts.
  version: 1.0.0
servers:
  - description: Production
    url: https://store.salesive.com/api/v1
security:
  - BearerAuth: []
    ShopIdHeader: []
paths:
  /library:
    get:
      summary: Get the shopper's library
      description: >-
        Returns every digital title the signed-in shopper holds in this store,
        active and expired, most recently updated first, plus the store's
        all-access pass so the page can offer a renewal. Needs a real signed-in
        account: guests get `403` with `code: "login_required"`. The response is
        never cached.
      parameters:
        - $ref: '#/components/parameters/XShopIdHeader'
      responses:
        '200':
          description: The shopper's library.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 200
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Library retrieved
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/LibraryItem'
                      pass:
                        $ref: '#/components/schemas/DigitalPassSummary'
                    example:
                      items:
                        - entitlementId: 6702d3f0e1b3a40012cd3001
                          productId: 6702c1a4e1b3a40012cd2001
                          name: The Lagos Cookbook
                          author: Ngozi Okafor
                          images:
                            - >-
                              https://cdn.salesive.com/d/lagos-cookbook-cover.jpg
                          format: pdf
                          size: 8421376
                          source: pass
                          kind: pass
                          status: active
                          accessUntil: '2026-11-11T08:00:00.000Z'
                          daysLeft: 30
                          autoRenew: true
                          autoRenewCard:
                            brand: visa
                            last4: '4081'
                          renewMode: pass
                          downloadUrl: >-
                            https://store.salesive.com/api/v1/downloads/9f2c1b7e4a6d8035c1e2f4a7b9d0c3e5a8b1d4f6c7e90123
                      pass:
                        name: All-access pass
                        description: Every book in the store for 30 days.
                        price: 7500
                        periodDays: 30
                        productCount: 12
        '400':
          description: No store context.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: object
                  code:
                    type: string
                    description: Machine-readable reason.
                example:
                  status: 400
                  success: false
                  message: Store context is required
                  code: shop_required
                  data: {}
        '403':
          description: The request is anonymous or a guest session.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: object
                  code:
                    type: string
                    description: Machine-readable reason.
                example:
                  status: 403
                  success: false
                  message: Please log in to see your library
                  code: login_required
                  data: {}
        '500':
          description: The library could not be built.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: object
                  code:
                    type: string
                    description: Machine-readable reason.
                example:
                  status: 500
                  success: false
                  message: Could not load your library
                  code: library_error
                  data: {}
      security:
        - BearerAuth: []
          ShopIdHeader: []
components:
  parameters:
    XShopIdHeader:
      name: x-shop-id
      in: header
      description: >-
        Optional identifier that scopes responses to a specific storefront when
        the referer cannot be inferred.
      required: false
      schema:
        type: string
  schemas:
    LibraryItem:
      type: object
      description: >-
        One title the shopper can (or could) download. One row per title: when
        several purchases reach the same title (say a lifetime copy and the
        all-access pass) the best one is shown.
      properties:
        entitlementId:
          type: string
          description: The access record id. Use it for the auto-renew toggle.
        productId:
          type: string
        name:
          type: string
        author:
          type: string
        images:
          type: array
          items:
            type: string
            format: uri
        format:
          type: string
          nullable: true
          enum:
            - pdf
            - epub
            - mobi
            - zip
            - null
        size:
          type: integer
          description: File size in bytes.
        source:
          type: string
          enum:
            - purchase
            - pass
            - all_access
            - granted
          description: >-
            How the shopper got it: bought outright, a 30-day pass for this
            title, the all-access pass, or granted by the seller.
        kind:
          type: string
          enum:
            - lifetime
            - pass
        status:
          type: string
          enum:
            - active
            - expired
        accessUntil:
          type: string
          format: date-time
          nullable: true
          description: End of the pass. `null` for lifetime access.
        daysLeft:
          type: integer
          nullable: true
          description: Whole days left. `null` for lifetime access, `0` once expired.
        autoRenew:
          type: boolean
        autoRenewCard:
          type: object
          nullable: true
          properties:
            brand:
              type: string
              nullable: true
            last4:
              type: string
        renewMode:
          type: string
          nullable: true
          enum:
            - pass
            - all_access
            - null
          description: >-
            What buying again would buy: a 30-day pass for the title, or the
            all-access pass. `null` when the row cannot be renewed (lifetime
            access).
        downloadUrl:
          type: string
          format: uri
          nullable: true
          description: >-
            Opens the file. `null` once the access has expired. The link carries
            the credential, so do not log or share it.
    DigitalPassSummary:
      type: object
      nullable: true
      description: The store's all-access pass, or `null` when none is on sale.
      properties:
        name:
          type: string
        description:
          type: string
        price:
          type: number
        periodDays:
          type: integer
          description: Length of one purchase in days (30).
        productCount:
          type: integer
          description: Listed products the pass covers.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT issued by the Salesive Store API for authenticated shoppers.
    ShopIdHeader:
      type: apiKey
      in: header
      name: x-shop-id
      description: >-
        Optional storefront identifier sent as a header to scope responses to a
        specific shop. Try It requests remember this value once provided.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.