> For the complete documentation index, see [llms.txt](https://spree-finance.gitbook.io/spreefinance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spree-finance.gitbook.io/spreefinance/developer-guides/stable-points-sp/authentication.md).

# Authentication

### API Keys

Get your API key from [Spree Studio](https://studio.spree.finance). Go to Settings > API Keys and generate a new key.

Pass it as a Bearer token in the `Authorization` header:

```bash
curl -X POST https://api.stg.spree.finance/api/v1/build/mint \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": {"asset": "0x...", "amount": "1000000"}, "key": "0xSignerAddress"}'
```

### Base URLs

| Environment | URL                                    |
| ----------- | -------------------------------------- |
| Staging     | `https://api.stg.spree.finance/api/v1` |

### SDK Authentication

The SDK talks to RPC endpoints, not the Spree API. On-chain operations need no API key. Pass your RPC URL in the config:

```typescript
import { Factory } from '@spree-finance/spree-evm-sdk';

const factory = new Factory({
  rpcUrl: 'https://sepolia.base.org',  // your RPC endpoint
  chainId: 84532n,
  contractAddress: '0xFactoryAddress',
  from: '0xYourWallet',
  defaultGasPriceWei: 1_000_000_000n,
  defaultGasLimit: 500_000n,
});
```

The `ContractRegistry` module uses the Spree API to look up deployed contracts. Pass `apiBaseUrl` when needed:

```typescript
import { ContractRegistry } from '@spree-finance/spree-evm-sdk';

const registry = new ContractRegistry({
  apiBaseUrl: 'https://api.stg.spree.finance/api/v1',
});

const factories = await registry.listFactories();
```

### Supported Networks

| Network      | Chain ID | Config                |
| ------------ | -------- | --------------------- |
| Base Sepolia | 84532    | Default               |
| MOCA Devnet  | 5151     | `MOCA_DEVNET_CONFIG`  |
| MOCA Testnet | 222888   | `MOCA_TESTNET_CONFIG` |

### Brand Configuration

Look up contract addresses for a brand:

```typescript
import { getBrandConfig, getContractsForBrand } from '@spree-finance/spree-evm-sdk';

const config = getBrandConfig('spree');
const contracts = getContractsForBrand('spree', 84532n);
```

Available brands: `spree` (root), plus any deployed child brands. Brand IDs are assigned during onboarding.

```typescript
import { getChildBrands } from '@spree-finance/spree-evm-sdk';

const children = getChildBrands('spree'); // child brand IDs
```
