Skip to content
moxon home

Captcha Generation

The /captcha endpoint generates a CAPTCHA image. You can provide your own text or let the API generate a random one automatically.

gethttps://api.moxon.dev/v4/captcha
Try itget/v4/captcha

Parameters

  • textstringoptional

    The captcha text. If omitted, a random string is generated

  • lengthnumberoptional

    Length of the auto-generated text (default 6)

  • widthnumberoptional

    Image width in pixels (default 300)

  • heightnumberoptional

    Image height in pixels (default 150)

  • noise"low" | "medium" | "high"optional

    Number of noise lines (default 5)

  • bgstringoptional

    Background color in hexadecimal (e.g. ffffff)

  • colorstringoptional

    Text color in hexadecimal (e.g. 000000)

Response

The endpoint returns a PNG image of the generated captcha.

Good to know

The response includes an X-Captcha-Text header containing the captcha answer, useful for server-side verification. When no text is provided, the auto-generated string avoids ambiguous characters (e.g. 0/O, 1/l).

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400length must be a numberThe length parameter is not a number
  • 400length must be between 1 and 20The length is out of range
  • 400width must be a numberThe width parameter is not a number
  • 400width must be between 100 and 800The width is out of range
  • 400height must be a numberThe height parameter is not a number
  • 400height must be between 50 and 400The height is out of range
  • 400noise must be one of: low, medium, highInvalid noise value
  • 400Invalid color (use hex like ff6600)A bg or color parameter is malformed