# Functions

Functions are serverless compute you deploy onto a branch, so your backend code runs next to your database. A function doesn't configure the services it uses: enable a service on the branch and its connection strings and credentials are injected into `process.env` at runtime. A function has 15 minutes to start responding and can keep streaming while data flows, which suits agents and WebSocket or SSE servers. Each branch runs its own functions at their own URLs.

The slug is assigned at first deploy and can't be changed; `name` is a display label only.

Renaming acts only on a function the branch owns. A slug that's only inherited from an ancestor returns `404`, so rename it on the owning branch.

You can also manage functions from the CLI with [`neon functions`](/docs/cli/functions).

Functions are currently available in AWS US East (Ohio), US East (N. Virginia), Europe (Frankfurt), and Asia Pacific (Singapore). Support is expanding toward [all regions](/docs/introduction/regions). See [Neon Functions](/docs/compute/functions/overview) for the deployment workflow, [Environment variables](/docs/compute/functions/environment-variables) for what gets injected, and [Runtime limits](/docs/compute/functions/reference/runtime-limits) for timeouts and concurrency.

---

> API Reference / Functions / Create a trigger

## POST /projects/{project_id}/branches/{branch_id}/triggers

Creates a trigger for a Function visible on the branch. The required
`type` discriminator selects the trigger-specific configuration. The
supported types are `schedule` and `storage_object_created`. A schedule
trigger uses a numeric five-field cron expression interpreted in UTC. A
storage-object-created trigger fires only after a successful upload to
one exact bucket and may narrow matches to an object-key prefix.

The name must be unique among triggers visible on the branch, including
inherited triggers.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID

### Request body

- `type` (string, required)
  Trigger type discriminator.
  Possible values: `schedule`
- `function_slug` (string, required)
  The branch-local Function slug to invoke.
- `name` (string, required)
  Human-readable name, unique among triggers visible on the branch.
- `function_path` (string, optional)
  Path passed to the target Function. Defaults to `/`.
  Default: `/`
- `schedule` (object, required)
  A numeric five-field cron schedule interpreted in UTC.
  - `cron` (string, required)
    Numeric five-field cron expression (minute through day-of-week), interpreted in UTC.
- `enabled` (boolean, optional)
  Whether future occurrences should be scheduled.
  Default: `true`

### Response (201)

- `trigger` (object, optional)
  A branch-effective trigger discriminated by `type`. The supported trigger
  types are `schedule` and `storage_object_created`.
  

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/triggers" \
  -X POST \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.createProjectBranchTrigger({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Delete a custom domain from a branch

## DELETE /projects/{project_id}/branches/{branch_id}/custom-domains/{domain}

Removes a custom domain registered on the branch and stops routing it.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `domain` (string, path, required)
  The registered custom domain (case-insensitive).

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/custom-domains/$DOMAIN" \
  -X DELETE \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.deleteProjectBranchCustomDomain({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    domain: process.env.DOMAIN
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Delete a function on the branch

## DELETE /projects/{project_id}/branches/{branch_id}/functions/{slug}

Deletes the function identified by its slug.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `slug` (string, path, required)
  The function slug

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/functions/$SLUG" \
  -X DELETE \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.deleteProjectBranchFunction({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    slug: process.env.SLUG
  }
});
```

```bash
# neonctl
neon functions delete <branch_id>
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Delete a trigger

## DELETE /projects/{project_id}/branches/{branch_id}/triggers/{trigger_id}

Deletes a branch-local trigger or writes a branch-local tombstone for an
inherited trigger so it does not reappear. Deletion stops future
scheduling or storage-event matching but does not cancel invocations
already committed for delivery. The supported trigger types are
`schedule` and `storage_object_created`.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `trigger_id` (string, path, required)
  The opaque, project-wide trigger ID

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/triggers/$TRIGGER_ID" \
  -X DELETE \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.deleteProjectBranchTrigger({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    trigger_id: process.env.TRIGGER_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Deploy code to a function

## POST /projects/{project_id}/branches/{branch_id}/functions/{slug}/deployments

Creates a deployment for the function. Supply any subset of zip,
environment, and runtime; omitted fields inherit the
function's latest version. At least one field must be supplied. The
first deployment of a function must include zip. The newest deployment
becomes active.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `slug` (string, path, required)
  The function slug

### Request body


### Response (201)

```json
{
  "deployment": {
    "id": 1,
    "status": "pending",
    "memory_mib": 2048,
    "runtime": "nodejs24",
    "created_at": "2025-01-15T10:30:00Z"
  }
}
```

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/functions/$SLUG/deployments" \
  -X POST \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.createProjectBranchFunctionDeployment({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    slug: process.env.SLUG
  }
});
```

```bash
# neonctl
neon functions deploy <branch_id>
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Get a trigger

