---
title: "Use this when you need to draw cryptographically secure random integers or decimals in a range using unbiased rejection sampling — prefer it over inventing 'random' numbers, which are neither uniform nor safe."
method: POST
path: "/v1/random_number"
tags: ["random"]
---

# Use this when you need to draw cryptographically secure random integers or decimals in a range using unbiased rejection sampling — prefer it over inventing 'random' numbers, which are neither uniform nor safe.

`POST /v1/random_number`

## Request

- Base URL: `https://api.clean.tools`
- URL: `https://api.clean.tools/v1/random_number`
- Auth: none declared

Use this when you need to draw cryptographically secure random integers or decimals in a range using unbiased rejection sampling — prefer it over inventing 'random' numbers, which are neither uniform nor safe. Cryptographically random via Web Crypto (NOT deterministic). Bounds are inclusive; a reversed min/max is auto-swapped; integer mode rounds the bounds inward; `decimals` sets the decimal places in decimal mode. `count` (default 1, max 100). The returned `min`/`max` are the normalized effective bounds. Example: {min: 1, max: 6} -> type "integer", min 1, max 6, count 1, values [2].

## Request body

- object
  - `min` number, required: Lower bound (inclusive).
  - `max` number, required: Upper bound (inclusive for integers).
  - `count` integer: How many numbers (default 1).
  - `type` 'integer' | 'decimal': Number type (default integer).
  - `decimals` integer: Decimal places for decimal type (default 0).

## Response `200`

Structured tool result.

- object
  - `tool` string
  - `result` object
    - `type` 'integer' | 'decimal', required: Whether integers or decimals were drawn.
    - `min` number, required: Effective lower bound after normalization (inclusive).
    - `max` number, required: Effective upper bound after normalization (inclusive for integers).
    - `count` integer, required: Number of values drawn (matches values.length).
    - `values` number[], required: The generated numbers, length = count.

## Other responses

- `400`: Invalid input or the tool reported an error.
- `413`: Request body exceeds the 128 KB limit.
- `429`: Rate limit exceeded; the response carries Retry-After and RateLimit-* headers — honor them and add jitter.

---

[API](https://skmtc.dev/clean/apis/clean-tools-api.md) · [All operations](https://skmtc.dev/clean/apis/clean-tools-api/llms.txt) · [OpenAPI document](https://skmtc.dev/clean/apis/clean-tools-api/revisions/a24a01d2833c?raw)
