OwlRelay API SDK for JavaScript and TypeScript
npm install @owlrelay/api-sdkThis package is a TypeScript SDK for the OwlRelay API.
You'll need an OwlRelay api key to use the SDK. You can get one by creating an account on OwlRelay and then creating an api key from the OwlRelay api key page.
``bash`
pnpm install @owlrelay/api-sdkor
npm install @owlrelay/api-sdkor
yarn add @owlrelay/api-sdk
`ts
import { createClient } from '@owlrelay/api-sdk';
const client = createClient({ apiKey: 'your-owlrelay-api-key' });
const createdEmail = await client.createEmail({
username: 'john.doe',
webhookUrl: 'https://my-app.invalid/webhook',
webhookSecret: 'my-webhook-secret',
});
console.log(createdEmail);
`
Create a new email address that will forward emails to a webhook.
`ts
const createdEmail = await client.createEmail({
// The username of the email address.
username: 'john.doe',
// The domain of the email address.
// optional, defaults to 'callback.email'
domain: 'callback.email',
// Your webhook url.
webhookUrl: 'https://my-app.invalid/webhook',
// The webhook secret is used to HMAC-SHA256 sign the webhook request.
// optional, defaults to a random secret
webhookSecret: 'my-webhook-secret',
// The allowed addresses that are allowed to trigger the webhook.
// optional, defaults to [] (all addresses)
allowedOrigins: ['foo@bar.com'],
});
console.log(createdEmail);
`
Get all email addresses that you have created.
`ts
const emails = await client.getEmails();
console.log(emails);
`
Get an email address by its id.
`ts`
const email = await client.getEmail({ emailId: '...' });
Get all processings for an email address.
`ts`
const processings = await client.getEmailProcessings({ emailId: '...' });
Disable an email address. This will stop the email address from forwarding emails to your webhook.
`ts`
const disabledEmail = await client.disableEmail({ emailId: '...' });
Enable an email address.
`ts`
const enabledEmail = await client.enableEmail({ emailId: '...' });
Delete an email address.
`ts``
const deletedEmail = await client.deleteEmail({ emailId: '...' });
This library is licensed under the AGPL-3.0 License. See the LICENSE file for details.
This project is crafted with ❤️ by Corentin Thomasset.
If you find this project helpful, please consider supporting my work.