0.0.2 • Published 7 months ago

@owlrelay/api-sdk v0.0.2

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
7 months ago

OwlRelay API SDK

This package is a TypeScript SDK for the OwlRelay API.

Prerequisites

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.

Installation

pnpm install @owlrelay/api-sdk
# or
npm install @owlrelay/api-sdk
# or
yarn add @owlrelay/api-sdk

Usage

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);

API Reference

createEmail

Create a new email address that will forward emails to a webhook.

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);

getEmails

Get all email addresses that you have created.

const emails = await client.getEmails();

console.log(emails);

getEmail

Get an email address by its id.

const email = await client.getEmail({ emailId: '...' });

getEmailProcessings

Get all processings for an email address.

const processings = await client.getEmailProcessings({ emailId: '...' });

disableEmail

Disable an email address. This will stop the email address from forwarding emails to your webhook.

const disabledEmail = await client.disableEmail({ emailId: '...' });

enableEmail

Enable an email address.

const enabledEmail = await client.enableEmail({ emailId: '...' });

deleteEmail

Delete an email address.

const deletedEmail = await client.deleteEmail({ emailId: '...' });

License

This library is licensed under the AGPL-3.0 License. See the LICENSE file for details.

Credits

This project is crafted with ❤️ by Corentin Thomasset. If you find this project helpful, please consider supporting my work.

0.0.2

7 months ago

0.0.1

8 months ago