Create Excel spreadsheet (.xlsx)
POST /api/xlsx-createTurn rows of data into a real Excel workbook (.xlsx) in one call. Send POST /api/xlsx-create with no required fields (3 optional) and pay $0.003 per call over x402 or MPP (there is no free tier). It returns a JSON object with xlsxBase64, bytes, contentType, filename and sheets.
Send "sheets": each a "name" plus "rows" as an array of arrays or an array of objects (an optional "columns" list sets the order). The first row is a bold, filled, frozen header by default; "headerStyle", "columnWidths" (auto-sized otherwise) and "numberFormats" (such as "#,##0.00") are optional. Every cell is written as a literal value, never a formula: text that starts with = + - or @ stays text. Up to 20 sheets, 10,000 rows per sheet, 200 columns and 50,000 cells, 100,000 characters in all. The request body may be up to 2 MB. Returns the file as base64 with its size, content type and filename.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
sheets | array of object | no | 1 to 20 sheets: {"name","rows","columns"?,"header"?,"headerStyle"?,"columnWidths"?,"numberFormats"?}. rows: arrays of cells, or objects (keys become the header row). header (default true) styles and freezes the first row. headerStyle: {"bold"?,"fill"?:"#D9E1F2","color"?,"freeze"?}. columnWidths and numberFormats: an array by column, or an object keyed by column key, header text or letter. |
rows | array | no | Shorthand for one sheet: the rows, with "name", "columns" and the other sheet options at the top level. |
filename | string | no | File name for the answer (default "workbook.xlsx") |
Example request
curl -i -X POST https://agent402.tools/api/xlsx-create \
-H "Content-Type: application/json" \
-d '{"sheets":[{"name":"Sales","rows":[{"region":"North","units":1200,"revenue":18450.5},{"region":"South","units":860,"revenue":12990},{"region":"West","units":540,"revenue":8120.25}],"columns":["region","units","revenue"],"numberFormats":{"revenue":"#,##0.00"}}],"filename":"sales.xlsx"}'
Without payment this returns HTTP 402 Payment Required with the exact price for xlsx-create; any x402 v2 or MPP client pays it and retries.
Example response
{
"xlsxBase64": "UEsDBBQACAAIAG...",
"bytes": 3191,
"contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"filename": "sales.xlsx",
"sheets": [
{
"name": "Sales",
"rows": 4,
"columns": 3
}
]
}
| Field | Type | Always present | In the example |
|---|---|---|---|
xlsxBase64 | string | yes | UEsDBBQACAAIAG... |
bytes | number | yes | 3191 |
contentType | string | yes | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
filename | string | yes | sales.xlsx |
sheets | array of objects | yes | 1 item in the example |
From an MCP client
catalog.call {
"slug": "xlsx-create",
"params": {
"sheets": [
{
"name": "Sales",
"rows": [
{
"region": "North",
"units": 1200,
"revenue": 18450.5
},
{
"region": "South",
"units": 860,
"revenue": 12990
},
{
"region": "West",
"units": 540,
"revenue": 8120.25
}
],
"columns": [
"region",
"units",
"revenue"
],
"numberFormats": {
"revenue": "#,##0.00"
}
}
],
"filename": "sales.xlsx"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for xlsx-create; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].
Errors and behavior
- Every field is optional. An input the tool rejects returns an HTTP 4xx whose body carries
error,tool,expected,requiredandexample. - A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/xlsx-create returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.003" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/xlsx-create", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"sheets": [
{
"name": "Sales",
"rows": [
{
"region": "North",
"units": 1200,
"revenue": 18450.5
},
{
"region": "South",
"units": 860,
"revenue": 12990
},
{
"region": "West",
"units": 540,
"revenue": 8120.25
}
],
"columns": [
"region",
"units",
"revenue"
],
"numberFormats": {
"revenue": "#,##0.00"
}
}
],
"filename": "sales.xlsx"
}),
});
Related tools
Create Word document (.docx)
POST /api/docx-createTurn markdown into a real Word document (.docx) in one call.
Create PowerPoint deck (.pptx)
POST /api/pptx-createTurn slide outlines into a real PowerPoint deck (.pptx, 16:9) in one call.
JSON to CSV
POST /api/json-to-csvConvert a JSON array of objects to CSV.
Base / radix convert
POST /api/base-convertConvert an integer between number bases (radix 2-36), e.g. binary↔hex↔decimal.
CSV to JSON
POST /api/csv-to-jsonParse CSV (quoted fields supported) into a JSON array of objects, using the first row as headers (header=false.
CSV to Markdown table
POST /api/csv-to-mdConvert CSV into a GitHub-flavored Markdown table (first row is the header).