Code Samples
Ready-to-paste examples in 5 languages for the core API flows. No SDK installation required — just the HTTP client of your choice.
Ingest a record
Submit a single record for blockchain anchoring. All examples assume CERTYO_API_KEY is set in your environment.
curl -X POST https://www.certyos.com/api/v1/records \
-H "X-API-Key: $CERTYO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "acme-corp",
"database": "production",
"collection": "orders",
"recordId": "order-12345",
"recordPayload": { "amount": 299.99, "currency": "USD" }
}'const response = await fetch("https://www.certyos.com/api/v1/records", {
method: "POST",
headers: {
"X-API-Key": process.env.CERTYO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
tenantId: "acme-corp",
database: "production",
collection: "orders",
recordId: "order-12345",
recordPayload: { amount: 299.99, currency: "USD" },
}),
});
if (!response.ok) {
throw new Error(`Ingestion failed: ${response.status}`);
}
const result = await response.json();
console.log("Record hash:", result.recordHash);import os
import requests
response = requests.post(
"https://www.certyos.com/api/v1/records",
headers={
"X-API-Key": os.environ["CERTYO_API_KEY"],
"Content-Type": "application/json",
},
json={
"tenantId": "acme-corp",
"database": "production",
"collection": "orders",
"recordId": "order-12345",
"recordPayload": {"amount": 299.99, "currency": "USD"},
},
)
response.raise_for_status()
result = response.json()
print("Record hash:", result["recordHash"])package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload := map[string]interface{}{
"tenantId": "acme-corp",
"database": "production",
"collection": "orders",
"recordId": "order-12345",
"recordPayload": map[string]interface{}{
"amount": 299.99,
"currency": "USD",
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://www.certyos.com/api/v1/records", bytes.NewReader(body))
req.Header.Set("X-API-Key", os.Getenv("CERTYO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println("Record hash:", result["recordHash"])
}using System.Net.Http.Json;
var apiKey = Environment.GetEnvironmentVariable("CERTYO_API_KEY");
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-API-Key", apiKey);
var payload = new
{
tenantId = "acme-corp",
database = "production",
collection = "orders",
recordId = "order-12345",
recordPayload = new { amount = 299.99, currency = "USD" }
};
var response = await http.PostAsJsonAsync(
"https://www.certyos.com/api/v1/records", payload);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<Dictionary<string, object>>();
Console.WriteLine($"Record hash: {result["recordHash"]}");Verify a record
After ~60 seconds (to allow batch accumulation and on-chain confirmation), verify the record by sending the original payload.
curl -X POST https://www.certyos.com/api/v1/verify/record \
-H "X-API-Key: $CERTYO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tenantId": "acme-corp",
"database": "production",
"collection": "orders",
"recordId": "order-12345",
"payload": { "amount": 299.99, "currency": "USD" }
}'const response = await fetch("https://www.certyos.com/api/v1/verify/record", {
method: "POST",
headers: {
"X-API-Key": process.env.CERTYO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
tenantId: "acme-corp",
database: "production",
collection: "orders",
recordId: "order-12345",
payload: { amount: 299.99, currency: "USD" },
}),
});
const result = await response.json();
if (result.verified && result.anchoredOnChain) {
console.log("Record verified on Polygon:", result.onChainProof.polygonScanEventUrl);
} else {
console.error("Verification failed:", result.reasonCategory);
}import os, requests
response = requests.post(
"https://www.certyos.com/api/v1/verify/record",
headers={"X-API-Key": os.environ["CERTYO_API_KEY"]},
json={
"tenantId": "acme-corp",
"database": "production",
"collection": "orders",
"recordId": "order-12345",
"payload": {"amount": 299.99, "currency": "USD"},
},
)
result = response.json()
if result["verified"] and result["anchoredOnChain"]:
print("Verified on Polygon:", result["onChainProof"]["polygonScanEventUrl"])
else:
print("Verification failed:", result.get("reasonCategory"))// Reuse the HTTP client setup from the ingestion example
req, _ := http.NewRequest("POST", "https://www.certyos.com/api/v1/verify/record", bytes.NewReader(body))
req.Header.Set("X-API-Key", os.Getenv("CERTYO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result struct {
Verified bool `json:"verified"`
AnchoredOnChain bool `json:"anchoredOnChain"`
ReasonCategory string `json:"reasonCategory"`
}
json.NewDecoder(resp.Body).Decode(&result)
if result.Verified && result.AnchoredOnChain {
fmt.Println("Record verified on Polygon")
} else {
fmt.Println("Verification failed:", result.ReasonCategory)
}var payload = new
{
tenantId = "acme-corp",
database = "production",
collection = "orders",
recordId = "order-12345",
payload = new { amount = 299.99, currency = "USD" }
};
var response = await http.PostAsJsonAsync(
"https://www.certyos.com/api/v1/verify/record", payload);
var result = await response.Content.ReadFromJsonAsync<JsonElement>();
if (result.GetProperty("verified").GetBoolean() &&
result.GetProperty("anchoredOnChain").GetBoolean())
{
Console.WriteLine("Record verified on Polygon");
}
else
{
Console.WriteLine($"Verification failed: {result.GetProperty("reasonCategory")}");
}Poll for anchoring
Wait for a record to transition from Batched to Anchored before verifying.
# Loop until anchored, max 2 minutes
for i in $(seq 1 24); do
STATUS=$(curl -s "https://www.certyos.com/api/v1/snapshots?tenantId=acme-corp&recordId=order-12345" \
-H "X-API-Key: $CERTYO_API_KEY" \
| jq -r '.items[0].status')
echo "Attempt $i: status=$STATUS"
if [ "$STATUS" = "Anchored" ]; then
echo "Anchored!"
break
fi
sleep 5
doneasync function waitForAnchor(recordId, tenantId, apiKey, maxWaitMs = 120000) {
const start = Date.now();
while (Date.now() - start < maxWaitMs) {
const res = await fetch(
`https://www.certyos.com/api/v1/snapshots?tenantId=${tenantId}&recordId=${recordId}`,
{ headers: { "X-API-Key": apiKey } }
);
const { items } = await res.json();
const snapshot = items[0];
if (snapshot?.status === "Anchored" && snapshot.onChainConfirmed) return snapshot;
if (snapshot?.status === "Failed") throw new Error("Anchoring failed");
await new Promise((r) => setTimeout(r, 5000));
}
throw new Error("Timeout waiting for anchor");
}import time, requests
def wait_for_anchor(record_id, tenant_id, api_key, max_wait=120):
start = time.time()
while time.time() - start < max_wait:
r = requests.get(
f"https://www.certyos.com/api/v1/snapshots",
params={"tenantId": tenant_id, "recordId": record_id},
headers={"X-API-Key": api_key},
)
items = r.json().get("items", [])
if items:
snap = items[0]
if snap["status"] == "Anchored" and snap["onChainConfirmed"]:
return snap
if snap["status"] == "Failed":
raise Exception("Anchoring failed")
time.sleep(5)
raise TimeoutError("Timeout waiting for anchor")