> 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/quick-start/how-locks-work.md).

# How locks work

The three building blocks behind every lock in Sami B2B Lock, Password Protect — content, access rules, and behavior.

Every lock you create in Sami B2B Lock, Password Protect is made of the same three pieces. Once these three concepts click, every other page in these docs is just a variation on one of them.

## 1. Content to lock

This is *what* you're protecting: your whole website, specific products or variants, collections, pages, blogs and articles, a specific URL, or checkout. A lock always protects exactly one content type, and you can carve out exceptions with an exclude list (specific URLs or products that stay open even though the rest of that content type is locked).

See [Locks overview](/b2b-lock-password-protect/locks/overview.md) for the full list of content types and how to combine them across multiple locks.

## 2. Access rules

This is *who or what* must be true about the visitor before the content unlocks. Access rules check things like whether the visitor is logged in, has a specific customer tag, knows a passcode, is browsing from a particular country, or has a certain product in their cart.

Rules are grouped into **access keys**:

* Rules inside the **same** access key are combined with **AND** — the visitor must satisfy every rule in that key. Use this to build something like "must be logged in AND tagged wholesale."

Most rules also have an **If / Unless** setting: **If** means the rule is satisfied when the visitor matches the condition, and **Unless** inverts that — satisfied when the visitor does *not* match. This doesn't apply to the action-based rules (Passcode, Secret link, Subscribe to unlock, Confirmation prompt, Custom liquid), since those work through their own verification step rather than a simple yes/no match.

See [Access rules overview](/b2b-lock-password-protect/access-rules/overview.md) for the full catalogue of rules, and [Combining rules](/b2b-lock-password-protect/access-rules/combining-rules.md) for more on how multiple conditions are evaluated.

## 3. Lock behavior

This is *what actually happens* to a visitor who doesn't pass your access rules. Depending on the content type, that can mean:

* The price and/or **Add to cart** button are hidden, with a message or styled button shown in their place.
* A lock screen or message appears asking the visitor to sign in, enter a passcode, subscribe, confirm a statement, or otherwise verify themselves.
* The visitor is redirected to a different page or URL.
* The item is hidden from storefront menus and/or from on-site search and sitemaps, so it's not just blocked but not discoverable either.

You can combine several behaviors on the same lock — for example, hiding a product's price and Add to cart button while also removing it from your navigation menu.

See [Lock behavior overview](/b2b-lock-password-protect/lock-behavior/overview.md) for the full list of behaviors and how they interact.

{% hint style="info" %}
Put together, a lock reads like a sentence: "On \[content to lock], require \[access rules], and if the visitor doesn't pass, do \[lock behavior]." The quickstart example builds "On this product, require the visitor to be logged in, and if they're not, hide the price and Add to cart button."
{% endhint %}

## Related docs

* [Locks overview](/b2b-lock-password-protect/locks/overview.md)
* [Access rules overview](/b2b-lock-password-protect/access-rules/overview.md)
* [Lock behavior overview](/b2b-lock-password-protect/lock-behavior/overview.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/quick-start/how-locks-work.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.
