npm Publish API
The Publish API from npm — 1 operation(s) for publish.
Operations 1
Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay
The Publish API from npm — 1 operation(s) for publish.
Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/npm:npm-publish-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: npm Registry Publish API
version: 1.0.0
license:
name: MIT
url: https://opensource.org/licenses/MIT
description: Welcome to the npm registry API documentation!
x-logo:
url: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAACyCAYAAAC0oD1PAAAAAXNSR0IArs4c6QAAAJZlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgExAAIAAAARAAAAWodpAAQAAAABAAAAbAAAAAAAAABIAAAAAQAAAEgAAAABQWRvYmUgSW1hZ2VSZWFkeQAAAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAfSgAwAEAAAAAQAAALIAAAAA7l/aDAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAi1pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6e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AAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECByYwP8ABJX2MCfo+K4AAAAASUVORK5CYII=
'
altText: npm logo
servers:
- url: https://registry.npmjs.org
tags:
- name: Publish
paths:
/{escapedPackageName}:
parameters:
- $ref: '#/components/parameters/EscapedPackageName'
- $ref: '#/components/parameters/RequiredBearerToken'
put:
tags:
- Publish
summary: Publish a new version of a package
description: 'Publish a new package version directly to the registry.
Stage-only Granular Access Tokens cannot publish new versions through this
endpoint, even with `bypass_2fa: true`. Requests rejected by the publish-policy
check return `403 Forbidden` with `E_STAGE_REQUIRED` in the error message.
Earlier authentication or package authorization checks can return other errors,
including `404 Not Found`. Rejected requests are not automatically redirected
to staging. Use `POST /-/stage/package/{package-name}`
(`npm stage publish`), followed by maintainer approval with 2FA.
The stage-only policy restricts new-version publication. Existing authorization
and 2FA requirements still apply.'
operationId: publish
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
_id:
type: string
example: npm@2.0.0
description: The name and version of the package being published
name:
type: string
example: npm
description: The name of the package being published
description:
type: string
example: a package manager for JavaScript
description: The description of the package being published
dist-tags:
type: object
description: dist-tag to apply for this new version
additionalProperties:
type: string
format: semver
description: version for this tag, must be the version being uploaded
example:
latest: 2.0.0
dist:
type: object
properties:
integrity:
type: string
format: sha512
description: sha512 integrity string for this version's tarball
example: sha512-0p99G5Mu9FC3ixLarvgfU0O8xoc386LBll2UixE8rbSJrKRFoXbJFbGSOBN9exJiFXryiLDFFhCKjOOBxQ/dsQ==
shasum:
type: string
format: sha1
description: sha1 hex digest for this version's tarball
example: f783874393588901af1a4824a145fa009f174d9d
tarball:
type: string
format: url
description: url for the tarball will live. This is overwritten by the registry.
example: https://registry.npmjs.org/npm/-/npm-2.0.0.tgz
versions:
description: manifest (package.json) of the package to be published, indexed by the version being published
additionalProperties:
type: object
properties:
name:
type: string
description: package name
version:
type: string
format: semver
description: version of the package being published
additionalProperties:
oneOf:
- type: string
- type: object
- type: array
description: other package.json content
example:
2.0.0:
name: npm
version: 2.0.0
description: A package manager for node
access:
type: string
example: public
enum:
- public
- restricted
description: Access level for this package. Whether it is public or not.
_attachments:
type: object
description: Tarball and provenance attestation attachments
additionalProperties:
anyOf:
- type: object
properties:
content_type:
type: string
description: tarball content type
enum:
- application/octet-stream
data:
type: string
format: base64
description: base64 content of the tarball for this version
length:
type: integer
description: length of the tarball data string
- type: object
properties:
content_type:
type: string
description: sigstore content type
data:
type: string
format: base64
description: base64 content of the provenance attestation for this version
length:
type: integer
description: length of the provenance data string
example:
npm-2.0.0.tgz:
content_type: application/octet-stream
data: ZXhhbXBsZQo=
length: 13
npm-2.0.0.sigstore:
content_type: application/vnd.dev.sigstore.bundle+json;version=0.2
data: ZXhhbXBsZQo=
length: 13
security:
- npmAccessToken: []
- npmSessionToken: []
- granularAccessToken: []
- oidcIdToken: []
responses:
'200':
$ref: '#/components/responses/PublishSuccess'
'401':
$ref: '#/components/responses/responses-Unauthorized'
components:
responses:
PublishSuccess:
description: Successful Publish
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
enum:
- true
responses-Unauthorized:
description: Unauthorized
headers:
www-authenticate:
description: Authentication challenge (e.g., "OTP" when OTP is required)
schema:
type: string
npm-notice:
description: Additional notice information
schema:
type: string
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error message
example:
error: Missing "Bearer" header.
parameters:
EscapedPackageName:
name: escapedPackageName
in: path
required: true
schema:
type: string
description: The name of a package. Scoped packages need "/" to be url encoded to "%2F"
example: '@npmcli%2Farborist'
RequiredBearerToken:
name: Authorization
in: header
required: true
schema:
type: string
pattern: ^Bearer .+
description: 'Bearer token for authentication. Must be an npm access token.
**Format:** `Bearer <token>`
**Accepted token types:**
- npm access token (traditional user token created via `npm login`)
'
securitySchemes:
oidcIdToken:
type: http
scheme: bearer
bearerFormat: JWT
description: 'OIDC id_token from a supported Identity Provider (IdP) such as GitHub Actions, GitLab CI, or CircleCI.
The `aud` (audience) claim must be set to `npm:registry.npmjs.org`.
**Supported Identity Providers:**
- GitHub Actions
- GitLab CI
- CircleCI
'
npmSessionToken:
type: http
scheme: bearer
description: 'Traditional npm session token created via `npm login`.
These tokens are tied to a user account and inherit the user''s permissions.
'
npmAccessToken:
type: http
scheme: bearer
description: 'Granular Access Token (GAT) with fine-grained permissions.
These tokens can be scoped to specific packages and operations.
GATs created with `bypass_2fa: true` cannot perform account,
token, or org/team/package governance write operations — those
requests are rejected with `403 Forbidden`. See the Authentication
section above for the full list.
'
granularAccessToken:
type: http
scheme: bearer
description: 'Granular Access Token (GAT) with fine-grained permissions.
These tokens can be scoped to specific packages and operations.
(Alias for npmAccessToken)
GATs created with `bypass_2fa: true` cannot perform account,
token, or org/team/package governance write operations — those
requests are rejected with `403 Forbidden`.
'
oidcExchangeToken:
type: http
scheme: bearer
description: 'Short-lived npm registry token obtained by exchanging an OIDC id_token
via the `/oidc/token/exchange` endpoint. These tokens are package-scoped
and have limited lifetime (typically 1 hour).
'
x-tagGroups:
- name: Introduction
tags:
- Introduction
- name: Authentication & Authorization
tags:
- Authentication
- name: Sections
tags:
- Access
- Audit
- OIDC
- Org
- Packages
- Publish
- Search
- Stage
- Team
- Tokens
- Trust