Download OpenAPI specification:
Welcome to the npm registry API documentation!
This is the API documentation for the npm registry. For information about the npm registry, website, and command-line interface (CLI), please refer to https://docs.npmjs.com.
The npm registry API supports multiple types of bearer tokens for authentication:
Token Types:
1. npm Session Token (npmSessionToken)
Traditional npm session tokens created via npm login. These tokens:
2. npm Access Token (npmAccessToken)
Fine-grained tokens with specific permissions:
3. OIDC id_token (oidcIdToken)
Tokens from supported Identity Providers (CI/CD systems):
aud claim set to npm:registry.npmjs.org4. OIDC Exchange Token (oidcExchangeToken)
Short-lived tokens obtained from OIDC token exchange:
Endpoint Authorization:
Each endpoint specifies which token types are accepted via security schemes. Some endpoints may accept multiple token types, others are restricted to specific types.
Example:
/tokens endpoint: Only accepts npmSessionToken/oidc/token/exchange endpoint: Only accepts oidcIdTokennpmSessionToken, npmAccessToken, or oidcExchangeTokenCreate a new npm access token with customizable permissions, scope restrictions, expiration, and CIDR IP range limitations.
Requirements:
npm-otp headernpm-otp headerdoneUrl after authenticationImportant notices:
npm-notice header regarding token limitations| Authorization required | string^Bearer .+ Bearer token for authentication. Must be an npm access token. Format: Accepted token types:
|
| npm-otp required | string One-time password for two-factor authentication. Always required for this endpoint. How to obtain the OTP:
|
| npm-auth-type | string Value: "web" Authentication type for web-based flow. When set to "web", enables browser-based authentication flow for WebAuthn users. |
| npm-command | string Value: "token" Command context for the request. When set to "token", indicates this is a token creation command. |
| password required | string User password for authentication |
| name required | string Human-readable name for the token |
| token_description | string or null Detailed description of token purpose |
number or string Expiration in days (number) or ISO date string. Read-write tokens: maximum 90 days, defaults to 7 days. Read-only tokens: unlimited maximum, defaults to 30 days | |
| bypass_2fa | boolean Default: false Allow token to bypass 2FA requirements |
| cidr | Array of strings or null IP ranges that can use this token |
| packages | Array of strings Specific packages this token can access. Use ["*"] for all packages. Empty arrays are treated as not provided |
| scopes | Array of strings Scoped packages this token can access. Empty arrays are treated as not provided |
| orgs | Array of strings Organizations this token can access. Empty arrays are treated as not provided |
| packages_and_scopes_permission | string Enum: "read-only" "read-write" "no-access" Permission for packages and scopes. Defaults to "read-only" if packages/scopes arrays have length > 0, otherwise "no-access" |
| orgs_permission | string Enum: "read-only" "read-write" "no-access" Permission for organizations. Defaults to "read-only" if orgs array has length > 0, otherwise "no-access" |
{- "password": "string",
- "name": "string",
- "token_description": "string",
- "expires": 0,
- "bypass_2fa": false,
- "cidr": [
- "string"
], - "packages": [
- "string"
], - "scopes": [
- "string"
], - "orgs": [
- "string"
], - "packages_and_scopes_permission": "read-only",
- "orgs_permission": "read-only"
}{- "key": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
- "name": "string",
- "description": "string",
- "token": "npm_aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890",
- "expiry": "2019-08-24T14:15:22Z",
- "cidr": [
- "string"
], - "bypass_2fa": true,
- "revoked": "2019-08-24T14:15:22Z",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "accessed": "2019-08-24T14:15:22Z",
- "permissions": [
- {
- "name": "string",
- "action": "string"
}
], - "scopes": [
- {
- "type": "string",
- "name": "string"
}
]
}List all access tokens associated with the authenticated user's account.
Requirements:
Response includes:
npm-notice headernpm_aBcD...7890 (first 8 chars including prefix + ... + last 4 chars)| page | integer Default: 0 Page number for pagination (0-indexed) |
| perPage | integer Default: 10 Number of tokens to return per page |
| Authorization required | string^Bearer .+ Bearer token for authentication. Must be an npm access token. Format: |
{- "objects": [
- {
- "name": "string",
- "description": "string",
- "expiry": "string",
- "key": "string",
- "token": "npm_aBcD...7890",
- "readonly": true,
- "bypass_2fa": true,
- "cidr": [
- "string"
], - "revoked": "2019-08-24T14:15:22Z",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "accessed": "2019-08-24T14:15:22Z",
- "permissions": [
- {
- "name": "string",
- "action": "string"
}
], - "scopes": [
- {
- "type": "string",
- "name": "string"
}
]
}
], - "total": 0,
- "urls": {
- "property1": "string",
- "property2": "string"
}
}Delete an npm access token. The token can be specified as:
npm_ followed by 36 alphanumeric characters)Requirements:
Web authentication flow:
npm-auth-type=web and npm-command=token headers are present and 2FA is required,
returns authentication URLs instead of an error| token required | string The token identifier to delete. Can be:
|
| Authorization required | string^Bearer .+ Bearer token for authentication. Must be an npm access token. Format: |
| npm-otp | string One-time password for two-factor authentication. Required if the user has 2FA enabled. |
| npm-auth-type | string Value: "web" Authentication type for web-based flow. When set to "web", enables browser-based authentication flow for WebAuthn users. |
| npm-command | string Value: "token" Command context for the request. When set to "token", indicates this is a token deletion command. |
{- "message": "invalid token"
}Exchange a valid OIDC id_token (provided as a Bearer token) for a short-lived npm registry access token for the specified package.
OIDC Token Requirements:
aud (audience) claim must be set to npm:registry.npmjs.orgImportant: The Bearer token must be an OIDC id_token from an Identity Provider (IdP) npm supports. This endpoint differs from the rest of the API, which expects a standard npm access token.
| package_name required | string Name of the npm package, url-encoded |
{- "token_type": "oidc",
- "token": "string",
- "created": "2025-07-18T10:30:00.000Z",
- "expires": "2025-07-18T11:30:00.000Z"
}