> For the complete documentation index, see [llms.txt](https://docs.samita.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samita.io/b2b-lock-password-protect/access-rules/passcode.md).

# Passcode

Protect content with one or more shared passcodes that shoppers type in to unlock it.

The Passcode rule protects content behind one or more access codes. Instead of checking a fact about the visitor, it presents a passcode field on the storefront — anyone who knows a valid code gets in. It's a straightforward way to gate content for a group of people who don't have (or don't need) customer accounts, like event attendees, press previews, or a private sale you're promoting by word of mouth.

## How Passcode works

Passcode is one of the app's action-based rules, so it doesn't have an If/Unless toggle — it works through its own verification step instead. When a visitor reaches locked content protected by this rule, they see a passcode field. If what they type matches any one of the passcodes you've configured, they pass; a wrong or empty entry shows an error and keeps the content locked.

You can keep more than one passcode active on the same rule at once — useful if you want to hand out a different code to different groups (say, one for a newsletter list and a different one for in-store customers) while still treating them as the same access key.

## Steps to manage

1. Open the app and go to **Locks**, then open the lock you want to protect (or create a new one).
2. On the **Lock setup** tab, set **Content to lock** to whatever you're protecting.
3. Click the **Unlock rules** tab to continue.
4. Add an access rule and set the condition type to **Passcode**.

   <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-154ae16fdd36dbe5f2b203675a63028332968b2a%2Fscreenshot-access-rules-passcode-picker.png?alt=media" alt="Access rule picker with Passcode selected as the condition type"><figcaption><p>Choosing Passcode as the condition type for a new access rule.</p></figcaption></figure>
5. Type a passcode into the field and click **Add Passcode** — or leave the field empty and click the same button to have the app generate a random code for you automatically.

   <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-362eb2907617b110d315060894fa99b6e51b5ef5%2Fscreenshot-access-rules-passcode-add.png?alt=media" alt="Passcode field with a code entered and the Add Passcode button"><figcaption><p>Adding a passcode manually, or leaving the field blank to auto-generate one.</p></figcaption></figure>
6. Repeat step 5 to add more passcodes if you want several active at once — each one added independently unlocks the same content.
7. Each passcode in the list has its own **Copy** and **Delete** buttons: copy a code to share it, or delete a code you no longer want to accept.

   <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-42ab3c37fdc8ed972ba48e9142b4d501b2460252%2Fscreenshot-access-rules-passcode-list.png?alt=media" alt="List of active passcodes with copy and delete controls next to each one"><figcaption><p>Managing the list of active passcodes — copy one to share it, or delete one to revoke it.</p></figcaption></figure>
8. Configure **Grant access (optional)** — leave it blank to remember a verified visitor only for their current browser session, or enter a number and choose a unit (minutes, hours, or days) to keep them remembered for a fixed duration instead.

   <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-aa2bf85a7a6b8a0c600621f3c1bfbe71605c1ff9%2Fscreenshot-access-rules-passcode-duration.png?alt=media" alt="Grant access duration field with a number and unit selector for the Passcode rule"><figcaption><p>Setting how long a verified visitor stays unlocked before needing to re-enter a passcode.</p></figcaption></figure>
9. Customize the passcode message and any other translated copy for this lock, per storefront language, from the lock's Messages section.

   <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-3d3322a9a3aab924a12a07709aaaa66b2dce1284%2Fscreenshot-access-rules-passcode-messages.png?alt=media" alt="Passcode message field in the lock&#x27;s translation and messages settings"><figcaption><p>Editing the passcode prompt copy shown to shoppers.</p></figcaption></figure>
10. Customize the design of the passcode input and surrounding lock screen (colors, button style) from the lock's Design section if you want it to match your theme.

    <figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-48a5f76aa2a55c3abf997ad2851d301360e9808b%2Fscreenshot-access-rules-passcode-design.png?alt=media" alt="Design settings panel showing passcode input color options"><figcaption><p>Adjusting the passcode input's colors from the lock's Design settings.</p></figcaption></figure>
11. Click **Save**.

{% hint style="info" %}
Passcode is one of only two access rules that support **Request access** — a built-in form shoppers without a code can use to ask you for one. See [Request access overview](/b2b-lock-password-protect/request-access/overview.md) for how to turn it on and manage submissions.
{% endhint %}

## Customer experience on the storefront

A shopper who reaches passcode-protected content sees a "Content locked" message with a passcode field and a **Submit** button. If they submit an empty field, they see "Passcode cant be empty !!"; if they enter a code that doesn't match any active passcode, they see "Passcode is incorrect !!". Once they enter a correct code, the content unlocks immediately, and the app remembers them for the rest of their session (or for your configured grant-access duration) so they aren't asked again on that same browser.

All of this copy is editable per lock and per storefront language from the Messages section — see [Translate lock messages](/b2b-lock-password-protect/design-and-customization/translate-messages.md).

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-bdae167d1196a5c8313c506858f2b5471c1353f9%2Fscreenshot-storefront-passcode.png?alt=media" alt="A locked storefront page replaced by the app&#x27;s Content locked card with a passcode field and Submit button."><figcaption><p>A visitor without the code gets the passcode card instead of the page.</p></figcaption></figure>

## Related docs

* [Secret link](/b2b-lock-password-protect/access-rules/secret-link.md)
* [Request access overview](/b2b-lock-password-protect/request-access/overview.md)
* [Grant access duration](/b2b-lock-password-protect/lock-behavior/grant-access-duration.md)
* [Translate lock messages](/b2b-lock-password-protect/design-and-customization/translate-messages.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.samita.io/b2b-lock-password-protect/access-rules/passcode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
