Skip to content

Connect an external app to WordPress with application passwords

Learn how to use WordPress application passwords so an outside app, script or dashboard can read and write through the REST API without ever holding your login password. This guide shows you how to create one, scope it to a least-privilege user, call the site with curl, and revoke it the moment you no longer need it.

This guide shows you how to let something outside your site read or write content through the WordPress REST API. That something might be a mobile app, a deploy script, an automation tool, a reporting dashboard or another WordPress site. REST stands for representational state transfer, and it is the HTTP interface WordPress publishes at /wp-json/; an API, short for application programming interface, is how one program talks to another. Handing that outside tool your admin login is the wrong move, because it exposes the account you use daily and it stops working the day you turn on two-factor authentication. The answer is an application password, a second credential built into WordPress core since version 5.6 that works only for API calls and can be revoked on its own. By the end you will have a scoped credential, a working call over curl, and a routine for auditing and rotating it.

What you’ll accomplish

  • Create an application password for a WordPress user, both from the profile screen and from the command line.
  • Give the outside tool its own user with only the permissions it needs, instead of reusing an administrator.
  • Call the REST API with curl and read a real answer back, for both a read and a write.
  • Tell a 401 from a 403 at a glance, so you fix the credential or the permission rather than guessing.
  • End state: an outside app authenticating over HTTPS with a credential you can revoke in seconds, without changing anyone’s login.

Prerequisites

  • WordPress 5.6 or newer. Check with wp core version, or look at Dashboard → Updates.
  • The site served over HTTPS, meaning HTTP secured by TLS (transport layer security, the encryption that protects data in transit). WordPress hides the whole feature on a plain HTTP site, and this guide has no workaround for that.
  • An Administrator login on the site, so you can create users and read other people’s application passwords.
  • Shell access as the site user, over SSH (the encrypted remote terminal protocol) or through cPanel’s Terminal, plus WP-CLI (the WordPress command-line tool) available as wp. Check with wp --info. Steps 4, 6 and 8 also give a browser-only path.
  • curl, the command-line HTTP client, on whatever machine you test from. Check with curl --version.
  • One thing worth knowing before you start: an application password bypasses two-factor authentication by design, because a script cannot type a code from a phone. That is exactly why the user it belongs to should be a limited one. If you have not yet set up two-factor authentication on your admin accounts, do that first.

How it works

An application password is a 24-character credential that WordPress generates for one user and stores as a hash, the same way it stores a login password. It is not an API key in the usual sense, because it carries no permissions of its own. It borrows the roles and capabilities of the user it belongs to, so a password on an Author account can do only what an Author can do. A user can hold many of them, each with a name you choose, and revoking one leaves the others and the login password untouched.

The outside app sends it using HTTP Basic authentication, the scheme defined in RFC 7617. The client joins the user name and the application password with a colon, encodes that string with base64, and sends it as a header: Authorization: Basic <encoded>. Base64 is an encoding, not encryption, and anyone who can read the header can read the password inside it. That single fact is why HTTPS is required rather than recommended, and why WordPress will not even show you the Application Passwords panel on a site that is not using it.

WordPress ignores spaces and punctuation in the value, so the grouped form the admin screen shows you and the unbroken 24-character string both work.

Six-step chain showing an Authorization header travelling from an external app through TLS, the edge, the web server and PHP into WordPress, with the failure that can occur at each step listed beside it

Two records get kept for every application password: last_used, the date it last authenticated, and last_ip, the address it came from. Those two fields are the whole audit story, and step 8 uses them.

Step-by-step

1. Confirm an application password is the right credential. It suits a caller you control: your own script, your own dashboard, one site talking to another. It suits a single tool acting as one identity. It does not suit a product that has to act for many different people, and it does not suit a browser session on your own site, which already has a cookie.

Decision tree with four questions that sorts a REST API caller into a cookie and nonce, an application password, OAuth 2.0, a JSON Web Token plugin, or a custom REST route

2. Check that the feature is available on this site. WordPress turns application passwords off on a site that is not using HTTPS. A plugin or a snippet can turn them off too. Ask WordPress directly rather than hunting through the admin screens.

cd ~/public_html
wp option get siteurl
wp eval 'var_export( wp_is_application_passwords_available() ); echo "\n";'
https://example.com
true

true means you can proceed. false with an http:// site URL means fix HTTPS first. false with an https:// site URL means something on the site is filtering the feature off, and Troubleshooting covers that.

3. Create a user with only the permissions the tool needs. Reusing your administrator account lets the outside tool install plugins and edit other users. A reporting dashboard has no business doing either. Pick the smallest built-in role that covers the job. Subscriber can read; Contributor can write drafts; Author can publish its own posts; Editor can edit everyone’s.

wp user create reporting-bot bot@example.com \
  --role=author --display_name='Reporting bot'
Success: Created user 7.
Password: aX2%tRq8Lm#4Ze1v

WP-CLI prints a login password because every user has one. You will not use it, and this account never needs to sign in. If no built-in role fits, clone the closest one and adjust its capabilities.

