<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainCallback",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@T@SecKeychainCallback"
  },
  "title" : "SecKeychainCallback"
}
-->

# SecKeychainCallback

A customized callback function that keychain services call when a keychain event has occurred.

```
typealias SecKeychainCallback = (SecKeychainEvent, UnsafeMutablePointer<SecKeychainCallbackInfo>, UnsafeMutableRawPointer?) -> OSStatus
```

## Parameters

`keychainEvent`

The keychain event that occurred. The type of event that can trigger your callback depends on the bit mask you passed in the `eventMask` parameter of the function [`SecKeychainAddCallback(_:_:_:)`](/documentation/Security/SecKeychainAddCallback(_:_:_:)). See [`SecKeychainEvent`](/documentation/Security/SecKeychainEvent) for a list of possible values.

`info`

A pointer to a structure of type [`SecKeychainCallbackInfo`](/documentation/Security/SecKeychainCallbackInfo). This structure provides your callback with information about the keychain event.

`context`

A pointer to application-defined storage that your application previously passed to the function [`SecKeychainAddCallback(_:_:_:)`](/documentation/Security/SecKeychainAddCallback(_:_:_:)). You can use this value to provide information that the callback function needs in order to properly handle the event, such as an object on which the callback function should call a method.

## Return Value

A result code. See `Codes`.

## Discussion

You would declare your keychain callback function like this if you were to name it `MyKeychainCallback`:

Listing 1. Declaring a keychain callback function

```objc
OSStatus MyKeychainCallback (
    SecKeychainEvent keychainEvent,
    SecKeychainCallbackInfo *info,
    void *context
);
```

To add your callback function, use the [`SecKeychainAddCallback(_:_:_:)`](/documentation/Security/SecKeychainAddCallback(_:_:_:)) function. To remove your callback function, use the [`SecKeychainRemoveCallback(_:)`](/documentation/Security/SecKeychainRemoveCallback(_:)) function.

---

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)