Documentation
Everything you need to integrate console.text() in 30 seconds.
On this page
Quick Start
Get your first SMS alert working in 30 seconds.
1. Get your API key
Visit the homepage and enter your email and phone number to generate your API keys instantly.
2. Install the package
npm install @holler2660/console-text 3. Initialize and use
CommonJS (Node.js)
const { init } = require("@holler2660/console-text");
init({ apiKey: "ct_live_your_key_here" });
// Now anywhere in your code:
console.text("Payment processed!");
ES Modules (TypeScript / Modern JS)
import { init } from '@holler2660/console-text';
init({ apiKey: 'ct_live_your_key_here' });
// Now anywhere in your code:
console.text('Deployment successful!');
✅ That's it! You'll receive an SMS within 5-10 seconds.
API Reference
init(config)
Initialize the console.text() SDK. Call this once at the start of your application.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Yes | Your API key (ct_live_* or ct_test_*) |
| timeout | number | No | Request timeout in milliseconds (default: 5000) |
| retries | number | No | Number of retry attempts (default: 2) |
| debug | boolean | No | Enable debug logging (default: false) |
Example
init({
apiKey: 'ct_live_your_key_here',
timeout: 10000,
retries: 3,
debug: true
});
console.text(message, options?)
Send an SMS alert. Available after calling init().
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | string | Yes | Alert message (max 500 characters, auto-truncated) |
| options | object | No | Additional metadata and severity |
| └ metadata | object | No | Custom data to attach to alert |
| └ severity | 'info' | 'warning' | 'critical' | No | Alert severity level |
Examples
Simple message
console.text('Deploy succeeded!');
With metadata
console.text('Payment failed', {
userId: '123',
amount: 99.99,
error: 'Card declined'
});
With severity
console.text('Database down!', {
severity: 'critical',
metadata: { server: 'prod-1' }
});
🔑 Test vs Live Keys
✓
ct_test_* Logs to console only, no SMS sent ✓
ct_live_* Sends real SMS to your phone Usage Examples
Express.js API
const express = require('express');
const { init } = require('@holler2660/console-text');
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
const app = express();
app.post('/api/payment', async (req, res) => {
try {
// Process payment...
console.text('Payment succeeded!');
} catch (error) {
console.text('Payment failed', { error: error.message });
}
});
Next.js API Route
import { init } from '@holler2660/console-text';
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
export default async function handler(req, res) {
if (req.method === 'POST') {
console.text('New signup!', { email: req.body.email });
res.status(200).json({ success: true });
}
}
Cron Job
const cron = require('node-cron');
const { init } = require('@holler2660/console-text');
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
// Run backup every night at 2am
cron.schedule('0 2 * * *', async () => {
try {
await runBackup();
console.text('Backup completed successfully');
} catch (error) {
console.text('Backup failed!', { severity: 'critical' });
}
});
Deployment Script
const { init } = require('@holler2660/console-text');
const { exec } = require('child_process');
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
exec('git push heroku main', (error, stdout) => {
if (error) {
console.text('Deploy failed!', { severity: 'critical' });
} else {
console.text('Deploy succeeded to production!');
}
});
Serverless Function (Vercel)
import { init } from '@holler2660/console-text';
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
export default async function handler(req, res) {
// Process webhook...
console.text('Stripe webhook received',
type: req.body.type,
amount: req.body.data.amount
);
res.status(200).send('OK');
}
💡 Best Practice: Environment Variables
Never hardcode your API key! Use environment variables:
# .env file
CONSOLE_TEXT_API_KEY=ct_live_your_key_here
// In your code
init({ apiKey: process.env.CONSOLE_TEXT_API_KEY });
Rate Limiting
console.text() automatically prevents spam with built-in rate limiting.
How it works
- • Same message within 5 minutes = sent only once
- • Different messages = each one sends
- • Rate-limited messages are logged but not sent
Bypassing Rate Limits
If you need to send the same message multiple times, add a timestamp or unique ID:
// ❌ Will be rate-limited
console.text('Payment failed');
console.text('Payment failed'); // Won't send
// ✅ Won't be rate-limited
console.text(`Payment failed at $new Date().toISOString()`);
Troubleshooting
SMS not received?
- ✓ Check you're using a
ct_live_*key (notct_test_*) - ✓ Verify your phone number is correct in your account
- ✓ Wait 5-10 seconds (delivery isn't instant)
- ✓ Check if message was rate-limited (same message within 5 min)
Getting API errors?
- ✓ Enable debug mode:
init({ debug: true }) - ✓ Check your API key format (must start with
ct_live_orct_test_) - ✓ Verify you called
init()beforeconsole.text()
Network timeouts?
Increase timeout and retries:
init({
apiKey: 'ct_live_xxx',
timeout: 10000, // 10 seconds
retries: 5
});
Alerts failing silently?
This is by design! Alerting should never crash your app. To debug:
init({ apiKey: 'ct_live_xxx', debug: true });
// Now check console for error messages
Need help?
Can't find what you're looking for? We're here to help!