An admin API key lets a script manage your Main Account's API keys, their policies, and your Subaccount policies without signing in. Use it to set up many Subaccounts at once, for example when a market maker scripts account onboarding. An admin key never moves funds.
Create or promote an admin key
Only the Main Account owner can create an admin key, or turn an existing key into one, in a signed-in
session with a fresh step-up in X-Auth-Step-Up. An API key can never create, promote, change, or
delete an admin key, including itself.
- Create ·
CreateApiKey(POST /v1/auth/api-keys) withpurposeADMIN_KEY, nosubaccountId, and a non-emptyipWhitelist. - Promote or demote ·
UpdateApiKey(PATCH /v1/auth/api-keys/{key_id}) withpurposeADMIN_KEYorSTANDARD. On ConnectRPC, selectpurposeinupdateMask, plusip_whitelistwhen the key has no allowlist yet.
An admin key acts for the Main Account only: a Subaccount key or an assistant key cannot become one
(AUTH_INVALID_REQUEST), and neither can a key whose policy allows a money-out action
(AUTH_ADMIN_KEY_ACTION_NOT_ALLOWED). ListApiKeys and GetApiKey show an admin key with purpose ADMIN_KEY.
IP allowlist
The allowlist is required. List every address your scripts use, up to 32 entries. Each entry is a
single address or a range no broader than /24 (IPv4) or /48 (IPv6); IPv4-mapped IPv6 entries are
refused. An empty list, a catch-all, or a broader range is refused with AUTH_ADMIN_KEY_ALLOWLIST_INVALID.
Keys the admin key creates or edits must use allowlist entries inside its own, so add your trading hosts' addresses to it as well. Only the owner's session, with a fresh step-up, can change an admin key's allowlist. See IP allowlists.
Permissions
An admin key's rights come from its type and from three permissions in its API key policy. They are honored only on an admin key:
MANAGE_API_KEYS·CreateApiKey,UpdateApiKey, andDeleteApiKeyMANAGE_API_KEY_POLICIES·SetApiKeyPolicyMANAGE_SUBACCOUNT_POLICIES·SetSubaccountPolicyandUpdateSubaccountPolicy
An admin key can make these six calls over REST and ConnectRPC. Every other key and policy change still needs a session. See API key policies for building the policy.
What an admin key can change
- Create, update, and revoke the standard API keys of the Main Account and of the Subaccounts it owns.
- Attach or clear those keys' policies, and apply policy templates.
- Attach, clear, and update Subaccount policies.
What an admin key can never do
- Withdraw or transfer funds, or change whitelists, the address book, or auto-withdraw rules. Its
policy can never allow
EXTERNAL_WITHDRAW,INTERNAL_TRANSFER,MANAGE_ADDRESS_BOOK, orMANAGE_AUTO_WITHDRAW. - Change sign-in, MFA, wallet, or session settings.
- Create, change, or revoke an admin key, including itself.
- Reach an assistant key.
- Change a key or policy that allows a money-out action. It can revoke such a key.
- Change a locked Subaccount policy, or reach a Subaccount your Main Account does not own.
- Edit or replace the policy of a Subaccount marked
strategyBot. - Give a Subaccount key more actions or markets than its Subaccount policy allows.
Each call rechecks the admin key when it runs: its status, expiry, type, permissions, and your address against its allowlist. Revoking or demoting an admin key, or narrowing its allowlist, takes effect immediately.
Audit and notifications
Every change an admin key makes is recorded in your account activity, with the admin key and the source
address. It also creates a security notification of type ADMIN_KEY_ACTION that names the admin
key, the action, the key, Subaccount, or policy it changed, and the source address; see Notifications. If nobody on your
account made a change, revoke the admin key and review your API keys.
Script Subaccount onboarding
Build your policies once, as templates or regular policies, then repeat these steps for each Subaccount with the admin key:
Attach the Subaccount policy
Call SetSubaccountPolicy (PATCH /v1/auth/subaccounts/{subaccount_id}/policy)
with the Subaccount and its policy. Do this first: a Subaccount without a policy is read-only, and
an admin key cannot give a Subaccount key more than its Subaccount policy allows, so attaching a
trading key policy before it is refused with AUTH_ADMIN_KEY_SCOPE_EXCEEDED.
Create the Subaccount's key
Call CreateApiKey with the Subaccount's subaccountId, the new key's public key, and an ipWhitelist inside the admin key's own allowlist.
Attach the key's policy
Call SetApiKeyPolicy with the new key's keyId and the policy or template to apply.
The calls share the ACCOUNT_SECURITY rate limit:
60 units a minute with a burst of 20. Creating, updating, or revoking a key costs 5 units, and each
policy call costs 2, so pace scripted onboarding. Each change also sends a notification, about three
per Subaccount with the steps above.
Errors
Each entry gives the code and its HTTP status, then the condition and what to do. ConnectRPC returns
the same code in an auth.v1.AuthErrorDetail.
AUTH_ADMIN_KEY_REQUIRED· HTTP 403 ·permission_denied
The key that signed the request is not an admin key. Use the admin key, or a session.AUTH_ADMIN_KEY_ESCALATION_DENIED· HTTP 403 ·permission_denied
The request would create, promote, or change an admin key, or attach an admin permission, by API key. Only the owner's session with a fresh step-up can.AUTH_ADMIN_KEY_SCOPE_EXCEEDED· HTTP 403 ·permission_denied
The change would give a key an allowlist entry outside the admin key's own, or a Subaccount key more actions or markets than its Subaccount policy.AUTH_ADMIN_KEY_FORBIDDEN_TARGET· HTTP 403 ·permission_denied
The target is an assistant key, a key or policy that allows a money-out action, a locked Subaccount policy, or a Subaccount your Main Account does not own.AUTH_STRATEGY_BOT_MANAGED· HTTP 412 ·failed_precondition
The target is managed or has a retained, restricted Subaccount policy. An attached policy cannot be edited or replaced, and may be cleared only after managed access ends.AUTH_ADMIN_KEY_ALLOWLIST_INVALID· HTTP 400 ·invalid_argument
The admin key's allowlist is empty, or has an entry broader than/24or/48, or an IPv4-mapped IPv6 entry.AUTH_ADMIN_KEY_ACTION_NOT_ALLOWED· HTTP 412 ·failed_precondition
The admin key's policy would allow a money-out action, or a key with such a policy was to become an admin key.AUTH_IP_NOT_ALLOWED· HTTP 401 ·unauthenticated
The request came from an address outside the admin key's allowlist. It is refused at ingress, so REST answers with the short codeIP_NOT_ALLOWED(HTTP 401); ConnectRPC carriesAUTH_IP_NOT_ALLOWEDin theauth.v1.AuthErrorDetail.AUTH_API_KEY_ACCESS_DENIED· HTTP 403 ·permission_denied
The admin key's policy lacks the permission the call needs.