---
schema_version: "1"
id: 20e2a5dd680bb6f68a013ff795df84c72e22f74c3ef505be98e67daa97591cb4
title: SharingReason
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_apexsharingreason.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_apexsharingreason.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: f38febf6d950c651277028c61e1a519f473a85bb9afb7434f550a3886f2dc01a
description: Represents an Apex sharing reason, which is used to indicate why sharing was implemented for a standard or custom object. Apex managed sharing allows developers to use Apex to programmatically share custom objects. When you use Apex managed sharing to share an object, only users with the “Modify All Data” permission can add or change the sharing on the object's record, and the sharing access is maintained when the record owner changes or is deactivated. Sharing reasons for standard objects are available for objects that have a corresponding share object (for example, AccountShare, OpportunityShare) and whose org-wide default can be set to Private or Public Read-Only. Objects on the detail side of a master-detail relationship, which have no share object of their own, aren't supported.
---
# SharingReason

Represents an Apex sharing reason, which is used to indicate why sharing was implemented for a standard or custom object. Apex managed sharing allows developers to use Apex to programmatically share custom objects. When you use Apex managed sharing to share an object, only users with the “Modify All Data” permission can add or change the sharing on the object's record, and the sharing access is maintained when the record owner changes or is deactivated. Sharing reasons for standard objects are available for objects that have a corresponding share object (for example, AccountShare, OpportunityShare) and whose org-wide default can be set to Private or Public Read-Only. Objects on the detail side of a master-detail relationship, which have no share object of their own, aren't supported.

Use SharingReason to create, update, or delete sharing reason definitions for a custom object. This type extends the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

## Version

Sharing reasons for custom objects are available in API version 14.0 and later. Sharing reasons for standard objects are available in API version 68.0 and later.

## Fields

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d139017e85">Field</th>

              <th class="featureTableHeader  " id="d139017e88">Field Type</th>

              <th class="featureTableHeader  " id="d139017e91">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d139017e85" data-title="Field"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm#meta_fullname">fullName</a></td>

              <td class="entry" headers="d139017e88" data-title="Field Type">string</td>

              <td class="entry" headers="d139017e91" data-title="Description">Required. Sharing reason name. The __c suffix is appended to
                custom sharing reasons.<p class="p">Inherited from <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm" title="The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.">Metadata</a>, this field is defined in the WSDL for this
                  metadata type. It must be specified when creating, updating, or
                  deleting. See <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_createMetadata.htm" title="Adds one or more new metadata components to your organization synchronously."><samp class="codeph java">createMetadata()</samp></a> to see an example of
                  this field specified for a call.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d139017e85" data-title="Field"><span class="keyword parmname">label</span></td>

              <td class="entry" headers="d139017e88" data-title="Field Type">string</td>

              <td class="entry" headers="d139017e91" data-title="Description">Required. Descriptive label for the sharing reason. Maximum of 40
                characters.</td>

            </tr>

          </tbody>

        </table>

## Usage

## Example

- A maximum of 10 custom sharing reasons can be created per standard object.
- Reserved row cause names (for example, Manual, Team, Sharing Rule, Record Collection) can't be used as sharing reason names.
- Deleting a sharing reason deletes all share records on that object that use the reason. This can revoke access for users, so treat deletion as a destructive change.

## Declarative Metadata Sample Definition

The definition of a sharing reason in a custom object:

<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
. . .
    <sharingReasons\>
        <fullName\>recruiter\_\_c</fullName\>
        <label\>Recruiter</label\>
    </sharingReasons\>
 . . .
</CustomObject\>

## Managed Package Support

Sharing reasons for standard and custom objects can be included in second-generation managed packages. On install, the fullName is prefixed with the package namespace (for example, myns\_\_Compliance\_Team). Packaged sharing reasons are locked in the subscriber org, so subscribers can't edit the label or developer name, or delete the reason directly. Uninstalling a package that contains sharing reasons deletes those reasons and all associated shares.

## Wildcard Support in the Manifest File

This metadata type doesn’t support the wildcard character \* (asterisk) in the package.xml manifest file. For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_searchlayouts.htm "SearchLayouts")
- [Next →](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_apexsharingrecalculation.htm "SharingRecalculation")