> ## 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.

# Turn auto-renew on or off

> Switch automatic renewal of a 30-day pass for the signed-in shopper.

## Request

```http theme={null}
POST /library/6702d3f0e1b3a40012cd3001/auto-renew
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "enabled": false
}
```

## 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. |
| `Content-Type` | string | Always set to `application/json`. |

## Path parameters

| Parameter | Type | Description |
| - | - | - |
| `entitlementId` | string | The `entitlementId` of a row from [Get the shopper's library](/api-reference/endpoint/library/get-library). |

## Body parameters

| Field | Type | Required | Description |
| - | - | - | - |
| `enabled` | boolean | Yes | `true` to renew automatically, `false` to stop. |

<Note>
  **How auto-renew works.** The shopper opts in when buying a pass, by sending `autoRenew: true` when adding the line to the cart or when [creating the order](/api-reference/endpoint/orders/create-from-cart). If they pay by card through Paystack and the card can be charged again, it is saved (encrypted) on the access record. From then on, within 3 days before the pass ends, Salesive charges the saved card at **today's** price and extends the pass by 30 days. After 3 failed charges auto-renew switches itself off, and the shopper is emailed each time.

  Turning it **off** here also throws the saved card away. Turning it **on** needs a card that was saved earlier, so there is no way to switch it on for a pass that was never bought with the opt-in. Lifetime access cannot be renewed.
</Note>

## Successful response

```json theme={null}
{
    "status": 200,
    "success": true,
    "message": "Auto-renew turned off",
    "data": {
        "entitlementId": "6702d3f0e1b3a40012cd3001",
        "autoRenew": false
    }
}
```

## Error responses

| Status | `code` | When |
| - | - | - |
| `400` | `invalid_body` | `enabled` is missing or not a boolean. |
| `400` | `not_renewable` | The access is lifetime. |
| `400` | `no_saved_card` | Turning it on without a saved card. |
| `403` | `login_required` | Not a real signed-in account. |
| `404` | `not_found` | No such access for this shopper in this store. |

```json theme={null}
{
    "status": 400,
    "success": false,
    "message": "No saved card. Tick \"Renew automatically\" the next time you buy this pass.",
    "code": "no_saved_card",
    "data": {}
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /library/{entitlementId}/auto-renew
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/{entitlementId}/auto-renew:
    post:
      summary: Turn auto-renew on or off
      description: >-
        Switches automatic renewal of a 30-day pass. Turning it off discards the
        saved card. Turning it on needs a card that was saved earlier, when the
        pass was bought with "Renew automatically" ticked. Lifetime access
        cannot be renewed.
      parameters:
        - $ref: '#/components/parameters/XShopIdHeader'
        - name: entitlementId
          in: path
          required: true
          schema:
            type: string
          description: The `entitlementId` of a library row.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - enabled
              properties:
                enabled:
                  type: boolean
              example:
                enabled: false
      responses:
        '200':
          description: Auto-renew updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 200
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Auto-renew turned off
                  data:
                    type: object
                    properties:
                      entitlementId:
                        type: string
                      autoRenew:
                        type: boolean
                    example:
                      entitlementId: 6702d3f0e1b3a40012cd3001
                      autoRenew: false
        '400':
          description: >-
            `enabled` is not a boolean (`invalid_body`), the access is lifetime
            (`not_renewable`), or there is no saved card (`no_saved_card`).
          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: >-
                    No saved card. Tick "Renew automatically" the next time you
                    buy this pass.
                  code: no_saved_card
                  data: {}
        '403':
          description: Not signed in with a real account.
          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: {}
        '404':
          description: No such access for this shopper in this store.
          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: 404
                  success: false
                  message: Access not found
                  code: not_found
                  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
  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.