Don’t Just YOLO Codex Permissions: Understand the Three Built-in Tiers, Then Write a Profile per Project

Author’s note: This breaks down the three built-in tiers of the Codex permission profile and how to write your own, then lays out a least-privilege setup for API development scenarios.

When you have Codex run scripts, call APIs, and edit several repos for you, the easiest move is to just grant full permissions. It’ll get you a working run on the first try—but it can also read your .env and send requests anywhere. This article covers the three built-in Codex permission profile tiers and a project-specific custom profile, to help you find the right spot between “it runs” and “nothing goes wrong.”

Three warnings up front. First, profiles and the old sandbox_mode can’t be mixed. If both are present, the old setting overrides the profile, so your rules might as well not exist. Second, if the three built-in tiers cover your needs, don’t write your own—and don’t use the full-access tier for everyday development. Third, a custom profile only needs to get three things right: the workspace root, .env set to deny, and only the necessary domains allowed on the network. Also remember: if the network proxy toggle isn’t on, domain rules won’t take effect.

What you’ll get: After reading this, you’ll be able to decide which built-in tier to use. When you need something custom, you’ll also be able to write a profile that only exposes your project directory, blocks reads of secret files, and connects only to the necessary API domains. Note that permission profiles are currently marked Beta in the official docs; all fields below are based on the docs for the version you’re using and aren’t a stability promise.

codex-permission-profiles-built-in-and-custom-en-image-0


Codex Permission Profile: Key Takeaways

According to OpenAI’s official documentation (currently marked Beta), permission profiles are meant to put a least-privilege boundary around the commands Codex runs on your behalf. A profile is a named policy that combines filesystem rules (what it can read and write) with network rules (where it can connect). The table below condenses the points you’ll want to remember most.

