Locksmith
Install LocksmithContact us
  • Quick Start
  • πŸ’‘Basics
    • A Locksmith Overview
    • Creating locks
    • Creating keys
    • Compatibility with other apps and Shopify features
    • Removing Locksmith
  • πŸ”†Tutorials
    • Approving customer registrations
    • Creating restricted wholesale products
    • Hiding product prices and/or the add to cart button
    • Selling digital content on Shopify
    • More tutorials...
      • Setting up multiple price tiers
      • Customizing messages
      • Customizing the customer login page
      • Customizing the registration form
      • Customizing the passcode form
      • Customizing Locksmith’s "Access denied content" messages, and redirecting customers
      • Customizing the email list signup form
      • Showing multiple prompts on the same page
      • Showing content only to specific Markets
      • Input lists
      • Protecting against bots
      • Earn recurring revenue on your exclusive content using ReCharge
      • Use Locksmith and PayWhirl together to grant access based on subscriptions
      • Liquid locking basics
      • Restricting checkout from the cart
      • Confirmation key condition
      • Restricting customers to a specific collection
      • Passcode-specific redirects
      • Grow your subscriber lists with Klaviyo
      • Use Klaviyo as an access control list
      • Use Mailchimp to collect customer emails
      • Hiding out-of-stock products
      • How to use a private browsing session
      • Granting access to variants by visitor input
      • Offering different variants by postal code
      • Locking products by tag
      • Locking multiple pages at once
      • Making a product accessible exclusively from the direct product link
      • Creating private team areas
      • Importing customers in bulk
      • Disabling Locksmith for certain theme files
      • Adding translations to your Locksmith messages
      • Redirecting using Locksmith
      • Locking variants
        • Limiting the scope of variant locks using the product tag key condition
        • Handling JavaScript DOM errors caused by variant locks
      • Locking the customer registration form
      • Locking the search results page in your store
      • How to clear cache for a single website
      • Disabling Locksmith for certain theme files
      • πŸ› οΈManual mode
      • Grant access for a limited time when using passcodes or secret links
      • Testing Locksmith on unpublished themes
      • Locking blog posts
      • How to access your browser's dev tools
      • Restricting the cart for mixed products and combinations of products
      • Locking products by vendor
      • How do I hide my Shopify store's header and footer
      • Hiding navigation links for locked resources
      • Hiding products from product-grids
      • Restricting a product so that it can only be purchased by new customers
      • Automatically managing the seo.hidden metafield using Locksmith
      • Locking the home page
      • Setting up checkout validation with Locksmith
      • How to hide theme sections, blocks, and snippets
  • πŸ”‘Keys: Access methods in Locksmith
    • About key conditions
    • Customer account keys
    • Passcode keys
    • Secret link keys
    • Visitor location keys
    • More about keys...
      • Inverting conditions in Locksmith
      • Combining key conditions
      • "Has purchased..." key
      • Using the "Force open other locks" setting
      • Liquid key basics
      • Manual mode
      • Excluding content from locks
      • IP address keys
      • Newsletter keys
      • Limiting the scope of variant locks using the product tag key condition
  • 🌻FAQs
    • Why aren't my locks working?
    • FAQ: I see blank spaces in my collections and/or searches when locking
    • Can Locksmith hide content from my in-store search?
    • Locksmith is not working with my page builder app
    • What should I do if my site is loading slowly?
    • I'm the administrator of my site and I cannot access pages because of Locksmith locks.
    • More FAQs...
      • I'm having trouble using Locksmith with a site speed optimization app.
      • The app isn't loading. What do I do?
      • Can Locksmith protect shipping methods, billing methods, or coupon codes?
      • I switched themes, and Locksmith isn't working
      • Why isn't my passcode, secret link, newsletter, or location key working?
      • Can Locksmith lock Shopify's public JSON API for my online store?
      • Why are my customers seeing a reCAPTCHA when logging in?
      • My passcode or newsletter prompt is not updating on my store when I change it.
      • My featured collections on my home page only show one product.
      • My infinite scrolling doesn't show all of my products.
      • My customers have to enter their e-mail address into the Mailchimp key every time they visit.
      • How do I know which customers have used a certain key?
      • Why is Locksmith adding information to my orders?
      • Locksmith isn't installing correctly!
      • Locksmith is not uninstalling correctly!
      • How does Locksmith affect search engines and SEO?
      • How do I change where customers are redirected to after registration on Shopify
      • The thing I want to lock isn't showing up in the Locksmith search
      • I am getting an "already taken" error when trying to create a metafield definition for seo.hidden
      • How do I add a hero banner image to Locksmith's access messages
  • πŸ“’Policies
    • Usage agreement
    • Locksmith's pricing policy: Pay what feels good
    • Privacy policy
    • Data policy
    • Contact us
  • πŸ”¦Developer Tools
    • Locksmith Admin API
    • Locksmith Storefront API
    • Locksmith variables
    • Unsupported functionality
    • Requests from Locksmith
  • More developer docs...
    • Using the Admin API with Locks
  • App Integrations
    • Easy Appointment Booking
Powered by GitBook
On this page
  • Body Parameters
  • Optional query parameters
  • Keys
  • Responses
  • Notes
  • Example cURL requests

Was this helpful?

Export as PDF
  1. More developer docs...

Using the Admin API with Locks

PreviousMore developer docs...NextEasy Appointment Booking

