Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v4
Expand All @@ -45,7 +45,7 @@ jobs:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/cloudflare-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v4
Expand All @@ -97,7 +97,7 @@ jobs:
if: github.repository == 'cloudflare/cloudflare-typescript' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v4
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/detect-breaking-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
branches:
- main
- next

jobs:
detect_breaking_changes:
runs-on: 'ubuntu-latest'
name: detect-breaking-changes
if: github.repository == 'cloudflare/cloudflare-typescript'
steps:
- name: Calculate fetch-depth
run: |
echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV

- uses: actions/checkout@v6
with:
# Ensure we can check out the pull request base in the script below.
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: |
yarn install

- name: Detect breaking changes
run: |
# Try to check out previous versions of the breaking change detection script. This ensures that
# we still detect breaking changes when entire files and their tests are removed.
git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true
./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }}
Comment on lines +10 to +36

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, the fix is to explicitly set a permissions block in the workflow (either at the top level or for the affected job) so that the GITHUB_TOKEN is granted only the scopes required. Since this job only checks out code and runs local scripts, it only needs read access to repository contents and does not appear to require any write scopes or additional permissions.

The best, non-breaking fix is to add a top-level permissions section right under the workflow name: (or under on:) specifying contents: read. This will apply to all jobs that do not override permissions (in this file, there is only detect_breaking_changes). No existing steps require write access to contents, issues, or pull requests, and actions/checkout works correctly with contents: read. No other files or imports are involved, and no functional behavior of the job changes apart from tightening the token’s permissions.

Concretely:

  • Edit .github/workflows/detect-breaking-changes.yml.
  • Insert a new block:
    permissions:
      contents: read
    immediately after line 1 (name: CI) so that it clearly applies at the workflow level.
  • Leave all other lines unchanged.
Suggested changeset 1
.github/workflows/detect-breaking-changes.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml
--- a/.github/workflows/detect-breaking-changes.yml
+++ b/.github/workflows/detect-breaking-changes.yml
@@ -1,4 +1,6 @@
 name: CI
+permissions:
+  contents: read
 on:
   pull_request:
     branches:
EOF
@@ -1,4 +1,6 @@
name: CI
permissions:
contents: read
on:
pull_request:
branches:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
if: github.repository == 'cloudflare/cloudflare-typescript' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Check release environment
run: |
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "6.0.0-beta.1"
".": "6.0.0-beta.2"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 1995
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-28b84a5db03b38290dfe7ef1de2c68feb68762d7a8f207bdbea4d39a7aeef1ea.yml
openapi_spec_hash: ba6bd61621e4be20b581f4f3bf0978d3
config_hash: 07dfb48a768bfdcfd417ec643bab23f5
configured_endpoints: 1996
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c0d713a413cf8be82c2ba4c521c453a128f1bdc4038355f2a8176369f152c2f4.yml
openapi_spec_hash: 9b9b440902b29ee45ad21b9a22c24c40
config_hash: d1101915de2a8b526a1fe20a9f7314ca
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 6.0.0-beta.2 (2026-01-26)