Point What it means Why it matters to you
A profile is a named policy Filesystem rules plus network rules, defined under [permissions.<name>] Use a different name for each project, so switching is clear
Three built-in profiles :read-only, :workspace, :danger-full-access Most cases don’t require writing your own
Can’t mix with legacy settings If sandbox_mode or --sandbox appears, Codex falls back to the old sandbox Avoid “I wrote a profile, but it doesn’t take effect”
Domain rules depend on the proxy network.enabled = true only means networking is allowed; it doesn’t start the proxy Prevents assuming domain-based filtering is already in place
Three essentials for API development Write only to the project root, set **/*.env to deny, and allow required domains such as api.apiyi.com You can make API calls without leaking API keys

Just How Far Does Each of Codex’s Three Built-in Profiles Open Things Up?

The boundaries of the three built-in profiles, as laid out in the official docs, break down like this. :read-only allows only read-only execution—perfect for having Codex read through the code, do some analysis, and write up a plan without touching a single file. :workspace lets it write to the workspace root directory and the system temp directory, and this is the level you’ll reach for most often when changing code day to day. :danger-full-access removes the local sandbox restrictions entirely—and the official wording is clear that you should only use it when you genuinely need that much openness.

There’s one documentation discrepancy worth being upfront about. The developers.openai.com/codex/config-basic page names the third built-in profile :danger-no-sandbox, while the permissions page and config-sample call it :danger-full-access. It’s the same thing under two different names in two different places, so don’t just copy one name and assume it’s in effect. Go by the docs that match your local Codex version, and confirm the actual behavior after you write it in.

codex-permission-profiles-built-in-and-custom-en-image-1

Built-in profile Filesystem Network & sandbox Good for Not good for
:read-only Read-only execution Local sandbox active Code review, plan analysis, reading logs Needing to edit files or install dependencies
:workspace Writable workspace root directory and system temp directory Local sandbox active Everyday code changes, running tests Needing fine-grained per-domain network control
:danger-full-access No local sandbox restrictions No local sandbox restrictions One-off tasks that you clearly need it for, running in an isolated environment Everyday development, machines holding keys
Custom profile Per workspace_roots and filesystem rules Per network and domains rules Running scripts that call APIs, multi-repo development Too much hassle, don’t want to maintain the config

The selection logic is simple: if you’re only reading and not changing anything, use :read-only; if you’re changing code inside a single repo, use :workspace. It’s only worth writing your own profile when you need a combination like “writing to multiple repos, hitting external APIs over the network, and keeping .env from being read.” Don’t run your everyday tasks on the fully-open profile—all it saves you is a handful of confirmations, while the risk it brings is hard to undo.


Why Codex profile and sandbox_mode can’t be mixed

This is the easiest trap to fall into. The official docs state plainly that permission profiles aren’t combined with legacy sandbox settings. You have to choose one: either configure default_permissions plus [permissions], or configure sandbox_mode and sandbox_workspace_write. Don’t write both.

More importantly, the trigger conditions are broader than you’d expect. Codex will use legacy sandbox settings instead of default_permissions if any one of the following is true:

  • Any loaded config file contains sandbox_mode.
  • The --sandbox flag is passed when launching from the command line.
  • The currently selected config profile sets sandbox_mode.
Your configuration state What Codex actually uses What to do
Only default_permissions and [permissions] permission profile Leave it as is
sandbox_mode is also present Legacy sandbox settings Remove all sandbox_mode entries
The startup command includes --sandbox Legacy sandbox settings Drop that flag; check aliases and scripts
The selected config profile contains sandbox_mode Legacy sandbox settings Clean up that profile file
Admin-issued allowed_permission_profiles permission profile (the exception documented by the official docs) Follow your enterprise policy

There’s also a compatibility detail to keep in mind during an enterprise mixed-version rollout. The official recommendation is that until all clients are upgraded to Codex 0.138.0 or later, you can keep allowed_sandbox_modes as a compatibility constraint. Individual developers usually don’t run into this, but teams distributing configuration centrally should pay attention to versions.

You also need to distinguish between two things both called “profile.” In the old style, a config-file profile is a separate TOML file per profile. For example, ~/.codex/full_auto.config.toml might contain approval_policy = "on-request" and sandbox_mode = "workspace-write", and you select it with codex --profile <name>. That style carries sandbox_mode by definition, so once the profile is selected, it overrides your permission profile.

codex-permission-profiles-built-in-and-custom-en-image-2

Codex API Development Profile Quick Start

Using the “API development” scenario as an example, here’s a profile structure you can copy directly. Following the conventions in this article, the configuration isn’t shown in a code block; instead, the field names, values, and locations are spelled out one by one. You can write them in config.toml in order. For how table names are nested, follow the examples in the documentation for the version you’re using.

Step 1: Set default_permissions at the top level

At the top level of config.toml (not under any table), write the line default_permissions = "api-dev". Here, api-dev is a custom profile name you define; you can also use a built-in profile name, such as ":workspace". At the same time, remove every sandbox_mode from the entire configuration setup, and check whether the startup command includes --sandbox.

Step 2: Use workspace_roots to list only project root directories

Under [permissions.api-dev.workspace_roots], list the project root directories you’ll allow Codex to treat as workspaces — for example, one entry for the billing service repo and one for the gateway SDK repo. The principle is simple: only list the projects you actually intend to modify this time. Don’t dump your entire home directory or your whole code directory in there. When you’re working across multiple repos, this is the most useful setting of all — Codex can move back and forth between a handful of repos but can’t step outside that boundary.

Step 3: Tighten read/write in filesystem, and block .env

Under [permissions.api-dev.filesystem], write your filesystem rules. The values the official docs commonly use are:

  1. ":minimal" = "read": the minimal system scope is read-only, ensuring commands can still run normally;
  2. Write "." = "write" under ":workspace_roots": makes the workspace root writable;
  3. At the same location, write ".devcontainer" = "read": the dev container config is read-only, keeping it from being broken by accident;
  4. At the same location, write "**/*.env" = "deny": all .env files at every level are blocked from access — this is the key line for protecting your API key.

Step 4: Only allow the necessary domains in network

Under [permissions.api-dev.network], write enabled = true, then add "api.apiyi.com" = "allow" to its domains rules. If your tests also need to reach package repositories or internal services, list each one precisely. The official matching rules are: exact hostnames; *.example.com matches subdomains; **.example.com also covers the top-level domain itself; and * can only be used for the global wildcard in allow. When there are no allow entries at all, every domain request gets denied, and deny takes priority over allow.

