# API, CLI, and Python quickstart

Make a read-only API request, use the Attma CLI, and work with workspace files from Python.

Obtain the CLI and SDK package for your deployment from Attma or your organization administrator. The web console and programmatic clients use your workspace permissions.

## Make your first API request

Use the API base URL and workspace slug supplied by your Attma administrator. Set `ATTMA_API_URL` to that base URL, `ATTMA_WORKSPACE` to the workspace slug, and load an Attma bearer access token as `ATTMA_TOKEN` from your secret manager.

This request lists up to ten items in the workspace’s Data root. It reads metadata without downloading file contents.

```sh
curl --fail-with-body --silent --show-error --get \
  "${ATTMA_API_URL%/}/api/v1/data/fs/${ATTMA_WORKSPACE}/ls" \
  --header "Authorization: Bearer ${ATTMA_TOKEN}" \
  --data-urlencode "path=/" \
  --data-urlencode "limit=10"
```

The JSON response contains an `items` array. A `401` means the request needs a valid token. Check workspace access and the path if the requested folder is unavailable.

## CLI quickstart

```sh
attma login
attma workspace ls
attma workspace use example-lab
attma ls attma:///
attma --json stat attma:///example.txt
```

`attma:///example.txt` resolves in the active workspace. `attma://example-lab.account/example.txt` names the workspace explicitly. Use `attma --help` or a command's `--help` to check the options available in your installed version.

## Python Data quickstart

```python
from attma.ldata import LPath

for item in LPath("attma:///").iterdir():
    print(item.name())
```

Use a client with the same authorized workspace when acting on a path in a workflow. For downloads or file use that needs to be reproduced, keep the exact Data version ID.

- Use `/` to join an `LPath` with a child name, and `iterdir()` to list immediate children.
- Read metadata with `name()`, `node_id()`, `type()`, `size()`, `size_recursive()`, `content_type()`, and `version_id()`. These methods fetch metadata when needed. Call `fetch_metadata()` to refresh it.
- Use `exists()` or `is_dir()` to check a path. Handle `AttmaPathError` when an operation fails.
- Use `download()`, `upload_from()`, and `copy_to()` for transfers. Directory operations include `mkdirp()` and the recursive delete method `rmr()`.

## Workflows API

Use the Workflows client or the CLI to discover installed definitions, submit runs, and inspect results. The [workflow guide](https://app.attma.bio/en/docs/workflows) describes the run review, versioning, and troubleshooting behavior. A workflow must be installed and a compatible runner must be available before submission.

Keep API credentials in your secret manager. Send them only to the Attma endpoint your administrator supplies. Keep approval records and the immutable IDs you used when reproducing a run.