Full Changelog: [v6.0.0-beta.1...v6.0.0-beta.2](https://github.com/cloudflare/cloudflare-typescript/compare/v6.0.0-beta.1...v6.0.0-beta.2)

### Features

* feat(fraud): public docs for fraud API ([dac4aa5](https://github.com/cloudflare/cloudflare-typescript/commit/dac4aa5614efd1bcfecb1665359e22bc7cf13a66))
* refactor(terraform): restructure origin_tls_client_auth to peer subresources ([89f79e9](https://github.com/cloudflare/cloudflare-typescript/commit/89f79e9494e67c4f034f948be7c2e3be0575b292))


### Bug Fixes

* add write ([e6638ba](https://github.com/cloudflare/cloudflare-typescript/commit/e6638ba1cde0c6745c81d759cb78372d74e4286c))
* node version, unset auth token var ([5a81485](https://github.com/cloudflare/cloudflare-typescript/commit/5a81485c28a9f8b7c71c5ac111b00c0661324427))
* npm publish url and run ci ([0b5a90f](https://github.com/cloudflare/cloudflare-typescript/commit/0b5a90f52790955187d5972ef101d5432ae1fbba))
* publish script ([e106752](https://github.com/cloudflare/cloudflare-typescript/commit/e1067522c6ab0a4d53298331c00ad7f4c877034c))
* registry url ([82932e9](https://github.com/cloudflare/cloudflare-typescript/commit/82932e9640ee9ee7d6e5461789cc7496c27fa4e0))
* typo ([5d30b47](https://github.com/cloudflare/cloudflare-typescript/commit/5d30b47f2f321360016f6168c487cc089c7ba3e5))
* use npm publish and oidc ([da94040](https://github.com/cloudflare/cloudflare-typescript/commit/da94040946c9f7ef5a7ad300a6d763232b28fe86))


### Chores

* **api:** update composite API spec ([ffa2c6c](https://github.com/cloudflare/cloudflare-typescript/commit/ffa2c6c290c72983dbbe2cda71a8a7cd12fb5b28))
* **internal:** codegen related update ([cb76fc9](https://github.com/cloudflare/cloudflare-typescript/commit/cb76fc9caad2f3cfeec4ef1ebb40faa18ffa60da))

## 6.0.0-beta.1 (2026-01-20)
> **Disclaimer:** Please note that v6.0.0-beta.1 is in Beta and we are still testing it for stability.

Expand Down
76 changes: 45 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ This library provides convenient access to the Cloudflare REST API from server-s

The REST API documentation can be found on [developers.cloudflare.com](https://developers.cloudflare.com/api). The full API of this library can be found in [api.md](api.md).

## MCP Server

Use the Cloudflare MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cloudflare-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsb3VkZmxhcmUtbWNwIl19)
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cloudflare-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cloudflare-mcp%22%5D%7D)

> Note: You may need to set environment variables in your MCP client.

## Installation

```sh
Expand Down Expand Up @@ -72,36 +81,31 @@ import Cloudflare, { toFile } from 'cloudflare';
const client = new Cloudflare();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await client.apiGateway.userSchemas.create({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
file: fs.createReadStream('/path/to/file'),
kind: 'openapi_v3',
await client.kv.namespaces.values.update('0f2ac74b498b48028cb68387c421e279', 'My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
value: fs.createReadStream('/path/to/file'),
});

// Or if you have the web `File` API you can pass a `File` instance:
await client.apiGateway.userSchemas.create({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
file: new File(['my bytes'], 'file'),
kind: 'openapi_v3',
await client.kv.namespaces.values.update('0f2ac74b498b48028cb68387c421e279', 'My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
value: new File(['my bytes'], 'file'),
});

// You can also pass a `fetch` `Response`:
await client.apiGateway.userSchemas.create({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
file: await fetch('https://somesite/file'),
kind: 'openapi_v3',
await client.kv.namespaces.values.update('0f2ac74b498b48028cb68387c421e279', 'My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
value: await fetch('https://somesite/file'),
});

// Finally, if none of the above are convenient, you can use our `toFile` helper:
await client.apiGateway.userSchemas.create({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
file: await toFile(Buffer.from('my bytes'), 'file'),
kind: 'openapi_v3',
await client.kv.namespaces.values.update('0f2ac74b498b48028cb68387c421e279', 'My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
value: await toFile(Buffer.from('my bytes'), 'file'),
});
await client.apiGateway.userSchemas.create({
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
kind: 'openapi_v3',
await client.kv.namespaces.values.update('0f2ac74b498b48028cb68387c421e279', 'My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
value: await toFile(new Uint8Array([0, 1, 2]), 'file'),
});
```

Expand All @@ -113,15 +117,17 @@ a subclass of `APIError` will be thrown:

<!-- prettier-ignore -->
```ts
const zone = await client.zones.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }).catch(async (err) => {
if (err instanceof Cloudflare.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
const zone = await client.zones
.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' })
.catch(async (err) => {
if (err instanceof Cloudflare.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
```

Error codes are as follows:
Expand Down Expand Up @@ -223,13 +229,21 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
const client = new Cloudflare();

const response = await client.zones
.create({ account: { id: '023e105f4ecef8ad9ca31a8372d0c353' }, name: 'example.com', type: 'full' })
.create({
account: { id: '023e105f4ecef8ad9ca31a8372d0c353' },
name: 'example.com',
type: 'full',
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: zone, response: raw } = await client.zones
.create({ account: { id: '023e105f4ecef8ad9ca31a8372d0c353' }, name: 'example.com', type: 'full' })
.create({
account: { id: '023e105f4ecef8ad9ca31a8372d0c353' },
name: 'example.com',
type: 'full',
})
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(zone.id);
Expand Down
Loading
Loading