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

# Merchants

> Manage merchant accounts and NMI connections

# Merchants API

## List Merchants

```bash theme={null}
GET /api/merchants
```

## Create Merchant

```bash theme={null}
POST /api/merchants
```

```json theme={null}
{
  "name": "Acme Corp",
  "legalName": "Acme Corporation LLC",
  "email": "billing@acme.com",
  "phone": "+1 555-0100",
  "website": "https://acme.com",
  "industry": "Technology"
}
```

## Get Merchant

```bash theme={null}
GET /api/merchants/:id
```

## Update Merchant

```bash theme={null}
PATCH /api/merchants/:id
```

## Delete Merchant

```bash theme={null}
DELETE /api/merchants/:id
```

```json theme={null}
{
  "retention": "immediate"
}
```

Retention options: `immediate` (delete now), `30days`, `90days` (soft delete with cleanup).

## NMI Credentials

### Test Connection

```bash theme={null}
POST /api/nmi/test-connection
```

```json theme={null}
{
  "apiKey": "your_private_key",
  "gatewayUrl": "https://secure.nmi.com"
}
```

Validates the API key and returns the merchant profile from NMI.

### Save Credentials

```bash theme={null}
POST /api/nmi/credentials
```

```json theme={null}
{
  "merchantId": "clx...",
  "name": "Production Gateway",
  "apiKey": "your_private_key",
  "tokenizationKey": "your_tokenization_key",
  "gatewayUrl": "https://secure.nmi.com"
}
```

API keys are encrypted with AES-256-GCM before storage.

### Trigger Sync

```bash theme={null}
POST /api/nmi/sync
```

```json theme={null}
{
  "nmiAccountId": "clx..."
}
```
