---
title: "createSelfHostEnrollment"
description: "Issue a self-host enrollment token"
canonical: "https://pgbeam.com/docs/ts-sdk/platform/createSelfHostEnrollment"
last-updated: "2026-10-15T11:54:41.000Z"
---

# createSelfHostEnrollment

> Issue a self-host enrollment token

URL: https://pgbeam.com/docs/ts-sdk/platform/createSelfHostEnrollment

{/* Auto-generated from OpenAPI. Do not edit. Run `pnpm generate:sdk-docs` to regenerate. */}

Issues an enrollment token a self-hosted (BYOC) proxy uses to authenticate to the control plane's config/audit gRPC stream. The token is returned once and cannot be retrieved again. Requires the Scale or enterprise plan. Returns 409 while any project in the organization has an enabled approval rule, because PgBeam cannot yet confirm that a self-hosted proxy runs a build that enforces approval rules. Disable those rules first; they can be saved with enabled set to false.

## Usage

```typescript
const result = await api.platform.createSelfHostEnrollment({
    pathParams: { org_id: "org_abc123" },
    body: {
      ,
    },
  });
```

## Parameters

| Parameter         | Type     | Required | Description                                                                                                                                                                       |
| ----------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pathParams.org_id | `string` | Yes      | Unique organization identifier.                                                                                                                                                   |
| body.region_label | `string` | No       | Operator-supplied label for where the proxy runs.                                                                                                                                 |
| body.description  | `string` | No       | Optional human-readable note.                                                                                                                                                     |
| body.expires_at   | `string` | No       | Optional expiry. When set, the enrollment token stops authenticating new proxy connections at this time (must be in the future). Omit or set null for a token that never expires. |

## Response

`Promise<SelfHostEnrollmentSecret>`: enrollment created. token shown once.

## Example

```typescript
import { PgBeamClient } from "pgbeam";

const client = new PgBeamClient({
  token: "pbu_...",
  baseUrl: "https://api.pgbeam.com",
});

const result = await client.api.platform.createSelfHostEnrollment({
  pathParams: { org_id: "org_abc123" },
  body: {
      ,
    },
});
```

## Errors

| Status | Description                                                                                                                                                                                                                                                                                                                           |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | The request was rejected. `code` is `INVALID_INPUT`, and `errors` names the offending fields when the failure was a validation one.                                                                                                                                                                                                   |
| 401    | Missing or invalid authentication. `code` is `UNAUTHORIZED`.                                                                                                                                                                                                                                                                          |
| 403    | The organization's plan is not entitled to self-host.                                                                                                                                                                                                                                                                                 |
| 409    | The request conflicts with the current state. `code` distinguishes the cases: `RESOURCE_EXISTS` for a name or value already in use, `INVALID_STATE` for a resource that is no longer in a state that allows the operation, and `IDEMPOTENCY_KEY_REUSED` for a retry whose body does not match the request the key was first used for. |
| 413    | The request body exceeds the 2 MB limit. `code` is `PAYLOAD_TOO_LARGE`.                                                                                                                                                                                                                                                               |
| 415    | The request body is not JSON, or carries a body without declaring a Content-Type. `code` is `UNSUPPORTED_MEDIA_TYPE`.                                                                                                                                                                                                                 |
| 429    | Rate limited. `code` is `RATE_LIMITED`.                                                                                                                                                                                                                                                                                               |
| 500    | The request failed for a reason on our side. `code` is `INTERNAL_ERROR`. Quote `request_id` when reporting it.                                                                                                                                                                                                                        |