# @cloudflare/util-api

> Set of utilities to help interact with the v4 API.

Latest version **1.2.32** (published 2026-06-30) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @cloudflare/util-api
pnpm add @cloudflare/util-api
yarn add @cloudflare/util-api
bun add @cloudflare/util-api
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.32 |
| Published | 2026-06-30 |
| First published | 2020-01-27 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 35.9 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | Frontend Team <frontend@cloudflare.com> |
| Maintainers | cf-ci-write, dash_service_account, wrangler-publisher, cf-npm-publish |

## Links

- npm: https://www.npmjs.com/package/@cloudflare/util-api
- npm.io page: https://npm.io/package/@cloudflare/util-api

## Dependencies (3)

- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [@types/jsonwebtoken](https://npm.io/package/@types/jsonwebtoken.md) ^7.2.7
- [@cloudflare/util-en-garde](https://npm.io/package/@cloudflare/util-en-garde.md) ^8.0.15

## Recent versions

- 1.2.32 (latest) — 2026-06-30
- 1.2.31 — 2026-05-04
- 1.2.30 — 2026-01-22
- 1.2.29 — 2026-01-21
- 1.2.28 — 2025-11-20
- 1.2.27 — 2022-05-03
- 1.2.26 — 2021-10-28
- 1.2.25 — 2021-10-22
- 1.2.24 — 2021-10-21
- 1.2.23 — 2021-04-23
- 1.2.22 — 2020-12-11
- 1.2.21 — 2020-12-11
- 1.2.20 — 2020-12-11
- 1.2.19 — 2020-08-12
- 1.2.18 — 2020-07-28
- … 16 more at https://npm.io/package/@cloudflare/util-api/versions

## README

# util-api

Handy utilities to help interact with the v4 API.

Lightweight. Asynchronous. In TypeScript.

## Installation

```sh
$ npm install @cloudflare/util-api
```

## Usage

Assuming your node service/worker is behind api-gateway:
```js
import { apiGateway } from '@cloudflare/util-api';

async function handleRequest(request: Request) {
  try {
    const decodedJWT = await apiGateway.authenticateRequest(request);

    console.log(decodedJWT.user.email);
  } catch (e) {
    // Authentication failed
  }
}
```

If you only have a Bearer token: 
```js
import { apiGateway } from '@cloudflare/util-api';

async function handleBearer(bearer: string) {
  try {
    const decodedJWT = await apiGateway.authenticateBearer(bearer);

    console.log(decodedJWT.user.email);
  } catch (e) {
    // Authentication failed
  }
}
```

If you only have a JWT: 
```js
import { apiGateway } from '@cloudflare/util-api';

async function handleJWT(jwt: string) {
  try {
    const decodedJWT = await apiGateway.authenticateJWT(jwt);

    console.log(decodedJWT.user.email);
  } catch (e) {
    // Authentication failed
  }
}
```

---
_Source: https://npm.io/package/@cloudflare/util-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
