Class SendByteClient

java.lang.Object
africa.sendbyte.SendByteClient
All Implemented Interfaces:
AutoCloseable

public final class SendByteClient extends Object implements AutoCloseable
The entry point to the SendByte API.

Create one client for the lifetime of your application and reuse it; it is thread-safe. Resources are reached through accessor methods:


 SendByteClient client = new SendByteClient(System.getenv("SENDBYTE_API_KEY"));

 Email email = client.emails().send(
     SendEmailRequest.builder()
         .from("PayLink <receipts@paylink.ng>")
         .to("amaka@halo.ng")
         .subject("Receipt for ₦45,000")
         .html("<p>Payment received.</p>")
         .build());

 System.out.println(email.getId());
 

Use a sk_test_ key while developing and a sk_live_ key in production. Call close() on shutdown to release the HTTP connection pool.

  • Constructor Details

    • SendByteClient

      public SendByteClient(String apiKey)
      Create a client with the given API key and default configuration.
    • SendByteClient

      public SendByteClient(SendByteClientOptions options)
      Create a client from a full options object.
    • SendByteClient

      public SendByteClient(HttpTransport transport)
      Create a client over a custom HttpTransport. Primarily used by tests to inject a stub transport, but also allows swapping the HTTP layer entirely.
  • Method Details

    • emails

      public Emails emails()
      Access the Emails resource: send, retrieve, and list transactional emails.
    • domains

      public Domains domains()
      Access the Domains resource: register, retrieve, list, and verify sending domains.
    • templates

      public Templates templates()
      Access the Templates resource: manage and preview reusable email templates.
    • webhooks

      public Webhooks webhooks()
      Access the Webhooks resource: manage endpoints, inspect deliveries, and replay them.
    • apiKeys

      public ApiKeys apiKeys()
      Access the API Keys resource: create, list, and revoke scoped keys.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable