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

# Automate imports and consume JSON output

> Use stable import inputs, inspect per-group results and detect partial failures.

Use a dedicated managed credential with only the workspaces and tools required by the job. Supply it as `FLEX_STUDIO_TOKEN` through the runner's secret store and set the full `FLEX_STUDIO_URL`.

## Run an import with machine-readable results

```bash theme={null}
if flex-studio import ./assets --manifest ./assets.jsonl --mode keep \
  --workspace 01J9GQ4ZPS9Z91FMY3JC5M8HJX \
  --concurrency 2 --json > import-results.jsonl 2> import-errors.log
then
  printf '%s\n' 'Import finished.'
else
  printf '%s\n' 'Import incomplete. Inspect the results and error log.'
  exit 1
fi
```

Keep both output files outside `./assets`. A successful run exits with 0. An invalid command, planning error, transfer failure or download failure exits with 1. Some groups can complete before a later failure. Import continues across per-group transfer failures, while a manifest or planning error can stop discovery of subsequent groups.

## Read the output contract

| Command | JSON stdout |
| - | - |
| `import --dry-run --json` | One `planned` record per group with source, target, variants, skipped files and roles |
| `import --json` | One `uploaded` or `failed` record per transferred group |
| `search --json` | One JSON object for the returned page |
| `download --json` | One JSON object containing `id` and local `output` |

```jsonl theme={null}
{"status":"uploaded","id":"oak-chair","target":"chairs/oak.jpg","entry":"01J9GQ4ZPS9Z91FMY3JC5M8HJY"}
{"status":"failed","id":"launch-brief","target":"documents/brief.pdf","message":"Studio transfer returned HTTP 422."}
```

Concurrent group records arrive in completion order. Match by stable group `id`, then use the final exit status to detect incomplete work. Top-level errors are written to stderr and can occur before any JSON record.

For retries, keep the source files, group IDs, roles and destination stable. A repeat uses the same content-derived keys while the server retains the corresponding operation state. Inspect failed groups rather than assuming a failed process rolled back earlier successful uploads.


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