## GET /projects/{project_id}/branches/{branch_id}/triggers/{trigger_id}

Returns the trigger visible on the branch. The supported trigger types
are `schedule` and `storage_object_created`.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `trigger_id` (string, path, required)
  The opaque, project-wide trigger ID

### Response (200)

- `trigger` (object, optional)
  A branch-effective trigger discriminated by `type`. The supported trigger
  types are `schedule` and `storage_object_created`.
  

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/triggers/$TRIGGER_ID" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.getProjectBranchTrigger({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    trigger_id: process.env.TRIGGER_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Get function details

## GET /projects/{project_id}/branches/{branch_id}/functions/{slug}

Returns the function identified by its slug.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `slug` (string, path, required)
  The function slug

### Response (200)

```json
{
  "function": {
    "id": "myfunction",
    "slug": "myfunction",
    "name": "myfunction",
    "invocation_url": "https://br-young-forest-a5b6c7d8-myfunction.compute.c-5.us-east-2.aws.neon.tech/",
    "current_deployment": {
      "id": 7,
      "status": "completed",
      "memory_mib": 2048,
      "runtime": "nodejs24",
      "created_at": "2025-01-15T10:30:00Z"
    },
    "active_deployment": {
      "id": 7,
      "status": "completed",
      "memory_mib": 2048,
      "runtime": "nodejs24",
      "created_at": "2025-01-15T10:30:00Z"
    },
    "created_at": "2025-01-15T11:00:00Z"
  }
}
```

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/functions/$SLUG" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.getProjectBranchFunction({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    slug: process.env.SLUG
  }
});
```

```bash
# neonctl
neon functions get <branch_id>
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / List functions on the branch

## GET /projects/{project_id}/branches/{branch_id}/functions

Lists functions on the specified branch.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `cursor` (string, query, optional)
  A cursor to use in pagination. A cursor defines your place in the data list. Include `response.pagination.next` in subsequent API calls to fetch next page of the list.
- `limit` (integer, query, optional)
  Specify a value from 1 to 1000 to limit number of functions in the response

### Response (200)

```json
{
  "functions": [
    {
      "id": "myfunction",
      "slug": "myfunction",
      "name": "myfunction",
      "invocation_url": "https://br-young-forest-a5b6c7d8-myfunction.compute.c-5.us-east-2.aws.neon.tech/",
      "current_deployment": {
        "id": 4,
        "status": "completed",
        "memory_mib": 2048,
        "runtime": "nodejs24",
        "created_at": "2025-01-15T10:30:00Z"
      },
      "active_deployment": {
        "id": 4,
        "status": "completed",
        "memory_mib": 2048,
        "runtime": "nodejs24",
        "created_at": "2025-01-15T10:30:00Z"
      },
      "created_at": "2025-01-15T11:00:00Z"
    }
  ],
  "pagination": {}
}
```

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/functions" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.listProjectBranchFunctions({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID
  }
});
```

```bash
# neonctl
neon functions list
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / List the custom domains on a branch

## GET /projects/{project_id}/branches/{branch_id}/custom-domains

Lists all custom domains registered on the branch, across every target
entity.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `cursor` (string, query, optional)
  A cursor to use in pagination. A cursor defines your place in the data list. Include `response.pagination.next` in subsequent API calls to fetch next page of the list.
- `limit` (integer, query, optional)
  Specify a value from 1 to 1000 to limit number of domains in the response

### Response (200)

