<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainItemCreateFromContent(_:_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeychainItemCreateFromContent"
  },
  "title" : "SecKeychainItemCreateFromContent(_:_:_:_:_:_:_:)"
}
-->

# SecKeychainItemCreateFromContent(_:_:_:_:_:_:_:)

Creates a new keychain item from the supplied parameters.

```
func SecKeychainItemCreateFromContent(_ itemClass: SecItemClass, _ attrList: UnsafeMutablePointer<SecKeychainAttributeList>, _ length: UInt32, _ data: UnsafeRawPointer?, _ keychainRef: SecKeychain?, _ initialAccess: SecAccess?, _ itemRef: UnsafeMutablePointer<SecKeychainItem?>?) -> OSStatus
```

## Parameters

`itemClass`

A constant identifying the class of item to create. See [`SecItemClass`](/documentation/Security/SecItemClass) for valid constants.

`attrList`

A pointer to the list of attributes for the item to create.

`length`

The length of the buffer pointed to by the `data` parameter.

`data`

A pointer to a buffer containing the data to store.

`keychainRef`

A reference to the keychain in which to add the item. Pass `NULL` to specify the default keychain.

`initialAccess`

An access object for this keychain item. Use the [`SecAccessCreate(_:_:_:)`](/documentation/Security/SecAccessCreate(_:_:_:)) function to create an access object or the [`SecKeychainItemCopyAccess(_:_:)`](/documentation/Security/SecKeychainItemCopyAccess(_:_:)) function to copy an access object from another keychain item. If you pass `NULL` for this parameter, the access defaults to the application creating the item.

`itemRef`

On return, a pointer to a reference to the newly created keychain item. This parameter is optional. You must call the `CFRelease` function to release this object when you are finished using it.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## Discussion

Each item stored in the keychain contains data (such as a certificate), which is indexed by the item’s attributes. Use this function to create a keychain item from its attributes and data. To create keychain items that hold passwords, use the [`SecKeychainAddInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)`](/documentation/Security/SecKeychainAddInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)) or [`SecKeychainAddGenericPassword(_:_:_:_:_:_:_:_:)`](/documentation/Security/SecKeychainAddGenericPassword(_:_:_:_:_:_:_:_:)) functions.

A `SecKeychainItemRef` object for a certificate that is stored in a keychain can be safely cast to a `SecCertificateRef` for use with the Certificate, Key, and Trust API.

This function automatically calls the function [`SecKeychainUnlock(_:_:_:_:)`](/documentation/Security/SecKeychainUnlock(_:_:_:_:)) to display the Unlock Keychain dialog box if the keychain is currently locked.

---

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)