wp role create api_reader 'API reader' --clone=subscriber
wp cap add api_reader edit_posts
wp cap list api_reader
Success: Role with key 'api_reader' created.
Success: Added 1 capability to 'api_reader' role.
read
edit_posts

4. Create the application password in the profile screen. Sign in as an Administrator and open Users → All Users, then click the user you made in step 3. Scroll to the Application Passwords section near the bottom. Type a name in New Application Password Name that says which tool will hold it, such as reporting-dashboard, then click Add New Application Password.

The password appears once, in six groups of four characters, with a button to copy it. Copy it now. WordPress stores only a hash, so losing the value means creating a new one. The name is a label for your own records and grants nothing.

5. Or create it with WP-CLI. This is the path for a deploy script or a server with no browser session. The second argument is the name, and --porcelain prints the password on its own so you can pipe it somewhere.

wp user application-password create reporting-bot reporting-dashboard --porcelain
K3mRqz7TbVnW9pXs2Ldh4Jf6

Without --porcelain the same value appears inside a success message. Either way it is shown once. Store it straight into a secrets manager, or an environment file only the calling service can read.

6. Call the REST API with curl. Start with a read that proves who WordPress thinks you are. Type the password into a shell variable first, so it stays out of your history and out of the process list.

read -rs WP_APP_PASSWORD
curl -sS -u "reporting-bot:$WP_APP_PASSWORD" \
  'https://example.com/wp-json/wp/v2/users/me?_fields=id,name,slug'
{"id":7,"name":"Reporting bot","slug":"reporting-bot"}

That is the whole handshake. The -u flag builds the Authorization: Basic header for you. If your language has no equivalent, build the header yourself from base64 of user:password.

printf '%s' "reporting-bot:$WP_APP_PASSWORD" | base64
cmVwb3J0aW5nLWJvdDpLM21ScXo3VGJWblc5cFhzMkxkaDRKZjY=

Send that value as a header and the result is identical.

curl -sS -H "Authorization: Basic cmVwb3J0aW5nLWJvdDpLM21ScXo3VGJWblc5cFhzMkxkaDRKZjY=" \
  'https://example.com/wp-json/wp/v2/users/me?_fields=id,slug'

Now prove it can write. This creates a draft, which is safe to delete afterwards.

curl -sS -u "reporting-bot:$WP_APP_PASSWORD" -X POST \
  -H 'Content-Type: application/json' \
  -d '{"title":"Created by the reporting bot","status":"draft"}' \
  'https://example.com/wp-json/wp/v2/posts?_fields=id,status,link'
{"id":5120,"status":"draft","link":"https://example.com/?p=5120"}

7. Give every tool its own password. A credential shared between three tools cannot be revoked without breaking two of them. Rotating then costs nothing. Create the replacement, deploy it, confirm it works, then delete the old one by its UUID. A UUID, or universally unique identifier, is the long dashed string WordPress assigns to each application password.

wp user application-password list reporting-bot \
  --fields=uuid,name,created,last_used,last_ip
+--------------------------------------+---------------------+------------+------------+---------------+
| uuid                                 | name                | created    | last_used  | last_ip       |
+--------------------------------------+---------------------+------------+------------+---------------+
| 6f1c0a3e-77b2-4d51-9a08-2b5e4c9d1f30 | reporting-dashboard | 2026-09-19 | 2026-09-19 | 203.0.113.44  |
| 1b7d9e02-3c64-4a88-b1f5-8e0a77c2d613 | deploy-runner       | 2026-06-02 | 2026-09-18 | 198.51.100.12 |
+--------------------------------------+---------------------+------------+------------+---------------+
wp user application-password delete reporting-bot 1b7d9e02-3c64-4a88-b1f5-8e0a77c2d613
Success: Deleted 1 of 1 application password.

If you have no policy of your own, rotate once a year, and rotate at once when somebody who held the value leaves the team. Revocation takes effect on the next request.

8. Audit what already exists. Most sites that have been running a few years hold application passwords nobody remembers creating. Walk every user and look at the last_used column.

wp user list --field=ID | while read -r id; do
  printf '\n== user %s ==\n' "$id"
  wp user application-password list "$id" --fields=name,created,last_used,last_ip
done

Anything with an empty last_used, or a date months old, is doing nothing but widening your exposure. Delete it. You can also read the list over the API itself, which suits a monitoring job.

curl -sS -u "reporting-bot:$WP_APP_PASSWORD" \
  'https://example.com/wp-json/wp/v2/users/me/application-passwords?_fields=name,last_used,last_ip'

To cut every credential for one user at once, after a laptop is lost for example, revoke them all. In the browser the same button reads Revoke all application passwords on the user’s profile.

wp user application-password delete reporting-bot --all
Success: Deleted all application passwords.

Validate it works

Four checks, in order. The first proves the credential works and the second proves a wrong one is rejected. The third proves WordPress recorded the use, and the fourth proves the account is as limited as you intended.

