---
title: "Create a company registry secret"
url: https://docs.corefinity.com/api/reference/deployments/create-company-deploy-secret
type: endpoint
last_updated: 2026-11-13
feature: deployment-templates
related:
  - https://docs.corefinity.com/guides/sites/code-and-deployments/deployment-templates.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_company_secret_set.md
---
# Create a company registry secret

Saves the credential for one private registry and answers the whole list. A registry must resolve to public
addresses, and a company holds one credential for each registry and scope.

```http
POST /api/corestack/companies/{company}/deploy-secrets
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 10 a minute
- Try it in the console: off. It has not been cleared for the console. Copy the request and run it yourself when you are sure.

## Path parameters

- `company` (integer, required): The id of a company you belong to or manage. Digits only.

## Body

- `auth_type` (string): For Composer, how the registry signs in. Required when `kind` is `composer`. One of `http-basic`, `bearer`, `github-oauth`, `gitlab-token`.
- `kind` (string, required) One of `npm`, `composer`.
- `label` (string, required)
- `registry` (string, required): For npm, the registry's HTTPS URL. For Composer, its host name, with a port if it needs one.
- `scope` (string): For npm only, the scope the credential is for, such as `@example`: `@`, then letters, digits, dots, hyphens and underscores, starting with a letter or digit. Leave out for the default registry.
- `shared_with_managed` (boolean): For an agency only, also give the credential to the sites it manages for its clients.
- `token` (string, required): The token or password, kept exactly as sent. No line breaks or control characters; an npm token may not contain `${`.
- `username` (string): For Composer with `http-basic`, the username, which is then required. No line breaks or control characters.
- `verify` (boolean): Ask the registry once, after the save, whether it accepts the credential.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/companies/1204/deploy-secrets \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "auth_type": "http-basic",
    "kind": "composer",
    "label": "Private packages",
    "registry": "packages.example.com",
    "token": "your-registry-token",
    "username": "your-username"
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/companies/1204/deploy-secrets', [
        'auth_type' => 'http-basic',
        'kind' => 'composer',
        'label' => 'Private packages',
        'registry' => 'packages.example.com',
        'token' => 'your-registry-token',
        'username' => 'your-username',
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/companies/1204/deploy-secrets', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    auth_type: 'http-basic',
    kind: 'composer',
    label: 'Private packages',
    registry: 'packages.example.com',
    token: 'your-registry-token',
    username: 'your-username',
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/companies/1204/deploy-secrets",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "auth_type": "http-basic",
        "kind": "composer",
        "label": "Private packages",
        "registry": "packages.example.com",
        "token": "your-registry-token",
        "username": "your-username",
    },
)

data = res.json() if res.content else None
```

## Responses

### 201 The company's registry secrets, with the new one.

```json
{
  "can_share": true,
  "data": [
    {
      "auth_type": "bearer",
      "id": 318,
      "kind": "composer",
      "label": "Private packages",
      "last4": "oken",
      "last_used_at": null,
      "registry": "repo.example.com",
      "scope": "",
      "shared_with_managed": false,
      "used_by": {
        "environments": 1,
        "overridden_on": 0
      },
      "verified_at": "2026-11-09T10:42:07Z"
    }
  ],
  "verification": {
    "id": 318,
    "message": "The registry accepted these credentials.",
    "verified": true,
    "verified_at": "2026-11-09T10:42:07Z"
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use: `write`, or `exec` for a reveal and for a change that brings a new command), your company requires two-factor authentication and you have not set it up, or your role lacks the Edit Environment Deployment Pipeline permission (`forbidden`, with `permission`).

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 The company already has a credential for this registry and scope (`exists`, with the saved one's `id`). Change that one instead.

```json
{
  "code": "exists",
  "id": 318,
  "message": "A registry for this host is already saved. Edit it instead.",
  "reason": "exists"
}
```

### 422 The request was refused and nothing was saved. `errors` names the field. - `secret_invalid`: a value the rules refuse (the label, the registry, the scope, the sign-in type, the username for `http-basic`, the token), or a registry whose address is not public or does not resolve. - `too_many_secrets`: the company holds as many registry secrets as it can. - `invalid`: a field of the wrong type or one this endpoint does not take (the token is `token`), a `scope` longer than 214 characters, or a change that names nothing to change and no `verify` true (on `secret_id`).

```json
{
  "code": "secret_invalid",
  "errors": {
    "auth_type": [
      "Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token."
    ]
  },
  "message": "Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token.",
  "reason": "secret_invalid"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `exists` | It already exists. Use the existing one. |
| 422 | `secret_invalid` | Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `too_many_secrets` | This company already has the most registry secrets it can hold. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Deployment templates](https://docs.corefinity.com/guides/sites/code-and-deployments/deployment-templates.md)
- MCP tool: [`corestack_deployments_company_secret_set`](https://docs.corefinity.com/mcp/tools/corestack_deployments_company_secret_set.md)
