A client in a few lines
Each call sends the key in Authorization, JSON in the body, and reads JSON back. A refusal carries code, message, next_action and, when a wait is known, retry_after. Every call of the reference shows its line for the client below, in the language you pick.
// A Blueping client in a few lines: any HTTP library works the same way.
const API = "https://blueping.dev/v1";
const KEY = process.env.BLUEPING_API_KEY;
export async function blueping(method, path, body, idempotencyKey) {
const response = await fetch(API + path, {
method,
headers: {
Authorization: `Bearer ${KEY}`,
"Content-Type": "application/json",
...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
},
body: body ? JSON.stringify(body) : undefined,
});
const answer = await response.json();
// A refusal says what to do next: hand next_action to your agent.
if (answer.error) throw Object.assign(new Error(answer.error.message), answer.error);
return answer;
}
const { code, link } = await blueping("GET", "/inboxes/inb_.../code?wait=50&from=service.example");# A Blueping client in a few lines: any HTTP library works the same way.
import json, os, urllib.error, urllib.request
API = "https://blueping.dev/v1"
KEY = os.environ["BLUEPING_API_KEY"]
class BluepingError(Exception):
def __init__(self, error):
super().__init__(error["message"])
self.code, self.next_action = error["code"], error["next_action"]
self.retry_after = error.get("retry_after")
def blueping(method, path, body=None, idempotency_key=None):
# A User-Agent of your own: the site's firewall refuses urllib's default one.
headers = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json", "User-Agent": "my-agent/1.0"}
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
data = json.dumps(body).encode() if body is not None else None
request = urllib.request.Request(API + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(request, timeout=90) as response:
return json.load(response)
except urllib.error.HTTPError as error:
raise BluepingError(json.load(error)["error"])
found = blueping("GET", "/inboxes/inb_.../code?wait=50&from=service.example")
print(found["code"], found["link"])// A Blueping client in a few lines, with Go's standard library.
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
)
const api = "https://blueping.dev/v1"
// blueping sends body, JSON or "", and returns the answer. A refusal is an error that says what to do next.
func blueping(method, path, body string, idempotencyKey ...string) (map[string]any, error) {
request, err := http.NewRequest(method, api+path, strings.NewReader(body))
if err != nil {
return nil, err
}
request.Header.Set("Authorization", "Bearer "+os.Getenv("BLUEPING_API_KEY"))
request.Header.Set("Content-Type", "application/json")
request.Header.Set("User-Agent", "my-agent/1.0")
if len(idempotencyKey) > 0 {
request.Header.Set("Idempotency-Key", idempotencyKey[0])
}
response, err := http.DefaultClient.Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
raw, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
answer := map[string]any{}
if len(raw) > 0 {
if err := json.Unmarshal(raw, &answer); err != nil {
return nil, err
}
}
if refusal, ok := answer["error"].(map[string]any); ok {
return nil, fmt.Errorf("%v: %v", refusal["code"], refusal["next_action"])
}
return answer, nil
}
func main() {
found, err := blueping("GET", "/inboxes/inb_.../code?wait=50&from=service.example", "")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(found["code"], found["link"])
}# A Blueping client in a few lines, with Ruby's standard library.
require "json"
require "net/http"
API = "https://blueping.dev/v1"
class BluepingError < StandardError
attr_reader :code, :next_action, :retry_after
def initialize(error)
super(error["message"])
@code, @next_action, @retry_after = error["code"], error["next_action"], error["retry_after"]
end
end
def blueping(method, path, body = nil, idempotency_key: nil)
uri = URI("#{API}#{path}")
request = Net::HTTPGenericRequest.new(method, !body.nil?, true, uri)
request["Authorization"] = "Bearer #{ENV.fetch("BLUEPING_API_KEY")}"
request["Content-Type"] = "application/json"
request["User-Agent"] = "my-agent/1.0"
request["Idempotency-Key"] = idempotency_key if idempotency_key
request.body = JSON.generate(body) unless body.nil?
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", read_timeout: 90) { |http| http.request(request) }
answer = response.body.to_s.empty? ? {} : JSON.parse(response.body)
# A refusal says what to do next: hand next_action to your agent.
raise BluepingError, answer["error"] if answer["error"]
answer
end
found = blueping("GET", "/inboxes/inb_.../code?wait=50&from=service.example")
puts found["code"], found["link"]<?php
// A Blueping client in a few lines, with PHP's curl extension.
const API = "https://blueping.dev/v1";
function blueping(string $method, string $path, $body = null, ?string $idempotencyKey = null): array
{
$headers = ["Authorization: Bearer " . getenv("BLUEPING_API_KEY"), "Content-Type: application/json"];
if ($idempotencyKey !== null) {
$headers[] = "Idempotency-Key: " . $idempotencyKey;
}
$curl = curl_init(API . $path);
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_USERAGENT => "my-agent/1.0",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 90,
]);
if ($body !== null) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
}
$answer = json_decode(curl_exec($curl) ?: "{}", true) ?? [];
if (isset($answer["error"])) {
// A refusal says what to do next: hand next_action to your agent.
throw new RuntimeException($answer["error"]["code"] . ": " . $answer["error"]["next_action"]);
}
return $answer;
}
$found = blueping("GET", "/inboxes/inb_.../code?wait=50&from=service.example");
echo $found["code"], " ", $found["link"] ?? "", "\n";// A Blueping client in a few lines, with the JDK's HttpClient. Java 17 or later.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Blueping {
static final String API = "https://blueping.dev/v1";
static final HttpClient HTTP = HttpClient.newHttpClient();
// body is JSON, or null. The answer is JSON; a refusal throws with its code and next_action.
static String call(String method, String path, String body, String idempotencyKey) throws Exception {
var request = HttpRequest.newBuilder(URI.create(API + path))
.header("Authorization", "Bearer " + System.getenv("BLUEPING_API_KEY"))
.header("Content-Type", "application/json")
.header("User-Agent", "my-agent/1.0")
.timeout(Duration.ofSeconds(90))
.method(method, body == null ? HttpRequest.BodyPublishers.noBody() : HttpRequest.BodyPublishers.ofString(body));
if (idempotencyKey != null) request.header("Idempotency-Key", idempotencyKey);
var response = HTTP.send(request.build(), HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) throw new IllegalStateException(response.body());
return response.body();
}
static String call(String method, String path, String body) throws Exception {
return call(method, path, body, null);
}
public static void main(String[] args) throws Exception {
System.out.println(call("GET", "/inboxes/inb_.../code?wait=50&from=service.example", null));
}
}// A Blueping client in a few lines, with .NET's HttpClient. C# 11 or later.
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Console.WriteLine(await Blueping.Call("GET", "/inboxes/inb_.../code?wait=50&from=service.example"));
static class Blueping
{
const string Api = "https://blueping.dev/v1";
static readonly HttpClient Http = new() { Timeout = TimeSpan.FromSeconds(90) };
// body is JSON, or null. The answer is JSON; a refusal throws with its code and next_action.
public static async Task<string> Call(string method, string path, string? body = null, string? idempotencyKey = null)
{
using var request = new HttpRequestMessage(new HttpMethod(method), Api + path);
request.Headers.Add("Authorization", "Bearer " + Environment.GetEnvironmentVariable("BLUEPING_API_KEY"));
request.Headers.Add("User-Agent", "my-agent/1.0");
if (idempotencyKey != null) request.Headers.Add("Idempotency-Key", idempotencyKey);
if (body != null) request.Content = new StringContent(body, Encoding.UTF8, "application/json");
using var response = await Http.SendAsync(request);
var answer = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new HttpRequestException(answer);
return answer;
}
}Send an Idempotency-Key with each send, such as your own id for the message: a retry after a timeout then returns the first answer instead of sending twice.
Agent frameworks and automation
Each framework and platform below has a guide with its setup and a first agent, in its own words:
- LangChain and LangGraph: Give a LangChain or LangGraph agent its own email inbox: five @tool functions over Blueping's API, then create_agent signs up, reads codes and replies.
- OpenAI Agents SDK: Attach Blueping's hosted MCP server to an OpenAI Agents SDK agent with MCPServerStreamableHttp: its 10 core email tools, with your key in the header.
- Claude Agent SDK: Give a Claude Agent SDK agent its own inbox: Blueping's hosted MCP server in mcp_servers with your key, its tools allowed as mcp__blueping__*.
- Google ADK: Give a Google Agent Development Kit agent its own inbox: Blueping's hosted MCP server as an McpToolset with your key, then try it with adk run or adk web.
- Vercel AI SDK: Give a Vercel AI SDK agent an email inbox: tool() definitions over Blueping's API, a zod schema each, and generateText with a step limit.
- CrewAI: Give each CrewAI agent its own email address: @tool functions over Blueping's API, per role, so a crew emails vendors, customers and each other.
- Mastra: Give a Mastra agent its own email inbox: createTool definitions over Blueping's API, with zod schemas, in the agent's tools.
- LlamaIndex: Give a LlamaIndex FunctionAgent its own email inbox: five plain Python functions over Blueping's API, read as tools from their type hints.
- Pydantic AI: Give a Pydantic AI agent an email inbox: Blueping's hosted MCP server as an MCPToolset with your key, passed in toolsets, then run the agent.
- n8n: Give an n8n workflow its own email inbox: a Webhook node runs on each email, an AI Agent node decides, and an HTTP Request node replies in the thread.
- Zapier: Run a Zap on every email your agent's inbox receives: Webhooks by Zapier catches it, your steps decide, and a POST answers in the same thread.
- Make: Start a Make scenario on every email your agent receives: a custom webhook catches it, your modules decide, and the HTTP app replies in the thread.
- Pipedream: Run a Pipedream workflow on every email your agent receives: the HTTP trigger catches it, and a Node.js step replies in the thread with fetch.
MCP clients such as Claude Code, Cursor or ChatGPT connect without code: Connect over MCP.
A typed client from OpenAPI
/openapi.json is OpenAPI 3.1, made from the same route table as the API itself: every endpoint, schema, example and error. Generators such as openapi-typescript or openapi-python-client turn it into types or a client.
curl -sS https://blueping.dev/openapi.json -o blueping.openapi.json
npx openapi-typescript blueping.openapi.json -o blueping.d.tsOr no code at all
An agent with MCP needs no client: the hosted MCP server carries the same calls as tools, with OAuth or a key. Connect over MCP has the line for each client.