---
title: "Use this when you need a ready-to-paste CSS gradient value from 2-5 hex color stops."
method: POST
path: "/v1/css_gradient"
tags: ["color"]
---

# Use this when you need a ready-to-paste CSS gradient value from 2-5 hex color stops.

`POST /v1/css_gradient`

## Request

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

Use this when you need a ready-to-paste CSS gradient value from 2-5 hex color stops. Builds a linear-gradient(...) (default; direction defaults to 'to bottom') or a radial-gradient(circle, ...). Direction accepts keywords ('to right', 'to left', 'to top', 'to bottom'), angles ('45deg', '90deg', '135deg'), or 'to <side> <side>'; it is ignored for radial, and passing type 'radial' (or direction 'radial') forces a radial gradient. Colors accept 6-digit hex with or without a leading '#' and are echoed normalized in order. Deterministic: same input, same output. Example: {colors:['#3b82f6','8b5cf6']} -> css 'linear-gradient(to bottom, #3b82f6, #8b5cf6)', type 'linear'. Radial results omit the 'direction' field.

## Request body

- object
  - `colors` string[], required: 2 to 5 color stops as 6-digit hex strings, with or without a leading '#', e.g. ["#3b82f6", "8b5cf6"].
  - `type` 'linear' | 'radial': Gradient type. Defaults to "linear". "radial" produces radial-gradient(circle, ...).
  - `direction` string: Linear direction: a keyword ("to right", "to left", "to bottom", "to top"), an angle ("45deg", "135deg", "90deg"), or "to <side> <side>". Defaults to "to bottom". Ignored for radial; passing "radial" here forces a radial gradient.

## Response `200`

Structured tool result.

- object
  - `tool` string
  - `result` object
    - `css` string, required: Ready-to-paste CSS gradient value, e.g. 'linear-gradient(to bottom, #3b82f6, #8b5cf6)' or 'radial-gradient(circle, #3b82f6, #8b5cf6)'.
    - `type` 'linear' | 'radial', required: Resolved gradient type.
    - `direction` string: Resolved linear direction (keyword or angle). Present only for linear gradients; omitted for radial.
    - `colors` string[], required: Normalized 6-digit hex color stops, in input order.

## 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)
