---
title: "createOrgNpmToken"
---

> Documentation Index
> Fetch the complete documentation index at: https://buildrforge.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# createOrgNpmToken

Path: Forge API › registry

`POST /orgs/{org_id}/npm-tokens`

Create a token that npm sends to read the org's packages and @buildr/sdk from the registry, and nothing else, as you, for 24 hours. Write it into .npmrc beside the registry it reads: @buildr-custom:registry=<registry>, @buildr:registry=<registry>, and //<registry without its scheme>:_authToken=<token>. Ask for another once it expires. Extension code can't create one.

## Path parameters

- `org_id` (`createOrgNpmToken.path.org_id`; string, required)
  - pattern: `^org_[0-7][0-9a-hjkmnp-tv-z]{25}$`

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/orgs/<org_id>/npm-tokens'
```

### TypeScript

```typescript
const url = '<base-url>/orgs/<org_id>/npm-tokens';
const options = {method: 'POST'};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/orgs/<org_id>/npm-tokens"

response = requests.post(url)

print(response.text)
```

## Responses

### 201

NpmToken

#### Example

```json
{
  "token": "string",
  "registry": "string",
  "expires_at": "string"
}
```

- `token` (`createOrgNpmToken.response.201.token`; string, required)
- `registry` (`createOrgNpmToken.response.201.registry`; string, required)
- `expires_at` (`createOrgNpmToken.response.201.expires_at`; string, required)

### 400

InvalidRequest

#### Example

```json
{
  "_tag": "InvalidRequest",
  "part": "path",
  "issues": [
    {
      "path": [
        "string"
      ],
      "message": "string"
    }
  ]
}
```

- `_tag` (`createOrgNpmToken.response.400._tag`; string, required)
  - one of `"InvalidRequest"`
- `part` (`createOrgNpmToken.response.400.part`; string, required)
  - one of `"path"`, `"query"`, `"headers"`, `"body"`
- `issues` (`createOrgNpmToken.response.400.issues`; array of object, required)
  - `path` (`createOrgNpmToken.response.400.issues.path`; array\<any of\>, required)
    - any of the following: `string`, `integer`
  - `message` (`createOrgNpmToken.response.400.issues.message`; string, required)

### 401

InvalidCredentials

#### Example

```json
{
  "_tag": "InvalidCredentials"
}
```

- `_tag` (`createOrgNpmToken.response.401._tag`; string, required)
  - one of `"InvalidCredentials"`

### 403

ForbiddenOrigin | RequiresPersonalSession | RunBranchRequired

#### Example

```json
{
  "_tag": "ForbiddenOrigin"
}
```

Any of the following:

- `ForbiddenOriginEncoded`
  - `_tag` (`ForbiddenOriginEncoded._tag`; string, required)
    - one of `"ForbiddenOrigin"`
- `RequiresPersonalSessionEncoded`
  - `_tag` (`RequiresPersonalSessionEncoded._tag`; string, required)
    - one of `"RequiresPersonalSession"`
- `RunBranchRequiredEncoded`
  - `_tag` (`RunBranchRequiredEncoded._tag`; string, required)
    - one of `"RunBranchRequired"`
  - `branch` (`RunBranchRequiredEncoded.branch`; string, required)
    - minLength: `1`
  - `message` (`RunBranchRequiredEncoded.message`; string, required)

### 404

OrgNotFound

#### Example

```json
{
  "_tag": "OrgNotFound"
}
```

- `_tag` (`createOrgNpmToken.response.404._tag`; string, required)
  - one of `"OrgNotFound"`

### 429

RateLimited

#### Example

```json
{
  "_tag": "RateLimited"
}
```

- `_tag` (`createOrgNpmToken.response.429._tag`; string, required)
  - one of `"RateLimited"`

### 500

OrgFailure

#### Example

```json
{
  "_tag": "OrgFailure",
  "reason": "string"
}
```

- `_tag` (`createOrgNpmToken.response.500._tag`; string, required)
  - one of `"OrgFailure"`
- `reason` (`createOrgNpmToken.response.500.reason`; string, required)

### 503

SessionUnavailable | RateLimitUnavailable

#### Example

```json
{
  "_tag": "SessionUnavailable"
}
```

Any of the following:

- `SessionUnavailableEncoded`
  - `_tag` (`SessionUnavailableEncoded._tag`; string, required)
    - one of `"SessionUnavailable"`
- `RateLimitUnavailableEncoded`
  - `_tag` (`RateLimitUnavailableEncoded._tag`; string, required)
    - one of `"RateLimitUnavailable"`


Source: https://buildrforge.com/docs/api/create-org-npm-token/index.md
