Connect to the Revdoku API with C# and .NET

Create a private bucket with its own email address using the .NET 8+ SDK and HttpClient. No additional NuGet package is needed.

API overview · JavaScript example · Python example

1. Get an API key

Sign in to Revdoku, then open Account → Access and choose Add connection → Create API key. Named API keys require a paid plan. For this example, choose bucket_admin permission and access to all buckets in the account where you want to create the inbox.

Set REVDOKU_API_KEY privately in the terminal where you will run the example, or through your secret manager. On macOS or Linux, enter the key at the hidden prompt:

printf 'Revdoku API key: '
read -r -s REVDOKU_API_KEY
export REVDOKU_API_KEY
printf '\n'

For PowerShell 7:

$env:REVDOKU_API_KEY = Read-Host "Revdoku API key" -MaskInput

Run the code on your machine or server. Keep the key out of browser code, shared files, and source control.

2. Create a console project

dotnet new console -n RevdokuInbox

Replace RevdokuInbox/Program.cs with this complete example. It sends one authenticated request and prints the bucket ID, email address, receiving state, and dashboard link.

using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

var apiKey = Environment.GetEnvironmentVariable("REVDOKU_API_KEY") // Get a key at https://app.revdoku.com/account/access
    ?? throw new Exception("Set REVDOKU_API_KEY first");
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);
using var response = await client.PostAsJsonAsync(
    "https://app.revdoku.com/api/v1/buckets",
    new { bucket = new { title = "My agent inbox" } });
response.EnsureSuccessStatusCode();
using var json = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
var bucket = json.RootElement.GetProperty("data").GetProperty("bucket");
var inbox = bucket.GetProperty("inbound_email");
Console.WriteLine($"Bucket ID: {bucket.GetProperty("id").GetString()}");
Console.WriteLine($"Email: {inbox.GetProperty("address").GetString()}");
Console.WriteLine($"Ready: {inbox.GetProperty("ready").GetBoolean()}");
Console.WriteLine($"Open: {bucket.GetProperty("dashboard_url").GetString()}");
if (!inbox.GetProperty("ready").GetBoolean())
    Console.WriteLine($"Receiving: {inbox.GetProperty("blocked_reason").GetString()}");

3. Run the example

From the terminal where you set REVDOKU_API_KEY, run:

dotnet run --project RevdokuInbox

Each run creates a new private bucket. Save the returned bucket ID and reuse it for later requests. The key’s default account is used; see account selection when working across accounts.

4. Receive and read an email

When Ready is true, send a test email from your normal email account to the printed address. If it is false, check Receiving for the reason and inspect the existing bucket’s receiving state. New addresses can take up to five minutes to activate; rerunning this script creates another bucket.

Follow the send and read walkthrough using the bucket ID printed by this example. Incoming messages are stored as JSON and Markdown alongside their attachments. The dashboard link lets authorized people review them in Revdoku.

For authentication and permission failures, see troubleshooting. For all operations, see the API reference.

Markdown version
↧
Loading PDF…