Create and revoke API keys
An API key lets an app or website use your models without a WordPress account. Create one key for each app or site, and delete it to stop that app at once.
Before you start
- You need the administrator role.
Steps
Open the tab, create a key, copy it, and delete it when you no longer need it.
Step 1: Open the API keys tab
- Go to Settings.
- Select API keys.
Step 2: Create a key
- Select New API key.
- In Name, enter a name that shows where the key is used. For example:
Website. - Under Models, select the models the key can use. If you select none, the key can use every model.
- Turn on Can also create, edit and delete to let the key write. Leave it off for a read-only key.
- Select Create key.
Step 3: Copy the key
The Copy your key now dialog shows the key once, with an example request:
curl -H "X-Morphic-Key: <your key>" "<REST URL>items/…"
- Select Copy key.
- Store the key in the app or website that uses it.
Step 4: Delete a key
- In the API keys list, select Delete key (trash icon) on the key row.
- Select Delete key in the confirmation dialog.
Result
The API keys tab lists each key with these columns:
- Name: the name you entered.
- Key: the first 7 characters of the key, followed by
…. For example:mk_df4b…. The full key is not shown again. - Can: Read & write or Read only.
- Models: the models you selected, or All.
- Last used: how long ago the key was last used, or Never.
A key can read the models it allows. A key with Read only cannot create, edit or delete entries. This applies to every request that sends the key, including one signed in as a WordPress administrator.
A request with a malformed or unknown key is not rejected. Morphic treats it as a request with no key, so it gets only what public models allow.