# Bruno Setup
> Source: /api-reference/introduction/bruno-setup
> Configure Bruno API client for Journey API testing

# Bruno Setup Guide

Bruno is the recommended API client for testing Journey API endpoints.

## Installation [#installation]

<Tabs>
  <Tab title="macOS">
    ```bash
    brew install bruno
    ```
  </Tab>
  <Tab title="Windows">
    Download from [Bruno Downloads](https://www.usebruno.com/downloads)
  </Tab>
  <Tab title="Linux">
    ```bash
    snap install bruno
    ```
  </Tab>
</Tabs>

## Repository Setup [#repository-setup]

```bash
# Clone the Journey API repository
git clone https://github.com/Journey-Rewards/api.git
cd api

# Open Bruno with the collection
bruno open bruno/
```

## Collection Structure [#collection-structure]

```
bruno/
├── Members (Surface)/
│   ├── Auth/
│   ├── Me/
│   ├── Properties/
│   └── Reservations/
├── Admin/
│   ├── Auth/
│   ├── Members/
│   └── Reservations/
├── Public (Surface)/
│   ├── Properties/
│   └── Reservations/
└── environments/
    ├── local.bru
    ├── development.bru
    └── production.bru
```

## Environment Configuration [#environment-configuration]

### 1. Select Environment [#1-select-environment]

Choose the appropriate environment in Bruno:
- **Local**: `http://localhost:3000`
- **Development**: `https://api-dev.cf.journey.com/v1`
- **Production**: `https://api-prd.cf.journey.com/v1`

### 2. Get a Members Token (Dev) [#2-get-a-members-token-dev]

The Members API authenticates via Clerk. To get a token in the development environment:

1. Open the **Members (Surface) → Auth → Login** request in Bruno
2. Enter a test phone number — use any **555 area code number ending in `01xx`**, e.g. `+15550010100`
3. Clerk will send an OTP to the number (test numbers are handled automatically in dev)
4. Complete the OTP step — Bruno will store the resulting Clerk JWT in `CLERK_TOKEN`

<Note>
  555 numbers ending in `01xx` (`+1555XXX0100` through `+1555XXX0199`) are Clerk test numbers. No real SMS is sent — the OTP completes automatically in the dev Clerk environment.
</Note>

### 3. Set Admin Token (WorkOS) [#3-set-admin-token-workos]

```javascript
// In environment variables
WORKOS_TOKEN = "your-workos-jwt-token"
```

## Example Requests [#example-requests]

### Members Profile Request [#members-profile-request]

File: `bruno/Members (Surface)/Me/Profile/Get Me.bru`

```http
GET {{BASE_URL}}/members/me
Authorization: Bearer {{CLERK_TOKEN}}
```

### Admin Member Query [#admin-member-query]

File: `bruno/Admin/Members/Query Members.bru`

```http
POST {{BASE_URL}}/admin/members/query
Authorization: Bearer {{WORKOS_TOKEN}}
Content-Type: application/json

{
  "limit": 10,
  "offset": 0,
  "filters": {
    "status": "active"
  }
}
```

### Public Property Request [#public-property-request]

File: `bruno/Public (Surface)/Properties/Get Property.bru`

```http
GET {{BASE_URL}}/public/properties/{{PROPERTY_ID}}
```

## Testing Workflows [#testing-workflows]

### 1. Member Onboarding Flow [#1-member-onboarding-flow]

1. Run `Members (Surface)/Auth/Validate.bru`
2. Run `Members (Surface)/Me/Update Me.bru`
3. Run `Members (Surface)/Me/Profile/Update Profile.bru`

### 2. Property Search Flow [#2-property-search-flow]

1. Run `Members (Surface)/Properties/Search.bru`
2. Run `Members (Surface)/Properties/Get Property.bru`
3. Run `Members (Surface)/Properties/Availability.bru`

### 3. Admin Operations [#3-admin-operations]

1. Run `Admin/Auth/WorkOS Callback.bru`
2. Run `Admin/Members/Query.bru`
3. Run `Admin/Members/Gift Points.bru`

## Assertions and Tests [#assertions-and-tests]

Bruno supports JavaScript-based assertions:

```javascript
// In Tests tab
test("Status is 200", () => {
  expect(res.status).to.equal(200);
});

test("Member has external ID", () => {
  expect(res.body.member.externalId).to.exist;
});

test("Response time under 500ms", () => {
  expect(res.responseTime).to.be.below(500);
});
```

## Tips [#tips]

1. **Use environment variables** for sensitive data
2. **Save responses** to variables for chaining requests
3. **Create folders** for organizing test scenarios
4. **Use pre-request scripts** for dynamic data
5. **Export/import** collections for team sharing

## Troubleshooting [#troubleshooting]

| Issue | Solution |
|-------|----------|
| 401 Unauthorized | Check token in environment variables |
| 404 Not Found | Verify endpoint URL and parameters |
| Connection refused | Ensure API server is running |
| CORS errors | Use Bruno instead of browser |
