---
title: "table.file.export: Export a table as a CSV or Markdown file — Table kit command — Kition"
description: "Answers one table as a CSV or Markdown file's bytes (base64, in data) for the host to write as a new file, without changing anything."
canonical: "https://developer.kition.ai/docs/kits/table/commands/table.file.export"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/table/commands/table.file.export](https://developer.kition.ai/docs/kits/table/commands/table.file.export)

# table.file.export

**Export a table as a CSV or Markdown file.** Answers one table as a CSV or Markdown file's bytes (base64, in data) for the host to write as a new file, without changing anything.

- Kit: Table 0.4.0 (.ktable); reference: [Table kit commands](https://developer.kition.ai/docs/kits/table.md)
- Changes the document: no

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `format` | `"csv" \| "md"` | yes | csv, or md for a Markdown table. |
| `tableId` | `integer \| string` | no | The table to export; default the first table. |

## Call through table_run

```text
table_run {
  "path": "<file>.ktable",
  "steps": [{ "command": "table.file.export", "params": { "format": <"csv" | "md"> } }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `tableId`. table_run answers the step’s result in `completed[i].result`.

## Result

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `bytes` | `integer` | no | The file's size. |
| `data` | `string` | no | The file's bytes, base64. |
| `error` | `object` | no | Why the call failed (A18); the file is as it was. |
| `extension` | `string` | no |  |
| `format` | `string` | no |  |
| `mime` | `string` | no |  |
| `name` | `string` | no | The table's title. |
| `tableId` | `integer` | no |  |

```json
{
  "additionalProperties": false,
  "properties": {
    "bytes": {
      "description": "The file's size.",
      "type": "integer"
    },
    "data": {
      "description": "The file's bytes, base64.",
      "type": "string"
    },
    "error": {
      "additionalProperties": false,
      "description": "Why the call failed (A18); the file is as it was.",
      "properties": {
        "code": {
          "enum": [
            "invalid-params",
            "invalid-op",
            "invalid-value",
            "not-found",
            "read-only",
            "unknown-command",
            "command-failed",
            "not-open",
            "draft-required",
            "not-allowed",
            "unsupported",
            "unavailable",
            "failed"
          ],
          "type": "string"
        },
        "index": {
          "description": "The failing step or operation.",
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "extension": {
      "type": "string"
    },
    "format": {
      "type": "string"
    },
    "mime": {
      "type": "string"
    },
    "name": {
      "description": "The table's title.",
      "type": "string"
    },
    "tableId": {
      "type": "integer"
    }
  },
  "type": "object"
}
```

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "format": {
      "description": "csv, or md for a Markdown table.",
      "enum": [
        "csv",
        "md"
      ],
      "type": "string"
    },
    "tableId": {
      "description": "The table to export; default the first table.",
      "oneOf": [
        {
          "type": "integer"
        },
        {
          "type": "string"
        }
      ],
      "x-khp-types": [
        "Table"
      ]
    }
  },
  "required": [
    "format"
  ],
  "type": "object"
}
```

Generated from kition-sdk packages/script/kits/table.ts and the kit itself (kition-table@ee73209).
