Typed Data API
Create databases, repositories, schemas, and documents, then query with TQL through one public API.
A typed document database with asynchronous replication across São Paulo and San Jose. The global endpoint routes to the nearest healthy region selected by your project. Public Alpha has no uptime percentage or SLA.
First-class C# and TypeScript SDKs target the same public HTTP routes used by the dashboard, with generated OpenAPI models underneath.
using System.Net.Http.Headers;
using System.Net.Http.Json;
// Server-side: TERRABASE_API_KEY holds a tb_ key.
// Supply a resolver and trusted origins from server configuration.
// The override skips discovery.
static class DocumentsExample
{
private static readonly HttpClient Http = new(new SocketsHttpHandler {
AllowAutoRedirect = false,
PooledConnectionLifetime = TimeSpan.FromMinutes(5)
});
public static async Task<string> CreateAndQueryCustomers(
Func<CancellationToken, Task<Uri>> resolveRegion, IReadOnlyCollection<Uri> trustedOrigins,
string project, string database, string collection, Uri? staticOrigin = null,
CancellationToken cancellationToken = default)
{
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
deadline.CancelAfter(TimeSpan.FromSeconds(30));
var token = deadline.Token;
token.ThrowIfCancellationRequested();
var origin = staticOrigin ?? await resolveRegion(token).WaitAsync(token);
if (!origin.IsAbsoluteUri || origin.Scheme != Uri.UriSchemeHttps ||
origin.UserInfo.Length != 0 || origin.AbsolutePath != "/" ||
origin.Query.Length != 0 || origin.Fragment.Length != 0 ||
!trustedOrigins.Contains(origin))
throw new ArgumentException("Expected a trusted HTTPS origin");
if (new[] { project, database, collection }.Any(name =>
string.IsNullOrEmpty(name) || name == "." || name == ".."))
throw new ArgumentException("Resource names are required");
var apiKey = Environment.GetEnvironmentVariable("TERRABASE_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
throw new InvalidOperationException("TERRABASE_API_KEY is required");
var path = "/v1/projects/" + Uri.EscapeDataString(project) +
"/databases/" + Uri.EscapeDataString(database) +
"/collections/" + Uri.EscapeDataString(collection);
using var create = new HttpRequestMessage(HttpMethod.Post, new Uri(origin, path + "/documents"));
create.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
create.Content = JsonContent.Create(new { email = "[email protected]", plan = "pro" });
using (var created = await Http.SendAsync(create, HttpCompletionOption.ResponseHeadersRead, token))
created.EnsureSuccessStatusCode();
using var request = new HttpRequestMessage(HttpMethod.Post, new Uri(origin, path + "/query"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = JsonContent.Create(new {
filter = new { eq = new[] { "/plan", "pro" } },
limit = 25
});
using var response = await Http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync(token);
}
}The launch contract covers document data, two selectable regions, typed clients, and customer-visible health without an uptime commitment.
Create databases, repositories, schemas, and documents, then query with TQL through one public API.
The global endpoint chooses the nearest healthy selected region. Strict regional endpoints never serve from an unselected region.
Choose São Paulo or San Jose during Public Alpha.
Replication health, convergence, conflicts, API latency, and geographic latency estimates remain separate values. Customer content stays in selected regions. Customer traffic requires TLS 1.2 or newer, data at rest uses qualified encryption, and every request still requires authorization.
Starter and Pro have one eligible 30-day trial per verified payment method and organization.