curl -sS -o /dev/null -w 'authenticated: %{http_code}\n' \
  -u "reporting-bot:$WP_APP_PASSWORD" \
  https://example.com/wp-json/wp/v2/users/me
curl -sS -o /dev/null -w 'wrong password: %{http_code}\n' \
  -u 'reporting-bot:WrongWrongWrongWrong1234' \
  https://example.com/wp-json/wp/v2/users/me
authenticated: 200
wrong password: 401

A 200 on the first line and a 401 on the second is the pair you want. Two 401s means the header is not reaching WordPress, and the first Troubleshooting item is yours. Two 200s would mean something is authenticating requests that should fail, which points at a plugin overriding authentication.

wp user application-password list reporting-bot --fields=name,last_used,last_ip
+---------------------+------------+--------------+
| name                | last_used  | last_ip      |
+---------------------+------------+--------------+
| reporting-dashboard | 2026-09-19 | 203.0.113.44 |
+---------------------+------------+--------------+

Today’s date in last_used confirms the call you just made landed on this credential and not another. Last, ask the API to do something the account should not be allowed to do.

curl -sS -u "reporting-bot:$WP_APP_PASSWORD" \
  'https://example.com/wp-json/wp/v2/users?_fields=id,slug'
{"code":"rest_user_cannot_view","message":"Sorry, you are not allowed to list users.","data":{"status":403}}

A 403 here is the success signal. It means the credential authenticated and the permission check then stopped it, which is the boundary you built in step 3.

Troubleshooting

Every request returns 401 although the password is correct. Usually the web server drops the Authorization header before PHP runs. That happens when PHP runs as CGI or FastCGI. On Apache 2.4.13 and newer, add CGIPassAuth On inside the site’s virtual host or .htaccess. Older Apache needs a rewrite rule in .htaccess above the WordPress block instead.

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=HTTP_AUTHORIZATION:%1]

On Nginx with PHP-FPM, confirm the header is passed through in the location ~ \.php$ block.

fastcgi_param HTTP_AUTHORIZATION $http_authorization;

Reload the web server and retry the validation pair above.

The Application Passwords section is missing from the profile screen. WordPress hides it when wp_is_application_passwords_available() returns false. That happens on a site whose address is http:// rather than https://, and when code filters the feature off. Check both.

wp option get siteurl
wp option get home
wp eval 'var_export( wp_is_application_passwords_available() ); echo "\n";'
grep -rn "wp_is_application_passwords_available" wp-content/ wp-config.php

The grep looks for the wp_is_application_passwords_available filter, which is how a plugin, a theme or a snippet in wp-config.php turns the feature off. A hit that returns false is your answer. Fix HTTPS rather than forcing the feature on over plain HTTP, because over HTTP the credential is readable by anyone on the network path.

You get 403 with rest_forbidden or a rest_cannot_ code. The credential worked and the capability check failed, so this is a permissions problem rather than an authentication one. Check what the user can actually do.

wp user get reporting-bot --fields=ID,user_login,roles
wp cap list author

Give the role the missing capability with wp cap add, or move the user to a role that already has it. Resist the urge to switch it to Administrator, since that undoes step 3. Our guide to WordPress REST API errors lists the rest of the error codes and what each one points at.

Anonymous requests to /wp-json/ fail too. Then the problem is the REST surface, not your credential. Test without any credential at all.

curl -sS -o /dev/null -w '%{http_code}\n' https://example.com/wp-json/

A 200 means REST is reachable. A 403, 404 or an HTML challenge page means a security plugin, a firewall rule or the CDN in front of the site is blocking /wp-json/. Allow your caller’s IP address, or narrow the rule to the routes you actually want closed. If you deliberately locked down REST earlier, revisit restricting unauthenticated REST API access and add an exception for this user.

The credential works with curl but fails from your app. Two causes account for most of it. Some HTTP clients drop credentials when they follow a redirect, so point the app at the canonical address with no redirect in the way, or set the client’s equivalent of curl’s --location-trusted. Others send the header only after a 401 challenge; WordPress does not issue one, so configure the client to send Basic credentials pre-emptively on the first request.

When this is the wrong approach

Application passwords fit a caller you own. They stop fitting in four situations.

A product that acts for many different users needs OAuth 2.0, added by a plugin. Each person grants access from their own account and can withdraw it later. Asking hundreds of users to paste an application password into an outside service serves nobody well.

A headless front end, meaning a site whose pages are rendered outside WordPress, is usually better served by a JSON Web Token plugin. Those issue short-lived tokens that expire on their own, which limits the damage when one leaks into a log file.

High-volume machine-to-machine traffic is a poor fit for a different reason. Basic authentication verifies the password hash on every request, which costs real processor time at hundreds of requests a minute. A purpose-built endpoint with caching and a rate limit will serve you better.

And when you need a permission narrower than any WordPress role, write your own REST route with a permission_callback that checks exactly the capability you want. The WordPress REST API handbook covers registering routes, and WP-CLI’s documentation covers the user and capability commands used above. For more of the command-line patterns in this guide, see our notes on advanced WP-CLI commands.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.