{"id":1588,"date":"2026-09-09T09:00:00","date_gmt":"2026-09-09T03:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/"},"modified":"2026-09-09T09:00:00","modified_gmt":"2026-09-09T03:30:00","slug":"apex-sharing-keywords-with-without-inherited","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/","title":{"rendered":"Apex Sharing Keywords: with, without and inherited sharing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Apex Sharing Keywords decide whether your code respects the record access of the person running it. With the right keyword, a teacher sees only her own students. With the wrong one, she might see every student in the company. That is why every Apex class that queries or saves data should declare its sharing mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn with sharing, without sharing and inherited sharing, what happens when you leave the keyword out, and how the rules changed in API version 67.0. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-sharing-rules-roles-owd\/\">Salesforce sharing rules, roles and OWD<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-access-modifiers\/\">Apex access modifiers<\/a> and the <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-trigger-handler-pattern\/\">Apex trigger handler pattern<\/a>. This is the first post of Level 6: Security in Code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Apex Sharing Keywords?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex Sharing Keywords are words you put on a class declaration, such as <code>public with sharing class CourseService<\/code>. They control record-level access: which rows a query returns and which rows code may change. They do not control object permissions or field-level security, which we cover in the next post.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a school library. A normal student card opens only the shelves you may use. A librarian&#8217;s master key opens every shelf. with sharing is the student card, without sharing is the master key, and inherited sharing borrows whichever card the caller is holding.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Apex Sharing Keywords Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Record access is the core of Salesforce security. Here is why Apex Sharing Keywords matter at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, a Lightning page for tutors must show only courses the tutor can see.<\/li>\n\n<li>Also, a nightly job that recalculates seats must see every enrolment.<\/li>\n\n<li>Next, a shared service class may be called from both kinds of code.<\/li>\n\n<li>AppExchange security reviews flag classes with no sharing declaration.<\/li>\n\n<li>Finally, a missing or wrong keyword can leak salary or student data.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So choosing between Apex Sharing Keywords is a security decision, not a style choice.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Apex Sharing Keywords Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex Sharing Keywords are checked when code runs. First, Salesforce looks at the class where the running method is defined. Next, it reads that class&#8217;s keyword: with sharing applies the user&#8217;s sharing rules, while without sharing ignores them. Then, for inherited sharing, it uses the mode of the calling class. After that, if the class is an entry point, such as a Lightning controller, inherited sharing runs as with sharing. Finally, queries and DML return or change only the records allowed by that mode.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-1024x640.png\" alt=\"Apex Sharing Keywords diagram showing how Salesforce finds the class, reads its keyword and applies sharing\" class=\"wp-image-1586\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">How Apex decides which sharing mode applies.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">with sharing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">with sharing enforces the current user&#8217;s record access: org-wide defaults, role hierarchy, sharing rules, teams and manual shares. Use it as your default for most classes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">without sharing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">without sharing ignores record-level sharing, so code can see records the user cannot. Use it only for small, well-reviewed classes that truly need system-level record access.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">inherited sharing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">inherited sharing runs in the caller&#8217;s mode. When the class is the entry point, such as an @AuraEnabled method, a REST service or an async job, it runs as with sharing. So it is a safe choice for reusable service classes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Omitted Sharing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In API version 67.0 and later, a class with no keyword runs as with sharing. In API 66.0 and earlier, the result depended on the caller and the class type, and often meant without sharing. So always write the keyword.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Triggers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Triggers cannot declare a keyword. They run in a without sharing context. However, in API 67.0 and later, queries and DML inside triggers default to user mode, which applies the user&#8217;s sharing anyway.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apex Sharing Keywords at a Glance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below sums up the four options.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Declaration<\/th><th>Record sharing<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td>with sharing<\/td><td>Enforced<\/td><td>Controllers and most classes<\/td><\/tr><tr><td>without sharing<\/td><td>Ignored<\/td><td>Small system-level helpers<\/td><\/tr><tr><td>inherited sharing<\/td><td>Caller&#8217;s mode, with sharing at entry points<\/td><td>Reusable service classes<\/td><\/tr><tr><td>No keyword (API 67.0+)<\/td><td>Enforced, like with sharing<\/td><td>Avoid, always declare<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">with sharing vs without sharing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares the two main keywords.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>with sharing<\/th><th>without sharing<\/th><\/tr><\/thead><tbody><tr><td>Records returned<\/td><td>Only those the user can see<\/td><td>All records<\/td><\/tr><tr><td>Respects role hierarchy<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>Risk of data leaks<\/td><td>Low<\/td><td>High if misused<\/td><\/tr><tr><td>Typical class<\/td><td>Lightning controller<\/td><td>Seat recalculation helper<\/td><\/tr><tr><td>Enforces FLS and CRUD<\/td><td>No, use user mode<\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which is simple. Start with with sharing everywhere. Then move only the exact logic that needs wider access into a small without sharing class.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-1024x640.png\" alt=\"Apex Sharing Keywords diagram comparing with sharing and without sharing\" class=\"wp-image-1587\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">with sharing vs without sharing.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Apex Sharing Keywords Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s apply Apex Sharing Keywords at Bright Path Tutors. Course__c has a Private org-wide default, so tutors see only courses they own or that are shared with them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: A with sharing Controller<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class MyCoursesController {\n\n    @AuraEnabled(cacheable=true)\n    public static List&lt;Course__c&gt; getMyCourses() {\n        \/\/ Returns only courses this user can see through sharing\n        return [SELECT Id, Name, Fee__c FROM Course__c ORDER BY Name];\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller lists courses for a Lightning component. Because the class is with sharing, a tutor sees only her own courses, not the whole catalog.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: A Small without sharing Helper<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public without sharing class SeatCounter {\n\n    \/\/ Counts every active enrolment, even ones the user cannot see\n    public static Integer activeSeats(Id courseId) {\n        return [SELECT COUNT() FROM Enrolment__c\n                WHERE Course__c = :courseId AND Status__c = 'Active'\n                WITH SYSTEM_MODE];\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Seat counts must include all students, even those in other tutors&#8217; groups. So this one method lives in a tiny without sharing class. WITH SYSTEM_MODE makes the query skip user-mode checks, so the class keyword decides record access.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: An inherited sharing Service<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public inherited sharing class CourseService {\n\n    public static List&lt;Course__c&gt; findOnlineCourses() {\n        return [SELECT Id, Name FROM Course__c WHERE Is_Online__c = true];\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When a with sharing controller calls CourseService, the query respects sharing. When a without sharing batch calls it, the query sees all online courses. If an async job uses CourseService as its entry point, it runs as with sharing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Check the Result<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what Asha Mehta, a tutor, sees in a quick test.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MyCoursesController.getMyCourses()   -&gt; 3 courses (only hers)\nSeatCounter.activeSeats(apexBasicsId) -&gt; 28 (all active students)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The controller protects other tutors&#8217; courses, while the helper still counts every seat correctly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apex Sharing Keywords and Inner Classes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Inner classes do not inherit the outer class&#8217;s keyword. So declare a keyword on each inner class that runs queries or DML. Also, a method follows the keyword of the class where it is defined, not the class that calls it, except in inherited sharing classes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Apex Sharing Keywords<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Leaving out the keyword and relying on the default.<\/li>\n\n<li>Marking a whole controller without sharing to fix one query.<\/li>\n\n<li>Assuming with sharing also enforces field-level security.<\/li>\n\n<li>Forgetting that inner classes need their own keyword.<\/li>\n\n<li>Using without sharing in code that Experience Cloud users can reach.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Apex Sharing Keywords<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Declare a keyword on every class that queries or saves data.<\/li>\n\n<li>Use with sharing by default and inherited sharing for reusable services.<\/li>\n\n<li>Keep without sharing classes small, named clearly and reviewed.<\/li>\n\n<li>Set an explicit access mode, user or system, on database operations.<\/li>\n\n<li>Test with System.runAs and a restricted user.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create a tutor user with a role below the Sales Manager. Then call MyCoursesController.getMyCourses inside System.runAs in a test and assert that only that tutor&#8217;s courses come back. Hint: insert two courses with different owners in the test.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Apex Sharing Keywords<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sharing questions appear in almost every developer interview. Here are the 21 questions asked most about Apex Sharing Keywords.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Apex Sharing Keywords<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What does with sharing do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It enforces the current user&#8217;s record-level access, such as OWD, role hierarchy and sharing rules.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What does without sharing do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It ignores record-level sharing, so code can access records the user cannot see.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What does inherited sharing do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It runs in the sharing mode of the calling class, and as with sharing when it is the entry point.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What is the default when no keyword is used?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In API version 67.0 and later, with sharing. In older versions, it depended on the caller and was often without sharing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: Do sharing keywords enforce field-level security?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. They control record access only. Use user mode or stripInaccessible for object and field permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: Can a trigger have a sharing keyword?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. Triggers run in a without sharing context.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: Which keyword should be your default?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">with sharing, unless a clear business need requires otherwise.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Apex Sharing Keywords<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: Does an inner class inherit the outer class&#8217;s keyword?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. Each inner class needs its own declaration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: A with sharing method is called from a without sharing class. Which mode applies?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">with sharing, because the mode comes from the class where the method is defined.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: When does inherited sharing run as without sharing?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only when it is called from an established without sharing context.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: Which mode does anonymous Apex run in?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">with sharing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: How do you count all records while respecting sharing elsewhere?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Move that one query into a small without sharing class and call it from your with sharing code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you test sharing behaviour?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create users with different roles and run code inside System.runAs, then assert the records returned.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: What mode does an async job with inherited sharing use?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">with sharing, because each async job is a new entry point.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Apex Sharing Keywords<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: How do user mode and sharing keywords work together?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">User mode applies the user&#8217;s sharing, CRUD and FLS. The class keyword decides record access for operations run in system mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: What changed in API version 67.0?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Classes without a keyword run as with sharing, and database operations run in user mode by default.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: Why does the AppExchange security review care about sharing?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Missing or unnecessary without sharing declarations can expose customer data to the wrong users.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Does a child class adopt the parent&#8217;s sharing mode?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, if the child has no explicit keyword, it adopts the parent&#8217;s mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: When is without sharing acceptable in Experience Cloud?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only for narrow, reviewed logic, such as letting guests read a specific public record, never for broad queries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: Why prefer inherited sharing over no keyword for services?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It states the intent clearly and guarantees with sharing at entry points.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How would you review a class for sharing risks?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check its keyword, every query and DML, its callers, and whether any without sharing logic can be narrowed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/apex-dev\/references\/apex-dev\/apex-classes-keywords-sharing.html\" target=\"_blank\" rel=\"noopener noreferrer\">Use the with sharing, without sharing, and inherited sharing Keywords (Apex Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/platform\/apex-dev\/references\/apex-dev\/apex-security-sharing-rules.html\" target=\"_blank\" rel=\"noopener noreferrer\">Enforce Sharing Rules (Apex Developer Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apex Sharing Keywords control record-level access in your code.<\/li>\n\n<li>with sharing enforces sharing, and without sharing ignores it.<\/li>\n\n<li>inherited sharing follows the caller and runs as with sharing at entry points.<\/li>\n\n<li>In API 67.0 and later, a missing keyword means with sharing.<\/li>\n\n<li>Sharing keywords do not enforce CRUD or field-level security.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Record access is only one layer. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-crud-and-fls-user-mode\/\">Apex CRUD and FLS with USER_MODE and stripInaccessible<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apex Sharing Keywords decide whether your code respects the record access of the person running it. With the right keyword, a teacher sees only&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1585,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[98,26,91,7,97,17,77],"swapz_series":[],"class_list":["post-1588","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-apex","tag-intermediate","tag-interview-questions","tag-salesforce","tag-salesforce-developer","tag-security","tag-sharing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apex Sharing Keywords: with, without and inherited<\/title>\n<meta name=\"description\" content=\"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex Sharing Keywords: with, without and inherited\" \/>\n<meta property=\"og:description\" content=\"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-09T03:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Apex Sharing Keywords: with, without and inherited sharing\",\"datePublished\":\"2026-09-09T03:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/\"},\"wordCount\":1744,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-sharing-keywords-with-without-inherited-featured.png\",\"keywords\":[\"Apex\",\"Intermediate\",\"Interview Questions\",\"Salesforce\",\"Salesforce Developer\",\"Security\",\"Sharing\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/\",\"name\":\"Apex Sharing Keywords: with, without and inherited\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-sharing-keywords-with-without-inherited-featured.png\",\"datePublished\":\"2026-09-09T03:30:00+00:00\",\"description\":\"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-sharing-keywords-with-without-inherited-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-sharing-keywords-with-without-inherited-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Apex Sharing Keywords featured image: title card with an Apex code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-sharing-keywords-with-without-inherited\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex Sharing Keywords: with, without and inherited sharing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex Sharing Keywords: with, without and inherited","description":"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/","og_locale":"en_US","og_type":"article","og_title":"Apex Sharing Keywords: with, without and inherited","og_description":"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-09T03:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Apex Sharing Keywords: with, without and inherited sharing","datePublished":"2026-09-09T03:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/"},"wordCount":1744,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png","keywords":["Apex","Intermediate","Interview Questions","Salesforce","Salesforce Developer","Security","Sharing"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/","url":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/","name":"Apex Sharing Keywords: with, without and inherited","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png","datePublished":"2026-09-09T03:30:00+00:00","description":"Apex Sharing Keywords explained simply: with sharing, without sharing, inherited sharing, omitted sharing, triggers, API 67 changes and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-sharing-keywords-with-without-inherited-featured.png","width":2400,"height":1260,"caption":"Apex Sharing Keywords featured image: title card with an Apex code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/apex-sharing-keywords-with-without-inherited\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apex Sharing Keywords: with, without and inherited sharing"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1588"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1588\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1585"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1588"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}