Request Inspector

Inspect HTTP requests and responses with status codes, headers, timing, format detection, and cURL generation.

@drift-ui/request-inspectorRegistry JSONOpen in v0
POSThttps://api.drift-ui.dev/v1/deployments?env=production
201 Created
Query Parameters (1)
envproduction
Request Body
  • project:"drift-dashboard"
  • branch:"main"
  • commit:"8f3e21a"
  • autoRollback:true

Keyboard

←→
Switch between tabs
HomeEnd
First or last tab
On this page

Installation

The CLI also installs the npm packages and registry items it builds on, and reads the style in your components.json to pick the Base UI or Radix build.

Usage

request-inspector-usage.tsx
"use client"

import { RequestInspector } from "@/components/ui/request-inspector"

export function ApiLogDetail() {
  return (
    <RequestInspector
      request={{
        method: "POST",
        url: "https://api.example.com/v1/orders",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer sec_test_token123",
        },
        body: {
          items: [{ sku: "DRIFT-TSHIRT", quantity: 2 }],
          currency: "usd",
        },
      }}
      response={{
        status: 201,
        statusText: "Created",
        headers: {
          "Content-Type": "application/json",
          "X-Request-Id": "req_8849b2",
        },
        body: {
          id: "ord_91823",
          status: "confirmed",
          total: 5800,
        },
        durationMs: 142,
      }}
    />
  )
}

Examples

Resource lookup

Inspect a standard GET API call with response caching, headers, and formatted JSON body.

GEThttps://api.example.com/v1/users/usr_48102
200 OK
Request Body
No request body

Webhook delivery

Inspect incoming webhooks with custom signature verification headers and plain text responses.

POSThttps://api.example.com/webhooks/stripe
200 OK
Request Body
  • id:"evt_3Mvw92LkdIwHu7ix0Sne85Y"
  • object:"event"
  • type:"payment_intent.succeeded"
  • created:1793356800
  • data:{…}
  • object:{…}
  • id:"pi_3Mvw92LkdIwHu7ix0"
  • amount:25000
  • currency:"usd"
  • status:"succeeded"

Validation error

Review client error responses with status badge color mapping and field error details.

POSThttps://api.example.com/v1/subscriptions
422 Unprocessable Entity
Status:422 Unprocessable Entity
Duration:310 ms
Response Body
  • error:"validation_failed"
  • message:"The seat quantity must be a positive integer."
  • field:"seats"
  • code:422

API reference

RequestInspector

Inspect HTTP requests and responses with status badge, duration, headers, query parameters, body format detection, and cURL generation.

Prop
requestRequiredRequestInspectorRequestRequest details including method, url, optional headers, and body.
responseRequestInspectorResponseResponse details including status, statusText, headers, body, and durationMs.
defaultTab"request" | "response" | "headers" | "timing"Default"request"Initial active tab when uncontrolled.
tab"request" | "response" | "headers" | "timing"Controlled active tab.
onTabChange(tab: "request" | "response" | "headers" | "timing") => voidCallback fired when the active tab changes.
sensitiveHeadersstring[]DefaultDEFAULT_SENSITIVE_HEADERSList of header names to mask by default and reveal with secret-field. Passing this replaces defaults; spread DEFAULT_SENSITIVE_HEADERS to retain them.
hideCurlbooleanDefaultfalseWhether to hide the Copy as cURL action button.

Other props go to the <div>.

buildCurlCommand, quoteShell, isSensitiveHeader, normalizeHeaders, parseQueryParams, parseBody, formatDuration, getStatusBadgeClass, getStatusText

buildCurlCommand(request: RequestInspectorRequest, options?: { maskSensitive?: boolean; sensitiveHeaders?: string[] }): string; quoteShell(arg: string): string; isSensitiveHeader(name: string, sensitiveHeaders?: string[]): boolean; normalizeHeaders(headers?: RequestInspectorHeaders | [string, string][]): [string, string][]; parseQueryParams(url: string): [string, string][]; parseBody(body: unknown): { isJson: boolean; jsonValue?: unknown; text: string }; formatDuration(ms?: number): string; getStatusBadgeClass(status: number): { className: string; label: string }; getStatusText(status: number): string

Pure logic helpers imported from @/lib/request-inspector-utils.

Source

components/ui/request-inspector.tsx