Step 5: Enable features.network_proxy

This is the step people most often forget. Under the [features] table in config.toml, write network_proxy = true. The official docs are clear about it: network.enabled = true only means commands are allowed to access the network; it does not start the network proxy on its own. Without a proxy, domain rules don’t restrict direct connections. Enterprise environments can also switch to the admin-issued [experimental_network].

Field Location Example value Purpose
default_permissions Top level of config.toml "api-dev" Selects this profile
workspace_roots [permissions.api-dev.workspace_roots] List the project root directories Limits the project scope that can be written to
":minimal" [permissions.api-dev.filesystem] "read" System minimal scope, read-only
"**/*.env" Under ":workspace_roots" in filesystem "deny" Blocks reading of secret files
enabled [permissions.api-dev.network] true Allows network access
domains Under network "api.apiyi.com" = "allow" Only allows the gateway domain
network_proxy [features] true Makes domain rules actually take effect

Once you’ve written everything, it’s worth doing two checks: have Codex try to read a .env file under the profile and confirm it’s rejected; then have it request a domain that isn’t allowed and confirm it’s blocked. If that second request actually succeeds, it’s almost certainly because network_proxy isn’t enabled, or a stray sandbox_mode is still lingering somewhere.

Connecting Model Requests to APIYI

Codex’s model requests use the Responses protocol. When setting up a custom provider, point base_url to https://api.apiyi.com/v1 and enter your APIYI key — that same key lets you switch between different models. This is separate from the profile discussed above: the provider decides where model requests are sent, while the profile decides what commands Codex can touch on your behalf. If your test scripts also need to call this gateway, you must allow the corresponding domain in domains.

Model ID Input Output Cache Read Protocol Support Available Platform
gpt-6.2-sol 2 10 0.1 Responses usable with Codex APIYI apiyi.com
gpt-6.1-terra 1 5 0.05 Responses usable with Codex APIYI
claude-opus-5-5 4 20 0.2 Chat and Messages only APIYI

Prices are in USD per million tokens, data as of 2026-11-22 09:58 (UTC+8), subject to the platform’s live page. When choosing a model, consider this: gpt-6.1-terra costs about half of gpt-6.2-sol, making it great for lots of repetitive scaffolding and test fixes; switch to gpt-6.2-sol for complex refactoring. claude-opus-5-5 currently only supports chat and messages, so it can’t serve as a Codex Responses provider directly — it’s better suited for your own scripts or other clients.

🚀 Quick start tip: First run a small task under :workspace with gpt-6.1-terra, then switch to the custom api-dev profile to verify .env and domain blocking. APIYI apiyi.com offers free trial credits for new users — with a single key you can compare costs and results across models without opening a separate account for each.

codex-permission-profiles-built-in-and-custom-en-image-3


Codex Permission Profile FAQ

Q1: What exactly is a Codex permission profile?

It’s a named least-privilege policy that combines filesystem rules and network rules to constrain the commands Codex runs on your behalf. You define it under `[permissions.]` and then select it with the top-level `default_permissions`. The official docs currently mark this feature as Beta.

Q2: How is a permission profile different from the old sandbox_mode, and can I use them together?

No, you can’t use both. `sandbox_mode` only lets you pick a preset mode, whereas a profile can get as granular as directories, file modes, and domains. If `sandbox_mode` shows up anywhere in your config, the command line includes `–sandbox`, or the selected profile sets `sandbox_mode`, Codex falls back to the legacy sandbox and your profile won’t take effect.

Q3: Is the third built-in tier called danger-full-access or danger-no-sandbox?

The official docs are inconsistent in two places: the permissions page and config-sample say `:danger-full-access`, while the config-basic page says `:danger-no-sandbox`. Go with the documentation for your local version and actually verify the behavior. At the end of the day, this tier isn’t recommended for everyday development anyway.

Q4: I turned on network.enabled and added domains, so why can domains I haven’t allowed still be reached?

Because `network.enabled = true` doesn’t spin up the network proxy. Per the official docs, you need to set `features.network_proxy = true` in `config.toml`, or use the admin-managed `[experimental_network]`, for the domain rules to actually block requests. Without a proxy, direct connections are unrestricted.

