# reCAPTCHA Response

> Google reCAPTCHA verification response with score, action, and error codes.

- Name: `recaptcha-response`
- Categories: google
- Detail page: https://open-types.dev/types/recaptcha-response

## Install

```bash
# Types only
npx shadcn add @open-types/recaptcha-response

# Types + Zod v4 validators
npx shadcn add @open-types/recaptcha-response-zod

# Types + real-world examples
npx shadcn add @open-types/recaptcha-response-examples
```

## Types

```typescript
export interface ReCAPTCHAResponse {
  success: boolean;
  challenge_ts?: string;
  hostname?: string;
  score?: number;
  action?: string;
  error_codes?: string[];
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { ReCAPTCHAResponse } from "../types/recaptcha-response";

export const recaptchaResponseSchema = z.object({
  success: z.boolean(),
  challenge_ts: z.string().optional(),
  hostname: z.string().optional(),
  score: z.number().min(0, { error: "Score must be at least 0" }).max(1, {
    error: "Score must be at most 1",
  }).optional(),
  action: z.string().optional(),
  error_codes: z.array(z.string().min(1, { error: "Error code cannot be empty" })).optional(),
}) satisfies z.ZodType<ReCAPTCHAResponse>;

export type { ReCAPTCHAResponse } from "../types/recaptcha-response";
```

## Examples

```typescript
// Source: https://developers.google.com/recaptcha/docs/verify
// Captured: 2026-05
import type { ReCAPTCHAResponse } from "../types/recaptcha-response";

export const recaptchaResponseExamples = {
  v2Success: {
    success: true,
    challenge_ts: "2026-04-13T18:30:00Z",
    hostname: "open-types.dev",
  } satisfies ReCAPTCHAResponse,
  v3HighScore: {
    success: true,
    challenge_ts: "2026-04-13T18:30:00Z",
    hostname: "open-types.dev",
    score: 0.9,
    action: "submit_contact",
  } satisfies ReCAPTCHAResponse,
  v3LowScore: {
    success: true,
    challenge_ts: "2026-04-13T18:30:00Z",
    hostname: "open-types.dev",
    score: 0.1,
    action: "submit_contact",
  } satisfies ReCAPTCHAResponse,
  failureInvalidToken: {
    success: false,
    error_codes: ["invalid-input-response"],
  } satisfies ReCAPTCHAResponse,
  failureMissingSecret: {
    success: false,
    error_codes: ["missing-input-secret", "missing-input-response"],
  } satisfies ReCAPTCHAResponse,
  failureTimeoutOrDuplicate: {
    success: false,
    error_codes: ["timeout-or-duplicate"],
  } satisfies ReCAPTCHAResponse,
} as const;
```
