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

# Configure credentials and account context

> Select an API key, environment, integration type, and acting account before your first API read.

Connect the [installed CLI](https://docs.straddle.com/developer-tools/cli/install.md) to the environment and account you want to work with. Start with a sandbox API key from the [Straddle dashboard](https://dashboard.straddle.com).

**1. Provide an API key**

Choose how the CLI receives your key:

> [tab] Environment variable
>
> Set `STRADDLE_API_KEY` in your shell or through your secret manager. Replace the placeholder locally:
>
> ```bash theme={null}
> export STRADDLE_API_KEY="YOUR_SANDBOX_API_KEY"
> ```
>
> This variable overrides a token saved with `auth set-token`. Enter keys outside agent prompts and shared scripts; shell history can retain commands that contain them.

> [tab] Saved token
>
> Save the key in the CLI's owner-only configuration file:
>
> ```bash theme={null}
> straddle auth set-token YOUR_SANDBOX_API_KEY
> ```
>
> The default file is `~/.config/straddle/config.toml`. The command contains the key, so account for shell history when entering it.

Inspect credential presence and source:

```bash theme={null}
straddle auth status --json
```

`authenticated: true` means a credential is present. `verified: false` means this check hasn't tested it against the API.

**2. Select the environment**

Use sandbox while building and testing:

```bash theme={null}
export STRADDLE_ENVIRONMENT=sandbox
```

Sandbox is the default. Use `production` with a production key when you're ready for production operations. A configured `STRADDLE_BASE_URL` or `base_url` can override the standard host, so verify the resolved environment in step 4.

**3. Set your integration type**

Choose the command that matches who owns the customers and payments:

| Integration | Command | Ownership |
| - | - | - |
| Direct business | `straddle setup --type account` | One business collects or sends its own payments. |
| SaaS platform | `straddle setup --type saas` | Your clients own their customers. |
| Marketplace | `straddle setup --type marketplace` | Your platform owns the customers. |

For a SaaS or marketplace platform, select the embedded account for account-level work:

```bash theme={null}
straddle use-account ACCOUNT_ID
```

This selection stays in effect until changed. `straddle use-account --clear` returns to a context without an acting account. Direct business integrations use their key's account and omit this step.

**4. Verify context and an API read**

Inspect `runtime_context.environment`, `integration_type`, and `acting_account`:

```bash theme={null}
straddle agent-context --pretty
```

Then request one customer from the selected environment:

```bash theme={null}
straddle customers list --page-size 1 --data-source live --no-cache --json
```

A successful response, including an empty list, confirms that the key can perform this operation. Resolve any [authentication or scope error](https://docs.straddle.com/developer-tools/cli/troubleshooting.md) before continuing.

## Choose an account for one command

For a platform payment read, override the saved account with `--account`:

```bash theme={null}
straddle payments --account ACCOUNT_ID --data-source live --no-cache --json
```

The CLI applies `Straddle-Account-Id` by operation and integration type. Marketplace customer, paykey, and Bridge operations use platform ownership. Account-management operations take IDs in the path or body. See [account scoping](https://docs.straddle.com/developer-tools/mcp/account-scoping.md) for the ownership rules.

> [accordion] Configuration files and reusable profiles
>
> Credentials live in `config.toml`; integration type and the saved account live in `platform.toml`. `STRADDLE_CONFIG` selects the credentials file and places `platform.toml` beside it. `STRADDLE_PLATFORM_CONFIG` selects the platform file explicitly. The `--config` flag changes only the credentials file.
>
> A profile applies saved flag values to one invocation. Inspect it with `straddle profile show PROFILE_NAME`, then use `--profile PROFILE_NAME` on compatible commands. `profile use` prints values; it doesn't activate a persistent profile. Explicit flags override saved values.
>
> A saved `account` acts as an explicit `--account`, including on commands that reject it. Run `use-account` and profile inspection without `--profile`. Profiles can also supply sync filters or `path-context`; review [sync completeness](https://docs.straddle.com/developer-tools/cli/local-data.md#check-sync-completeness) before using them for analysis.


## Related topics

- [Work with Straddle from your terminal](https://docs.straddle.com/developer-tools/cli/overview.md)
- [Choose an SDK](https://docs.straddle.com/developer-tools/sdks.md)
- [Find paykeys that need attention](https://docs.straddle.com/playbooks/expiring-paykeys.md)
- [Troubleshoot the Straddle CLI](https://docs.straddle.com/developer-tools/cli/troubleshooting.md)
- [Review identity queue items](https://docs.straddle.com/playbooks/identity-review.md)


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