> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Import

`bijection import` reads a local file and stages its rows through the
installation's [archives mount](https://docs.bijection.com/operate/data/export.md#install-the-archives-mount).
The importing principal needs a role admitted by that mount and a live
platform `importer` grant issued by the installation steward.

> [!WARNING]
>
> Data import is in beta.

Use `--help` to see all options. The most common flows are described here.

## Single table import

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection import --table <table path> <path>
```

Import a CSV, JSON, or JSONLines file into a Bijection table.

* `.csv` files must have a header, and each row's entries are interpreted either
  as a (floating point) number or a string.
* `.jsonl` files must have a JSON object per line.
* `.json` files must be an array of JSON objects.
  * JSON arrays have a size limit of 16 MiB. To import more data, use CSV or
    JSONLines. You can convert json to jsonl with a command like
    `jq -c '.[]' data.json > data.jsonl`

Imports into a table with existing data will fail by default, but you can
specify `--append` to append the imported facts to the table or `--replace` to
replace existing data in the table with your import.

The default is your configured installation. Name another installation with `--installation <project>:<name>`,
as `--installation my-app:prod`.

## Import data from an archive ZIP file

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection import <path>.zip
```

Use a ZIP written by [`bijection export`](https://docs.bijection.com/operate/data/export).
A sealed copy keeps its original fact ID, typed ID references and declared
keys. For another installation, configure `managedSources` on the destination
mount with the source's issued relation IDs and their local tables. The
ZIP table path selects the destination table, and the reviewed mapping
resolves the original IDs independently of local table numbers.
Clear imports take declared keys from the rows. For minted-key tables they
allocate fresh IDs and remap references to the imported facts. For physical
recovery, see [Backups](https://docs.bijection.com/operate/data/backup-and-restore.md).

Imports where tables have existing data will fail by default, but you can
specify `--replace` to replace existing data in tables mentioned in the ZIP
file.

For a hosted archive, the app declares an importer role and passes it in
`archives({ allow: { import: [importer], … } })`. A caller whose grant can
confer that role issues it to the person importing the archive. Its expiry
must cover confirmation, staging and landing. Use the same signed-in
principal for all three steps. The installation checks the grant again
when it decides whether to land the archive.

## Limits

CSV and JSONLines imports have a 16 MiB line limit, including line endings and
CSV headers. Quoted multiline CSV values count as a single logical line. For ZIP
imports, the limit applies to decompressed lines in `documents.jsonl` files.

Imported facts must also meet the
[1 MiB fact size limit](https://docs.bijection.com/database/types.md#limits).

## Use cases

1. Seed dev installations with sample data.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
# Archive exported from prod or another dev deployment.
bijection import seed_data.zip

# Import single table from jsonl/csv
bijection import --table <table path> data.jsonl
```

2. Replace the archived tables in an installation from an archive ZIP.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection import --installation my-app:prod --replace archive.zip
```

3. Seed preview installations with sample data, exported from prod, dev, or
   another preview installation. Example for Vercel, seeding data from
   `seed_data.zip` committed in the root of the repo.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection deploy --cmd 'npm run build' &&
if [ "$VERCEL_ENV" == "preview" ]; then
bijection import --installation "my-app:$VERCEL_GIT_COMMIT_REF" seed_data.zip;
fi
```

4. Clear a table efficiently with an empty import.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
touch empty_file.jsonl
bijection import --replace --table <table path> empty_file.jsonl
```

## Features

* A table declared with `key` takes its key from the row's key fields.
  Use declared fields for the rest of the row.
* All import modes publish table changes atomically in one branch landing.
* `--replace` clears the import's target tables. `--replace-all` also clears
  the mount's declared tables that the archive omits.
* Use `--library` to select a subtree other than `archives`. Run
  `bijection import --status <importId>` with the same installation selection
  and mount to inspect an import.
* JSON, JSONLines and archive ZIP rows use Bijection wire JSON. Tagged
  values preserve types such as Int64 and Bytes.
* A sealed [File](https://docs.bijection.com/files) keeps its ID, lifetime and erasure units. The
  import skips and counts copies whose units have closed. A File disclosed
  through a clear-copy release receives a new ID, and imported facts refer
  to that ID.
* Sealed imports require the named recipient and access to original custody.
  For a destination outside that authority, re-export with the affected tables
  in `exclude` or use an authorized clear-copy release.
* Re-export sealed packages made before the current portable descriptor cutover.

## Warnings

Bijection refuses streaming import, so the Fivetran and Airbyte destination
connectors cannot write to a Bijection installation. Use an
[integration](https://docs.bijection.com/integrations) to synchronize an external system, or
`bijection import` to load a file.

* Avoid changing the ZIP file between exporting it with `bijection export` and
  importing it with `bijection import`. Some manual changes of the ZIP file may
  be possible, but remain undocumented. Please share your use case with the Bijection team at
  [contact@bijection.com](mailto:contact@bijection.com).

Data import uses database bandwidth to write facts. You can observe it on
the [console usage page](https://console.bijection.com/team/settings/usage).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.