# Source connections

Canonical: https://interlatent.com/docs/ivy/source-reference

Connection states, cloud permissions, import tools, and recovery for source workflows.

## Check access before importing

Section: https://interlatent.com/docs/ivy/source-reference#connection-state

`get_account` and `get_capabilities` report plan access and supported sources. `list_storage_connections` returns connection IDs, providers, permissions, and whether a connection is usable. Recheck access with `verify_storage_connection`; inspect its `verified` result and the returned connection state.

| Response | Meaning | Next action |
| --- | --- | --- |
| Usable connection | The saved connection is ready to use. | Verify it if the cloud grant may have changed. |
| connected: false with setup | Additional cloud setup is required. | Apply the returned instructions and finish verification. |
| Pending read/write connection | A connection exists but is not usable yet. | Complete the IAM role setup and verify it. |
| Already connected | A connection for this bucket and permission already exists. | List connections and reuse its ID. |
| verified: false | The current access check failed. | Read the reason, fix the grant, and verify again. |

Note: The examples below describe tool arguments for your agent. They are not an installable Python client. Replace every placeholder with your own values.

## AWS permissions and verification

Section: https://interlatent.com/docs/ivy/source-reference#aws-permissions

`create_storage_connection(provider="aws", bucket=..., permission="read", region=...)` probes access. When setup is required, use the response’s bucket-policy or IAM-role instructions. Preserve any returned verification nonce when retrying. If the bucket already has a policy, merge the new statements before applying it; AWS put-bucket-policy replaces the whole policy.

1. For import-only access, request permission="read" and follow the returned setup.
2. For export access, request permission="read_write" with a chosen root_prefix. The AWS flow creates a pending connection and returns a trust policy and permission policy.
3. Create the IAM role with those exact policies, including the connection-specific ExternalId condition. The returned policy reads the bucket and limits writes to the selected root.
4. Call verify_storage_connection with the connection ID and the role ARN. If the role was just created, allow for IAM propagation before verifying again.
5. Check verified=true and a usable connection before importing or writing exports.

Note: Do not reuse another connection’s trust policy, ExternalId, or nonce. These values come from the current setup response. A read connection does not grant export write access.

## Google Cloud permissions

Section: https://interlatent.com/docs/ivy/source-reference#gcs-permissions

`create_storage_connection(provider="gcp", bucket=..., permission="read")` checks bucket access. If it returns setup, apply its commands for the exact service account and bucket, then retry as instructed. Use `verify_storage_connection(connection_id=...)` to check the saved connection. Read/write access is a separate request with a storage root.

Note: Choose the default output bucket in the dashboard. Connecting a bucket or importing a source does not choose it as the destination for future exports.

## Source storage and copies

Section: https://interlatent.com/docs/ivy/source-reference#origin-mirror

`import_from_bucket` takes an `s3://` or `gs://` URI, project ID, and an optional connection ID. `sync_mode="origin"` is the default and reads from source storage. `sync_mode="mirror"` copies the source tree into Interlatent storage. Keep origin objects and their access grants available for later playback and processing.

### Bucket import arguments

```python
import_from_bucket(
    uri="s3://YOUR_BUCKET/recordings/session-01/",
    project_id="PROJECT_ID",
    connection_id="CONNECTION_ID",
    sync_mode="origin",
    episode_limit=1,
)
```

Note: A connection and an import are separate operations. Verifying a bucket does not import its files. A recognized layout starts importing; an unrecognized one can start metered converter authoring and automatic verified conversion.

## Drive tools and conversion continuation

Section: https://interlatent.com/docs/ivy/source-reference#drive-tools

`drive_service_account` returns the email and share steps. `list_shared_drive_folders` returns directly shared folders, who shared them, and a continuation token when more are available. `import_drive_folder(folder_link=..., project_id=...)` accepts a folder link or discovered folder ID and returns an estimate. Review it before calling `confirm_import`.

1. Share the intended folder directly as Viewer with the address Ivy returns, with notifications off.
2. Discover it with list_shared_drive_folders and check its identity.
3. Plan with import_drive_folder. Review bytes, skipped items, notes, and any conversion requirements.
4. After approval, call confirm_import(ingest_id=...). Poll ingest_status at least five seconds apart.
5. If the copied files need conversion, use start_conversion on the existing ingest ID when instructed. It follows the existing copy and returns the effective import to track.

Note: Zero planned files does not always establish that there are no recordings to process. A known converter may discover episodes when the run starts; inspect the response’s notes and conversion information.

## Upload protocol and preparation

Section: https://interlatent.com/docs/ivy/source-reference#upload-tools

Direct HTTPS files use `import_video_url`. Terminal agents use the upload tools below. After a single-video import or upload, poll `get_video` until the duration is present; it also provides the recovery path when preparation failed to start.

| Input | Tool sequence |
| --- | --- |
| Local video from a terminal | prepare_video_upload → upload bytes → complete_video_upload → get_video |
| Local dataset directory from a terminal | prepare_directory_upload → upload each file → complete_directory_upload → ingest_status |
| Direct HTTPS video file | import_video_url → get_video |
| Hugging Face repository | huggingface_search → huggingface_import → ingest_status → list_videos |

Note: For terminal uploads, POST every returned form field and add the file last as “file”. Preserve relative directory paths. Complete a directory upload only after all files have landed; its completion starts the import.

## Import completion and sample limits

Section: https://interlatent.com/docs/ivy/source-reference#completion

Keep the returned ingest ID and poll `ingest_status` at intervals of at least five seconds. Follow its active import ID when copying leads to conversion. Once it reports completion, use `list_videos(project_id=..., limit=100)` and continue with `next_offset` as needed. Review imported, skipped, and failed counts rather than treating a submitted request as success.

| Situation | What to do |
| --- | --- |
| The source cannot enforce the sample limit | Nothing starts for that refused request. Keep the limit; use a compatible source or prepare a smaller collection. |
| A copy or conversion is still running | Continue polling the existing import instead of submitting a duplicate. |
| The recording layout needs clarification | Describe episode boundaries, cameras, metadata files, and what should become recorded channels. |
| A Drive copy needs a converter | Continue with start_conversion on the existing import when authorized. |
| You need to stop a running import | Use stop_ingest. Completed recordings stay; usage already incurred still applies. |
| You need to revoke a connection | Review its dependencies before detaching it. Detaching stops new work and can break origin recordings that depend on it. |

- [Choose an import source](https://interlatent.com/docs/ivy/import-datasets)
- [General troubleshooting](https://interlatent.com/docs/ivy/troubleshooting)