Last updated 13 hours ago

Was this helpful?

Important: Locksmith support cannot help write or troubleshoot these requests for you. However, if there is anything unclear in our documentation, please feel free to contact us with questions.

Locks can be created via our Admin API using the following endpoint:

POST /lock

This guide covers information specific to creating locks. See our general Admin API guide for more general information on forming these requests (including headers and authentication):

Body Parameters

Note that only the top 3 parameters are required. If left blank, the rest will use their defaults as noted.

Parameter
Type
Description
Required

resource_id

integer

Shopify resource ID. This number can be found at the end of the resource URL in your Shopify Admin.

Required. Unless creating a shop lock, in which case it can be left out.

resource_type

string

Required. Type of resource - product, custom_collection, smart_collection page, blog , or shop . Other types of locks unsupported.

Required

keys

array

List of key definitions that grant access; can be an empty array on creation.

Required

enabled

boolean

Whether the lock is active.

Optional Default: true

options

object

Lock behavior options. See below.

Optional

options.hide_links_to_resource

boolean

Optional Default: false

options.hide_resource

boolean

Optional

Default: false

options.hide_resource_from_sitemaps

boolean

Optional

Default: false

options.manual

boolean

Optional Default: false

options.noindex

boolean

Optional Default: true

Optional query parameters

Add these to the end of the /lock endpoint. For example:

https://uselocksmith.com/api/unstable/lock?dryrun=true

Name
Type
Description
Extra info

install

boolean

If true, a theme install on your published theme is performed (if request is successful).

Recommended unless you are manually triggering an install later! See POST /install endpoint.

dryrun

boolean

If true, changes are not persisted, but a success/error response is still returned.

Useful for testing/debugging.

Keys

Locksmith has a large variety of key conditions types and their corresponding options. The easiest way to create a valid key config is doing it right inside the Locksmith app on a lock page. Once created, the key config can be copy-pasted directly from the Locksmith app:

If using multiple keys, make sure to create a valid JSON array and use it as the "keys" parameter in your request. Once you've created valid key configs, you can reuse them wherever you are using this API. Check the examples below.

Responses

  • 200 Success - the response body will contain the json representation of the newly created lock

  • 400 Error - Post payload incorrectly formed

  • 404 Error - Post URL incorrectly formed

Creating locks using invalid input may occasionally create malfunctioning locks. It is important that you test your storefront and delete any locks that aren't working as expected.

Notes

  • On success, the returned json object will contain fields you did not explicitly add. Note that fields prefixed with _ are automatically generated by the backend and should not be included in request bodies.

  • After creation, you can use the GET /locks/:lock_id endpoint to verify.

Example cURL requests

# Create a minimal product-level lock with required fields only
curl -X POST https://uselocksmith.com/api/unstable/lock \
  -H "x-shopify-shop-domain: example-store.myshopify.com" \
  -H "x-locksmith-access-token: abcd1234" \
  -H "Content-Type: application/json" \
  -d '{
    "resource_id": 1234567890,
    "resource_type": "product",
    "keys": []
  }'
# Create a shop-level lock that applies to the entire storefront
curl -X POST https://uselocksmith.com/api/unstable/lock \
  -H "x-shopify-shop-domain: example-store.myshopify.com" \
  -H "x-locksmith-access-token: abcd1234" \
  -H "Content-Type: application/json" \
  -d '{
    "resource_type": "shop",
    "keys": []
  }'
# Create a product-level lock. Optional parameters included. without keys.
curl -X POST https://uselocksmith.com/api/unstable/lock \
  -H "x-shopify-shop-domain: example-store.myshopify.com" \
  -H "x-locksmith-access-token: abcd1234" \
  -H "Content-Type: application/json" \
  -d '{
    "resource_id": 1234567890,
    "resource_type": "product",
    "enabled": true,
    "options": {
      "hide_links_to_resource": true,
      "hide_resource": true,
      "hide_resource_from_sitemaps": true,
      "manual": false,
      "noindex": true
    },
    "keys": []
  }'
# minimal product level lock. WITH keys
curl -X POST "https://uselocksmith.com/api/unstable/lock" \
  -H "x-shopify-shop-domain: example-store.myshopify.com" \
  -H "x-locksmith-access-token: abcd1234" \
  -H "Content-Type: application/json" \
  -d '{
    "resource_id": 1234567890,
    "resource_type": "product",
    "keys": [
      {
        "options": {
          "customer_autotag": "",
          "force_open": false,
          "redirect_url": "",
          "inverse": false
        },
        "conditions": [
          {
            "type": "customer_tag",
            "inverse": false,
            "options": {
              "customer_tag": "approved"
            }
          }
        ]
      },
      {
        "options": {
          "customer_autotag": "",
          "force_open": false,
          "redirect_url": "",
          "inverse": false
        },
        "conditions": [
          {
            "type": "passcodes",
            "inverse": false,
            "options": {
              "passcodes": ["letmein"],
              "case_sensitive": true,
              "customer_remember": true
            }
          }
        ]
      }
    ]
  }'

Hide navigation links pointing to the resource on storefront. .

Hide the resource from product grids. .

Remove resource from sitemap generation. .

Indicates a manual lock.

Add noindex meta tag to the storefreont rendering to prevent search engine indexing. .

Locksmith Admin API
See documentation
See documentation
See documentation
See documentation.
See documentation