# export

URL: /business/nouns/collection/export · Id: `verb:Collection.export` · Call: `await $.Collection.export({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Export writes a Collection’s records to a file or the Startup’s warehouse, once or on a schedule.

Export writes a [Collection](/business/nouns/collection)’s records to a file or the [Startup](/business/nouns/startup)’s warehouse, once or on a schedule.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `collection` | [Collection](/business/nouns/collection) | Yes | The Collection to export. |
| `to` | `string` | Yes | A file format, or the warehouse Integration that receives it. |
| `cadence` | `string` | No | How often it repeats; omitted, it runs once. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | [File](/business/nouns/file) | No | The exported File, for a one-time export. |
| `collection` | [Collection](/business/nouns/collection) | Yes | The Collection exported. |

## Effects
- Emits [`Collection.exported`](/business/events/Collection.exported).
- Performed by the [Data Engineer](/agents/engineering/data-engineer).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Masks fields the caller’s Permissions hide.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [Collection.export](/business/nouns/collection/export) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Low: two-way, nothing at stake |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | None: it runs once review passes. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Export the latest collection.
```

**API**

```bash
curl -X POST https://api.sb/tutorloop.com/collections/collection_1/export \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"Example to"}'
```

```json
{
  "api": "https://api.sb/tutorloop.com",
  "file": {
    "$id": "https://api.sb/tutorloop.com/files/file_1",
    "$type": "File",
    "contentType": "Example content type",
    "size": 1
  },
  "collection": {
    "$id": "https://api.sb/tutorloop.com/collections/collection_1",
    "$type": "Collection",
    "id": "Example id",
    "type": [
      "noun_1"
    ]
  },
  "action": {
    "$id": "https://api.sb/tutorloop.com/actions/action_1",
    "operation": "Collection.export",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/tutorloop.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const { file, collection } = await $.Collection.export({ collection: 'collection_1', to: 'Example to' })
```

**CLI**

```bash
npx startup-builder do Collection.export --json '{"collection":"collection_1","to":"Example to"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Collection.export({ collection: 'collection_1', to: 'Example to' })"
  }
}
```

Guides that call it: [Export my customers to CSV](/systems/data-and-insights/export-my-data).