# JSON to CSV (`convert.json_to_csv`)

Turn an array of JSON objects into CSV with a header row; nested values are written as JSON strings and cells are quoted when needed.

- **Route:** `POST /v1/run/convert.json_to_csv`
- **Price:** $0.0002 per request ($0.20 per 1,000) · `cost_usd` on every response
- **Source:** GetAllAPIs compute (`compute`) · failover: no
- **Measured latency:** p50 0 ms · p95 0 ms · p99 0 ms (1 calls, 30d)
- **Heavy response:** no

## Input

| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| `rows` | array | yes |  | Array of flat JSON objects |
| `delimiter` | string | no | "," | Field delimiter |
| `columns` | array | no | [] | Column order; default is every key in first-seen order |

## Output (`output` in the run envelope)

| Field | Meaning |
|---|---|
| `csv` | CSV text with a header row. |
| `columns` | Columns written. |
| `row_count` | Number of data rows. |

## Example

```bash
curl -s -X POST https://getallapis.com/v1/run/convert.json_to_csv \
  -H "Authorization: Bearer $GETALLAPIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rows":[{"name":"Widget, large","price":9.5},{"name":"Gadget","price":12,"tags":["new"]}]}'
```

```python
from getallapis_client import Client
client = Client()  # reads GETALLAPIS_API_KEY
result = client.run('convert.json_to_csv', {'rows': [{'name': 'Widget, large', 'price': 9.5}, {'name': 'Gadget', 'price': 12, 'tags': ['new']}]})
print(result['cost_usd'], result['output'])
```

```bash
getallapis run convert.json_to_csv '{"rows":[{"name":"Widget, large","price":9.5},{"name":"Gadget","price":12,"tags":["new"]}]}'
```

Quote first (free, validates input): `POST /v1/quote/convert.json_to_csv` with the same body.
