How to use multiple Codex accounts
Create one CODEX_HOME per account, set cli_auth_credentials_store = "file" in each, then sign in and launch Codex through a named shell function. Use --profile for settings, not identity. Never copy auth.json between account homes, and use only accounts you are authorized to access.
A personal subscription for your own projects, a work account for the day job, maybe a client’s on top of that. Codex assumes you have one. Here is how to run several properly, and the two failure modes that quietly break a second account weeks after you set it up.
Give each account its own CODEX_HOME
Codex keeps its local state in one directory. OpenAI’s environment-variable documentation is direct about it: Codex stores config, authentication, logs, sessions, skills and other state under CODEX_HOME, which defaults to ~/.codex. The directory must already exist before you point Codex at it.
That single variable is the whole mechanism. Point it at a different path and Codex reads a different account’s settings, credentials and history, with no knowledge that the first one exists.
# one directory per account
mkdir -p ~/.codex-personal ~/.codex-work
# sign in to each, separately
CODEX_HOME=~/.codex-personal codex login
CODEX_HOME=~/.codex-work codex login
# then run whichever you want
CODEX_HOME=~/.codex-work codex
Typing that prefix every time gets old by the second day. Put it behind shell functions instead, so the account is something you choose rather than something you remember.
# ~/.zshrc
codex-personal() { CODEX_HOME="$HOME/.codex-personal" codex "$@"; }
codex-work() { CODEX_HOME="$HOME/.codex-work" codex "$@"; }
Each directory is a complete Codex home, which cuts both ways. Your work account will not see your personal session history, and any config.toml tuning you did has to be repeated in the other home or copied across deliberately. Isolation is the feature and also the chore.
Whether this stays a chore depends on how often you switch. Twice a week is fine. Several times a day, across a CLI and a desktop app, is where people start looking for something that manages it for them.
Switch Codex accounts without logging out
Start the shell function for the account you want. Each new Codex process inherits that function’s CODEX_HOME and reads only the cached login in that home, so switching from personal to work is a new command, not a codex logout cycle.
# start either account
codex-personal
codex-work
# confirm that the work home has a stored authentication method
CODEX_HOME="$HOME/.codex-work" codex login status
codex login status reports the active authentication method and exits successfully when credentials are present. OpenAI does not document it as an account-identity readout, so it cannot prove that the cached login is the work email you intended. Keep the home names unambiguous and complete each browser login with only the intended account signed in.
Why codex --profile is not the answer
Codex has a feature called profiles, and the name sends a lot of people down the wrong path. Profiles are configuration layers. Passing --profile deep-review loads config.toml and then overlays deep-review.config.toml from the same CODEX_HOME, which is how you switch model or reasoning settings.
Credentials are not part of that overlay. They belong to the home directory, so every profile inside one CODEX_HOME is the same signed-in account. If you want a second account, the variable is the lever, and the profile flag is unrelated.
Check where your credentials actually live
This is the step almost every guide on the subject skips, and it decides whether the isolation above is real.
Codex does not always keep credentials in auth.json. OpenAI’s authentication documentation says cli_auth_credentials_store picks the storage backend, and auto prefers the operating system credential store before falling back to the file. On a Mac with a working keychain, auto generally means the keychain.
| Value | Where credentials go | Use it when |
|---|---|---|
| auto | OS credential store when available, otherwise auth.json | The default. Fine for one account, ambiguous for several. |
| file | auth.json inside that CODEX_HOME | Running multiple accounts. Storage follows the directory, so isolation is visible. |
| keyring | OS credential store | You want the keychain and run a single account. |
| ephemeral | Memory only, for that session | Shared or throwaway machines, CI. |
OpenAI’s documentation does not say whether keychain entries are separated by CODEX_HOME. Rather than guess, take the ambiguity off the table: write the setting into each account’s own config file, and the credential is then a file you can point at, inside the directory you named.
# in ~/.codex-personal/config.toml and ~/.codex-work/config.toml
cli_auth_credentials_store = "file"
The trade is explicit. OpenAI describes auth.json as a plaintext file, so you are choosing a readable file on disk over the keychain’s protection. For a multi-account setup that certainty is usually worth it. Keep the directories out of any repository, Dropbox folder or backup that leaves the machine.
Never copy auth.json between accounts
Plenty of switcher scripts work by moving auth.json files in and out of ~/.codex. The approach looks sound, passes every test you run on the day, and fails later.
OpenAI’s authentication documentation states that Codex refreshes tokens automatically during use, so the credential in the active directory is rewritten in place as you work. The maintainers of the open-source codex-accounts tool describe the consequence: OpenAI rotates an account’s refresh token on every login and invalidates the previous one server-side, so a stored copy older than the account’s most recent login is already dead no matter how well-formed it looks. We have not found that rotation behaviour in OpenAI’s own documentation, so treat the mechanism as third-party reporting.
Three specific ways it bites:
- The stale copy. You switch back to an account after a fortnight. The file is intact, the JSON parses, and the token was rotated away days ago. You are signed out with no useful error.
- The duplicate directory. The same account sitting in two homes has two credentials rotating against each other. Each refresh invalidates the other, so both eventually die.
- The misdirected login. A plain codex login writes into whichever home is active. Sign in as personal while work is active and the work directory now holds a personal credential.
Setting CODEX_HOME avoids all three, because nothing ever moves. Each account refreshes its own credential in the directory it lives in. If you do want a switcher that swaps the active account rather than running several at once, prefer one that symlinks ~/.codex/auth.json into the account’s own file so refreshes write through, which is what codex-accounts does. The account switcher comparison shows which tools swap auth.json and which give each account its own home.
Running two Codex desktop apps at once
The CLI is the easy case. Two terminals with different CODEX_HOME values coexist without any special handling, since each process reads its own directory.
The desktop app adds a second problem on top. OpenAI’s official account-switching availability lists ChatGPT web, iOS and Android, not Codex desktop. Edi Hasaj’s write-up on running two Codex accounts on macOS isolates the desktop data directory as well as CODEX_HOME, but it is a third-party workaround rather than a supported Codex mode. A crash, a manual quit or a system sleep can interrupt it.
What the environment-variable method leaves unsolved
Everything above is worth doing and it is where most people stop. It is also worth being clear about what you still do not have, because no amount of shell configuration produces these.
| Still missing | Why |
|---|---|
| One history across accounts | Each home keeps its own sessions. Finding last month’s conversation means remembering which account you were using. |
| A view of which account has room | You discover the limit by hitting it, mid-task, rather than before you start. |
| Carrying work across when one runs out | The accounts cannot share a session, so continuing elsewhere means copying context by hand. |
| A pooled allowance | Quota is metered per account and per plan. Nothing merges it, and any tool claiming otherwise is describing something else. |
The pooled-allowance row is permanent, whatever any tool claims. The other three are interface problems, so a layer above Codex can address them, and it is worth checking which ones a given tool actually covers for Codex rather than for Claude Code. We list our own gaps below.
Doing it in Crowsnest
Crowsnest is ours, so weigh this section accordingly. It handles the directory bookkeeping described above and adds the part shell configuration cannot reach: a reading of how much each account has left, before you commit a task to one.
Registering an account creates its home at ~/.crowsnest/codex-accounts/<id>/ and hands back the exact command to run in your own terminal, CODEX_HOME=<dir> codex login. Crowsnest does not perform the sign-in. The OAuth exchange stays between you and OpenAI, and the credential is written by Codex into that directory.
It also never touches the credential afterwards. Crowsnest checks whether auth.json exists, to show the account as signed in, and reads nothing from it. No copying, no symlinking, no token parsing, which is the same discipline the section above asks of any switcher you might use instead.
Each account in its own home
One CODEX_HOME per registered account, created and tracked for you, with the login command generated per account.
Usage read per account
Crowsnest asks the Codex app-server for each signed-in account’s limits under that account’s own home, so the remaining window is visible before you start rather than after you hit it.
Continue when one runs out
After a Codex turn fails on quota, Crowsnest offers another signed-in account and previews exactly what the new conversation will receive.
An attributed fork, not a resume
The new thread starts under the other account’s home with a briefing of at most 8,000 characters. Omitted turns are counted in the text, and the original conversation is left untouched.
Where Codex support is thinner than Claude Code
Worth stating plainly, because the two providers are not at parity in the shipped app and a feature list would hide it.
- The early warning reached Codex later. Crowsnest can warn at 90% of a window and offer to continue before a failure. That notice covered only Claude Code until 0.3.10; it now runs for Codex conversations too.
- Codex history is not attributed per account. The conversation gallery reads Codex sessions from the default ~/.codex home, so older Codex threads are not labelled by the account that wrote them, and reopening one runs it under the default account.
- Automatic continuation acts only when the destination is unambiguous. You have to turn it on, and it proceeds only when exactly one other account of that provider is signed in. With two or more it draws a chooser and waits.
- Signed in means the file is there. An expired credential still shows as signed in until a turn actually fails.
Quota is never pooled here either. Each account keeps its own meter, shown separately, because adding them together would hide which subscription is about to run out.
Several accounts per provider is a Pro and Premium feature. Standard works with your default Claude Code and Codex accounts and still browses and searches history. If you run a single Codex account, none of this applies to you and the environment variable above is the whole answer.
Questions behind the search
How do I use multiple Codex accounts?
Give each account its own CODEX_HOME directory and sign in separately inside each one. CODEX_HOME defaults to ~/.codex and holds that account’s config, credentials, history and logs, so pointing it somewhere else gives you a second isolated account. Do not copy auth.json between directories; keep one independently created login in each home.
How do I switch Codex accounts without logging out?
Start Codex with the CODEX_HOME assigned to that account. With the shell functions in this guide, run codex-personal or codex-work; each process reads the cached login from its own home, so you do not need codex logout. CODEX_HOME=... codex login status can confirm the authentication method, but OpenAI does not document it as an account-identity readout.
Does codex --profile switch between accounts?
No. Profiles are configuration layers, not accounts. Passing --profile name loads config.toml and then overlays name.config.toml from the same CODEX_HOME, which changes settings such as model or reasoning effort. Authentication is unaffected, because it belongs to CODEX_HOME rather than to the profile.
Can I run two Codex accounts at the same time?
Yes for the CLI. Two shells with different CODEX_HOME values run concurrently without touching each other, because each process reads its own state directory. Codex desktop is different: OpenAI lists account switching for ChatGPT web, iOS and Android, not Codex desktop. Running separate desktop instances requires a third-party workaround and is not an official Codex mode.
Why does my second Codex account keep logging out?
Check two things. A copied auth.json can become stale after token rotation, according to third-party switcher maintainers, and the auto credential store can put credentials in the operating system keychain instead of the account directory. Keep one independently created login per home and set cli_auth_credentials_store to file in each config.toml when you need storage to follow CODEX_HOME.
Do multiple Codex accounts combine my usage limits?
No. Each account keeps its own usage, billing, history and workspace, and no tool can merge them. Separate accounts can keep personal, employer and client work on the right billing relationship. They do not create a larger shared allowance and should not be used to evade a plan limit.
Is it against OpenAI’s terms to have more than one Codex account?
Use only accounts you are authorized to access. OpenAI’s account-switching help gives personal and work accounts as examples, but separate accounts do not merge billing or usage. OpenAI’s terms prohibit circumventing rate limits or restrictions, so do not use this setup to evade a plan limit; check the current terms for each account.
Codex behaviour above was checked against OpenAI’s published Codex documentation on October 20, 2026, with third-party sources named where first-party documentation is silent. Crowsnest behaviour was re-checked against the released 0.3.16 application source on November 3, 2026. Codex changes quickly; follow OpenAI’s own documentation for current behaviour.