Skip to Content
Sindre Sorhus
Back to Actions

Updated

How to Store an API Key Safely in Shortcuts on iPhone and Mac

By Sindre Sorhus, who makes the Actions app

A key in a “Text” action is part of the shortcut. When you share the shortcut, the key goes with it.

With Actions

  1. Install Actions, and open it once.
  2. Make a new shortcut, and add the “Keychain: Set” action of Actions.
  3. Type a name for the key, like openai, and paste the API key as the value. To have the key on all your devices, expand the action, and turn on “Sync to iCloud”.
  4. Run the shortcut once. Then delete the shortcut, so the key is only in the keychain.
  5. In the shortcut that uses the API, add “Keychain: Get” with the same name. Use its result, “Keychain Value”, where the key goes, like in a header of “Get Contents of URL”.

“Sync to iCloud” needs iCloud Keychain. Without it, the key is only on the device where you saved it. When the key does not exist, “Keychain: Get” returns nothing.

Tips

  • To remove a key, use “Keychain: Delete”.
  • To check that a key exists before you use it, use “Keychain: Has Key”.
  • For ChatGPT, Claude, and Gemini, the actions of AI Actions keep the key in their own settings. Guide

Get Actions

Additional actions for the Shortcuts app

Download on the App Store

Free

Requires
macOS, iOS, or visionOS 26 or later
Updated
June 2026
US App Store rating
4.8/5 (703 ratings)

More about Actions

Without an app

Put the key in a text file, like in the Shortcuts folder of iCloud Drive. In the shortcut, read the file with the “Get File from Folder” action, and use the result where the key goes.

When you share the shortcut, the key stays in the file. But the file is plain text, so all apps and people that can open the file can read the key. The keychain keeps it encrypted.