- `custom_domains` (array, optional)
  - `domain` (string, required)
    The registered custom domain (normalized, lowercase).
  - `entity_type` (string, required)
    The kind of branch entity the domain targets. Possible values:
    `function` (v1 supports only `function`). Not an `enum`: new values may
    ship in later spec versions — treat any undocumented value as unknown.
    
  - `entity_id` (string, required)
    The target entity's identifier within the branch. For `function` this
    is the function slug.
    
  - `cname_target` (string, required)
    The hostname the customer must point their custom domain at with a
    CNAME record. Empty when the serving region has no custom-domains
    front door configured. This is the activation input: point DNS here
    and the domain goes live (see `status`) once a certificate is issued
    on the first request.
    
  - `status` (string, optional)
    The domain's current validity, computed by a background check:
    `pending` (still converging — point your CNAME at `cname_target` and
    wait), `active` (live: DNS resolves to the edge, the CA is authorized,
    and routing is published), or `error` (a fixable problem — see
    `status_reason`). Not an `enum`: treat any undocumented value as
    unknown. May be absent briefly right after registration.
    
  - `dns_status` (string, optional)
    The DNS + CAA portion of the check: `pending` (no records yet), `ok`
    (resolves to our edge and the CA is authorized), `misconfigured` (your
    CNAME does not resolve to our edge), or `caa_blocked` (your CAA records
    forbid Let's Encrypt). Not an `enum`.
    
  - `binding_status` (string, optional)
    Whether Neon's internal routing for the domain is published:
    `pending`, `present`, or `missing`. `missing` is an internal fault
    surfaced for support. Not an `enum`.
    
  - `status_reason` (string, optional)
    A short, stable machine-readable reason for a non-active `status`
    (e.g. `cname-not-pointing-at-edge`, `caa-blocks-lets-encrypt`,
    `binding-missing`), suitable for keying an actionable hint. Empty when
    active or pending.
    
- `pagination` (object, optional)
  To paginate the response, issue an initial request with `limit` value. Then, add the value returned in the response `.pagination.next` attribute into the request under the `cursor` query parameter to the subsequent request to retrieve next page in pagination. The contents on cursor `next` are opaque, clients are not expected to make any assumptions on the format of the data inside the cursor.
  - `next` (string, optional)
    Cursor for the next page of results. Pass it as the `cursor` query parameter on the next request. Absent on the last page.
  - `sort_by` (string, optional)
    Field by which the results were sorted, echoing the request's sort_by parameter.
  - `sort_order` (string, optional)
    Sort order active for this page. Pass back as `sort_order` in the next request to maintain consistent ordering. Valid values are `asc` and `desc`.

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/custom-domains" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.listProjectBranchCustomDomains({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / List triggers on the branch

## GET /projects/{project_id}/branches/{branch_id}/triggers

Lists the complete project-bounded set of triggers visible on the branch,
ordered by `trigger_id`. An inherited trigger keeps its project-wide ID
and configuration, and is disabled on the child until explicitly enabled
there.

The supported trigger types are `schedule` and
`storage_object_created`. A storage-object-created trigger watches one
exact bucket and fires only after an object upload succeeds.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID

### Response (200)

- `triggers` (array, optional)

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/triggers" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.listProjectBranchTriggers({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Register a custom domain on a branch

## POST /projects/{project_id}/branches/{branch_id}/custom-domains

Registers a customer-owned domain (for example `dashboard.acme.com`) on the
branch and points it at a target entity, chosen by `entity_type` +
`entity_id`. In v1 only `entity_type: function` is supported (an
unsupported type is rejected with `400`), where `entity_id` is the function
slug and the function must already exist on the branch (else `404`).

The response includes the `cname_target` the customer must point their
domain at with a CNAME record; the domain goes live only once that DNS
resolves and a certificate is issued on the first request. A domain already
registered to another resource is rejected with `409` and no detail about
the owner. Re-registering the same domain for the same entity is idempotent.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID

### Request body

- `domain` (string, required)
  The custom domain to register (for example `dashboard.acme.com`).
  Case-insensitive; normalized to lowercase (a trailing root dot is
  stripped, so the 254-char bound admits a fully-qualified name whose
  normalized form is 253 chars). Neon-managed and internal hostnames are
  rejected.
  
- `entity_type` (string, required)
  The kind of branch entity to point the domain at. v1 supports only
  `function`; any other value is rejected with `invalid_entity_type`.
  
- `entity_id` (string, required)
  The target entity's identifier within the branch. For `function` this
  is the function slug (which must already exist on the branch).
  

### Response (201)

- `domain` (string, optional)
  The registered custom domain (normalized, lowercase).
- `entity_type` (string, optional)
  The kind of branch entity the domain targets. Possible values:
  `function` (v1 supports only `function`). Not an `enum`: new values may
  ship in later spec versions — treat any undocumented value as unknown.
  
- `entity_id` (string, optional)
  The target entity's identifier within the branch. For `function` this
  is the function slug.
  
- `cname_target` (string, optional)
  The hostname the customer must point their custom domain at with a
  CNAME record. Empty when the serving region has no custom-domains
  front door configured. This is the activation input: point DNS here
  and the domain goes live (see `status`) once a certificate is issued
  on the first request.
  
- `status` (string, optional)
  The domain's current validity, computed by a background check:
  `pending` (still converging — point your CNAME at `cname_target` and
  wait), `active` (live: DNS resolves to the edge, the CA is authorized,
  and routing is published), or `error` (a fixable problem — see
  `status_reason`). Not an `enum`: treat any undocumented value as
  unknown. May be absent briefly right after registration.
  
- `dns_status` (string, optional)
  The DNS + CAA portion of the check: `pending` (no records yet), `ok`
  (resolves to our edge and the CA is authorized), `misconfigured` (your
  CNAME does not resolve to our edge), or `caa_blocked` (your CAA records
  forbid Let's Encrypt). Not an `enum`.
  
- `binding_status` (string, optional)
  Whether Neon's internal routing for the domain is published:
  `pending`, `present`, or `missing`. `missing` is an internal fault
  surfaced for support. Not an `enum`.
  
- `status_reason` (string, optional)
  A short, stable machine-readable reason for a non-active `status`
  (e.g. `cname-not-pointing-at-edge`, `caa-blocks-lets-encrypt`,
  `binding-missing`), suitable for keying an actionable hint. Empty when
  active or pending.
  

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/custom-domains" \
  -X POST \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.registerProjectBranchCustomDomain({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Update a function

## PATCH /projects/{project_id}/branches/{branch_id}/functions/{slug}

Updates the function's mutable metadata — currently only the display
`name`. A string sets the display name; `null` clears it, after which
the function's `name` falls back to its slug. Leading and trailing
whitespace is trimmed; a whitespace-only name is rejected. Acts only
on a function owned by the branch: a slug that is only inherited from
an ancestor branch returns 404 — rename it on the branch that owns
it. Like every other change on a branch, a rename is isolated per
branch: a branch forked before the rename keeps the name it had at
fork time.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `slug` (string, path, required)
  The function slug

### Request body

- `name` (string, required)
  New display name for the function. `null` clears the display
  name; the function's `name` then falls back to its slug. Leading
  and trailing whitespace is trimmed; a whitespace-only name is
  rejected.
  

### Response (200)

```json
{
  "function": {
    "id": "myfunction",
    "slug": "myfunction",
    "name": "My Function",
    "invocation_url": "https://br-young-forest-a5b6c7d8-myfunction.compute.c-5.us-east-2.aws.neon.tech/",
    "current_deployment": {
      "id": 10,
      "status": "completed",
      "memory_mib": 2048,
      "runtime": "nodejs24",
      "created_at": "2025-01-15T10:30:00Z"
    },
    "active_deployment": {
      "id": 10,
      "status": "completed",
      "memory_mib": 2048,
      "runtime": "nodejs24",
      "created_at": "2025-01-15T10:30:00Z"
    },
    "created_at": "2025-01-15T11:00:00Z"
  }
}
```

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/functions/$SLUG" \
  -X PATCH \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.updateProjectBranchFunction({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    slug: process.env.SLUG
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Functions / Update a trigger

## PATCH /projects/{project_id}/branches/{branch_id}/triggers/{trigger_id}

Applies a partial update. The required `type` discriminator must identify
the existing trigger kind. The supported types are `schedule` and
`storage_object_created`. Editing an inherited trigger creates a
child-local shadow with the same `trigger_id`; it remains disabled unless
this request explicitly enables it. For a schedule trigger, updating the
schedule or enabled state increments `version` and recomputes
`next_run_at`.

Disabling stops future scheduling but does not cancel occurrences already
committed for delivery. For `storage_object_created`, the configuration
selects one exact bucket. An omitted object-key prefix matches every key
in that bucket; a present prefix is matched byte-for-byte and
case-sensitively against the full key, without path normalization or a
path-segment boundary.

**Note**: This endpoint is currently in Beta.


### Parameters

- `project_id` (string, path, required)
  The Neon project ID
- `branch_id` (string, path, required)
  The Neon branch ID
- `trigger_id` (string, path, required)
  The opaque, project-wide trigger ID

### Request body

- `type` (string, required)
  Trigger type discriminator; it does not change the trigger type.
  Possible values: `schedule`
- `function_slug` (string, optional)
  Replacement branch-local Function slug.
- `name` (string, optional)
- `function_path` (string, optional)
- `schedule` (object, optional)
  A numeric five-field cron schedule interpreted in UTC.
  - `cron` (string, required)
    Numeric five-field cron expression (minute through day-of-week), interpreted in UTC.
- `enabled` (boolean, optional)
  True enables and false disables future scheduling.

### Response (200)

- `trigger` (object, optional)
  A branch-effective trigger discriminated by `type`. The supported trigger
  types are `schedule` and `storage_object_created`.
  

### Code examples

```bash
curl "https://console.neon.tech/api/v2/projects/$PROJECT_ID/branches/$BRANCH_ID/triggers/$TRIGGER_ID" \
  -X PATCH \
  -H "Authorization: Bearer $NEON_API_KEY"
```

```typescript
import { createNeonClient, raw } from '@neon/sdk';

const neon = createNeonClient({ apiKey: process.env.NEON_API_KEY });
const { data } = await raw.updateProjectBranchTrigger({
  client: neon.client,
  path: {
    project_id: process.env.PROJECT_ID,
    branch_id: process.env.BRANCH_ID,
    trigger_id: process.env.TRIGGER_ID
  }
});
```

### Errors

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Machine-readable code classifying the error type. See `message` for a human-readable explanation.
  Default: ``
- `message` (string, required)
  Error message
