<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/kSecAttrAccessGroup",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@kSecAttrAccessGroup"
  },
  "title" : "kSecAttrAccessGroup"
}
-->

# kSecAttrAccessGroup

A key with a value that’s a string indicating the access group the item is in.

```
let kSecAttrAccessGroup: CFString
```

## Discussion

The corresponding value is of type <doc://com.apple.documentation/documentation/CoreFoundation/CFString> and indicates the item’s one and only access group.

For an app to access a keychain item, one of the groups to which the app belongs must be the item’s group. The list of an app’s access groups consists of the following string identifiers, in this order:

- The strings in the app’s <doc://com.apple.documentation/documentation/BundleResources/Entitlements/keychain-access-groups>
- The app ID string
- The strings in the <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.security.application-groups>

Two or more apps that are in the same access group can share keychain items. For more details, see [Sharing access to keychain items among a collection of apps](/documentation/Security/sharing-access-to-keychain-items-among-a-collection-of-apps).

Specify which access group a keychain item belongs to when you create it by setting the [`kSecAttrAccessGroup`](/documentation/Security/kSecAttrAccessGroup) attribute in the query you send to the [`SecItemAdd(_:_:)`](/documentation/Security/SecItemAdd(_:_:)) method. Naming a group that’s not among the creating app’s access groups—including the empty string, which is always an invalid group—generates an error. If you don’t explicitly set a group, keychain services defaults to the app’s first access group, which is either the first keychain access group, or the app ID when the app has no keychain groups. In the latter case, the item is only accessible to the app creating the item, since no other app can be in that group.

By default, the [`SecItemUpdate(_:_:)`](/documentation/Security/SecItemUpdate(_:_:)), [`SecItemDelete(_:)`](/documentation/Security/SecItemDelete(_:)), and [`SecItemCopyMatching(_:_:)`](/documentation/Security/SecItemCopyMatching(_:_:)) methods search all the app’s access groups. Add the [`kSecAttrAccessGroup`](/documentation/Security/kSecAttrAccessGroup) attribute to the query to limit the search to a particular group.

> Important:
> This attribute applies to macOS keychain items only if you also set a value of `true` for the ``doc://com.apple.security/documentation/Security/kSecUseDataProtectionKeychain`` key, the ``doc://com.apple.security/documentation/Security/kSecAttrSynchronizable`` key, or both.

## See Also

[Sharing access to keychain items among a collection of apps](/documentation/Security/sharing-access-to-keychain-items-among-a-collection-of-apps)

Enable apps to share keychain items with each other by adding the apps to an access group.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)