---
title: "Returns `n` random bytes as the response body."
url: "https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8/operations/bytes_handler"
---

> Full API specification: https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8.md

# Returns `n` random bytes as the response body.

`GET` `/bytes/{n}`

Operation ID: `bytes_handler`

Response headers: `Content-Type: application/octet-stream`, `Content-Length: n`. `n` is capped at `MAX_BYTES_RESPONSE_SIZE` (10 MiB); larger values return 400. `n = 0` returns an empty 200 OK. The body is filled via `rand::thread_rng().fill_bytes(&mut buf[..])` for maximum-entropy payloads (useful for verifying binary integrity through a proxy, since any tampering is observable).

## Path parameters

- `n` (integer, required) - Number of random bytes to return (max 10485760)

## Responses

- `200` - Returns n random bytes as application/octet-stream
- `400` - n exceeds MAX_BYTES_RESPONSE_SIZE

## OpenAPI definition

```yaml
openapi: 3.0.3
info:
  title: rucho
  version: 1.6.0
servers:
  - url: https://rucho.org
    description: Production (EKS us-east-2, behind Kong)
paths:
  /bytes/{n}:
    get:
      tags:
        - crate::routes::bytes
      summary: Returns `n` random bytes as the response body.
      description: >-
        Response headers: `Content-Type: application/octet-stream`,
        `Content-Length: n`.

        `n` is capped at `MAX_BYTES_RESPONSE_SIZE` (10 MiB); larger values
        return 400.

        `n = 0` returns an empty 200 OK.


        The body is filled via `rand::thread_rng().fill_bytes(&mut buf[..])` for

        maximum-entropy payloads (useful for verifying binary integrity through
        a

        proxy, since any tampering is observable).
      operationId: bytes_handler
      parameters:
        - name: n
          in: path
          description: Number of random bytes to return (max 10485760)
          required: true
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Returns n random bytes as application/octet-stream
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        "400":
          description: n exceeds MAX_BYTES_RESPONSE_SIZE
```
