Configuration
Customize the MsGine SDK to fit your needs.
Basic Configuration
The only required option is your API key:
typescript
import { MsGineClient } from '@msgine/sdk';
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
});Configuration Options
apiKey
Type: string (required)
Your MsGine API key. Get one from the Developer Dashboard.
typescript
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
});WARNING
Never hardcode your API key in source code. Use environment variables instead.
baseUrl
Type: string (optional) Default: https://api.msgine.net/api/v1
Override the API base URL. Useful for staging environments or self-hosted deployments.
typescript
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
baseUrl: 'https://api-staging.msgine.net/api/v1',
});Environment Variables
Store your API key in a .env file:
bash
# .env
MSGINE_API_KEY=your-api-key-hereThen load it in your application:
typescript
import { MsGineClient } from '@msgine/sdk';
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
});TIP
Add .env to your .gitignore to prevent committing secrets to version control.
Environment-Specific Configuration
Production
typescript
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
});Staging / QA
typescript
const client = new MsGineClient({
apiKey: process.env.MSGINE_API_KEY!,
baseUrl: 'https://api-staging.msgine.net/api/v1',
});Testing
typescript
const client = new MsGineClient({
apiKey: 'test-api-key',
baseUrl: 'https://api-test.msgine.net/api/v1',
});TypeScript Config Reference
typescript
interface MsGineClientConfig {
apiKey: string; // Required
baseUrl?: string; // Optional
}Next Steps
- Quick Start - Send your first message
- Sending SMS - Learn how to send SMS
- Error Handling - Handle errors gracefully