Inbox created
- Forward OTP emails to
fao2zrjgo2yvcar3to@opensurf.io - Worker extracts code and stores for 60s
- Fetch it with a read-once API key
Keys
Inbox key
fao2zrjgo2yvcar3to
API key
DNgAJRX91V1nZjBWq61uV7UPHFp3_UCgv1Nerv1k5KE
TypeScript quickstart
async function fetchCode(key: string, inbox: string, sender = '') {
const url = `https://opensurf.io/inbox/${inbox}/otp?sender=${sender}`;
const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } });
return res.json().catch(() => null);
}
async function waitForCode(key: string, inbox: string, sender = '') {
while (true) {
const code = await fetchCode(key, inbox, sender);
if (code) {
return code;
}
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
const key = 'DNgAJRX91V1nZjBWq61uV7UPHFp3_UCgv1Nerv1k5KE';
const inbox = 'fao2zrjgo2yvcar3to';
console.log('Waiting for code...');
const code = await waitForCode(key, inbox);
console.log(code);