Send your first fax through the API.

Follow working C# and JavaScript examples for private uploads, server-priced fax quotes, idempotent sending, and delivery tracking.

Test both connections in your browser

  1. Open Developer settings and sign in with a verified account.
  2. Choose Create a read-only test key, then Test API connection. A successful response shows your balance.
  3. Choose Test MCP in the browser, then Connect and test. Approve the read-only request to see the protocol version, tool list, and balance.

Send a standard test fax

  1. Complete MFA and create a key with fax.quote, fax.send, and fax.status. Use an eligible credit or business page allowance and a number you control.
  2. Put the key in TIDYFAX_API_KEY on your server. Provide an authorized test PDF at document.pdf and set TIDYFAX_DESTINATION to a number you can send to.
  3. Run the sample to create a draft and quote. Review and approve the quote in the account. Use the authorization session required for your account.
  4. Set TIDYFAX_QUOTE_ID and a unique TIDYFAX_REQUEST_KEY, then run the same sample to submit. Preserve the key if you need to retry.

JavaScript (Node 22+)

import { readFile } from "node:fs/promises";

const base = "https://tidyfax.com/api/v1";
const auth = { Authorization: `Bearer ${process.env.TIDYFAX_API_KEY}` };
async function call(path, options = {}) {
  const response = await fetch(base + path, {
    ...options, headers: { ...auth, ...options.headers }
  });
  const data = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(data));
  return data;
}
const json = (value, headers = {}) => ({
  method: "POST",
  headers: { "Content-Type": "application/json", ...headers },
  body: JSON.stringify(value)
});
if (!process.env.TIDYFAX_QUOTE_ID) {
  const form = new FormData();
  form.append("file", new Blob([await readFile("document.pdf")]), "document.pdf");
  const draft = await call("/documents", { method: "POST", body: form });
  const quote = await call("/faxes/quotes", json({
    documentId: draft.id, destination: process.env.TIDYFAX_DESTINATION
  }));
  console.log(quote);
} else {
  const fax = await call("/faxes", json({ quoteId: process.env.TIDYFAX_QUOTE_ID },
    { "Idempotency-Key": process.env.TIDYFAX_REQUEST_KEY }));
  console.log(await call("/faxes/" + fax.id));
}

C# (.NET 10)

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

using var client = new HttpClient { BaseAddress = new("https://tidyfax.com/api/v1/") };
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
    "Bearer", Environment.GetEnvironmentVariable("TIDYFAX_API_KEY"));
var quoteId = Environment.GetEnvironmentVariable("TIDYFAX_QUOTE_ID");
if (string.IsNullOrEmpty(quoteId))
{
    using var form = new MultipartFormDataContent();
    form.Add(new StreamContent(File.OpenRead("document.pdf")), "file", "document.pdf");
    using var upload = await client.PostAsync("documents", form);
    upload.EnsureSuccessStatusCode();
    var draft = await upload.Content.ReadFromJsonAsync<JsonElement>();
    using var quote = await client.PostAsJsonAsync("faxes/quotes", new {
        documentId = draft.GetProperty("id").GetGuid(),
        destination = Environment.GetEnvironmentVariable("TIDYFAX_DESTINATION")
    });
    Console.WriteLine(await quote.Content.ReadAsStringAsync());
    quote.EnsureSuccessStatusCode();
}
else
{
    using var request = new HttpRequestMessage(HttpMethod.Post, "faxes");
    request.Headers.Add("Idempotency-Key",
        Environment.GetEnvironmentVariable("TIDYFAX_REQUEST_KEY")
            ?? throw new InvalidOperationException("Set TIDYFAX_REQUEST_KEY."));
    request.Content = JsonContent.Create(new { quoteId });
    using var response = await client.SendAsync(request);
    if (!response.IsSuccessStatusCode)
        Console.WriteLine(await response.Content.ReadAsStringAsync());
    response.EnsureSuccessStatusCode();
    var fax = await response.Content.ReadFromJsonAsync<JsonElement>();
    Console.WriteLine(await client.GetStringAsync("faxes/" + fax.GetProperty("id").GetGuid()));
}

Read authentication, error, and retry guidance or inspect the API contract.