Spendesk Integration Development

This guide covers developing and testing the Spendesk integration for Billy.

Overview

Spendesk integration allows Billy to:
  • Handle expense management and reimbursement
  • Process payment requests
  • Manage corporate cards and spending limits
  • Integrate with accounting workflows
  • Handle OAuth authentication

Development Setup

1. OAuth Configuration

Spendesk has specific requirements for OAuth development that differ from other integrations.

2. Port Configuration

Important: Spendesk does not allow ports in redirect URIs. You must configure your development environment to run on HTTPS without a port.
# Set port to 443 for HTTPS (required for Spendesk)
PORT=443
This will make your app run on https://localhost instead of http://localhost:3000.

3. Environment Configuration

Add these variables to your .env.local:
# Spendesk [Dev]
SPENDESK_REDIRECT_URI=https://localhost/oauth/spendesk/redirect_uri
SPENDESK_CLIENT_ID=YOUR_CLIENT_ID
SPENDESK_CLIENT_SECRET=YOUR_CLIENT_SECRET
SPENDESK_API_URL=https://api.spendesk.com

Development Workflow

1. Start Development Server

# Set port for Spendesk compatibility
PORT=443 pnpm dev

# Or set environment variable
export PORT=443
pnpm dev

2. Test OAuth Flow

  1. Navigate to Spendesk integration setup
  2. Complete the OAuth authorization
  3. Verify redirect works correctly on https://localhost
  4. Check token exchange and API access

3. Test API Integration

# Test Spendesk API connection
pnpm tsx scripts/spendesk/test-sdk.ts