Q5: In an API development setup where Codex calls a gateway, what’s the minimum I need to allow in the profile?

At the very least, allow the API domains you actually call. If your test scripts hit the APIYI apiyi.com endpoints, set `api.apiyi.com` to allow in `domains`, and keep `”**/*.env” = “deny”` so keys get injected via the environment instead of living in repo files. Then narrow `workspace_roots` down to the project you’re changing this time.

Q6: How does Codex switch between different models through APIYI?

Create your own provider, point `base_url` at the gateway address, and fill in your APIYI key, then switch between `gpt-6.2-sol` or `gpt-6.1-terra` depending on the task. Note that Codex uses the Responses protocol, and `claude-opus-5-5` currently only offers chat and messages. You can start by using the free credits at APIYI apiyi.com to compare how a few models perform on your project, then decide which one to use by default.

Q7: Once I’ve written the profile, am I completely safe?

No. A profile only narrows the range of things a command can touch — it can’t replace code review, key rotation, or approval policies. Its rules also depend on whether you wrote them accurately; forget to enable the proxy, for instance, and the domain rules are essentially useless. On top of that, the feature itself is still in Beta, so you’ll need to re-verify after upgrades.

Q8: Do I still need to configure approval_policy, and what values are available?

Approval policy and permission boundaries are two separate things, and they can coexist. Per the official docs, `approval_policy` accepts `on-request`, `never`, or a granular object containing `sandbox_approval`, `rules`, `mcp_elicitations`, `request_permissions`, and `skill_approval`. `untrusted` is no longer supported and `on-failure` is deprecated, so update any old configs that still use those two values.


Codex Permission Profiles: Key Takeaways

  • A profile is a named policy: filesystem rules plus network rules, selected via default_permissions.
  • Don’t mix it with legacy settings: if sandbox_mode or --sandbox appears anywhere, it overrides the profile.
  • Prefer the built-in presets: use :read-only for read-only work, :workspace to modify a single repo, and don’t run the fully-open preset for everyday tasks.
  • Names depend on the version: the third preset shows up as :danger-full-access or :danger-no-sandbox in different docs.
  • Three things when customizing: list only the project root, set **/*.env to deny, and allow only the required domains on the network.
  • No proxy, no blocking: domain rules only take effect when paired with features.network_proxy = true.
  • Model access is configured separately: point the provider at the gateway address, allow the matching domain in the profile too, and set up the two layers independently.

Summary: Narrow Codex Permissions Per Project, Not One-Size-Fits-All

The core points of Codex permission profiles:

  1. Know the three built-in presets first: :read-only or :workspace covers most scenarios; the third preset has inconsistent names across docs and isn’t suited to daily use.
  2. Then make sure the config is clean: pick either a profile or sandbox_mode, not both — leftover legacy settings will silently disable the profile.
  3. Finally, write profiles per project: list projects in workspace_roots, block .env in filesystem, allow only required domains in network, and turn on features.network_proxy.

There’s no set-and-forget configuration for permissions. Every time you add a new project, switch to a new gateway, or upgrade Codex, it’s worth spending two minutes re-verifying that .env blocking and domain blocking still work. When you need to compare cost and quality across different models in Codex, you can connect through APIYI apiyi.com using the same key, then add the corresponding domain to your api-dev profile.


📚 References

  1. OpenAI Codex Documentation – Permissions (Beta): permission profile definitions, built-in profiles, relationship with the legacy sandbox, network and domain rules

    • Link: developers.openai.com/codex/permissions
    • Note: This is the primary source for the field and behavior descriptions in this article; Beta content may change between versions
  2. OpenAI Codex Documentation – Config basics: configuration basics and built-in profile naming

    • Link: developers.openai.com/codex/config-basic
    • Note: The third built-in profile on this page is written as :danger-no-sandbox, which differs from the permissions page. Check against your local version before use.

Author: APIYI Technical Team
Technical Discussion: If you run into trouble configuring a Codex provider or troubleshooting permission issues, feel free to reach out to us through the official APIYI website.

Leave a Comment