Florentin

API-Referenz

Die Florentin API ist REST-basiert. Alle Anfragen und Antworten verwenden JSON. Die Authentifizierung erfolgt über einen API-Key im Authorization-Header.

Base URL

Bash — Produktion
https://api.florentin.io/v1

Authentifizierung

Alle API-Anfragen benötigen einen gültigen API-Key im Authorization-Header:

Bash
Authorization: Bearer sk_live_...

Kunden

Erstelle und verwalte Kundendaten für die Abrechnung.

Kunden erstellen

POST /v1/customers

customer = client.customers.create( email="user@example.com",
name="Acme Inc.", metadata={"plan": "pro"} ) print(f"Erstellt: {customer.id}")
const customer = await client.customers.create({ email: "user@example.com", name:
"Acme Inc.", metadata: { plan: "pro" } }); console.log(`Erstellt: ${customer.id}`);
customer, err := client.Customers.Create(ctx, &florentin.CustomerParams{ Email:
"user@example.com", Name: "Acme Inc.", Metadata: map[string]string{ "plan": "pro", }, })
fmt.Printf("Erstellt: %s
", customer.ID)

Kunden auflisten

GET /v1/customers

customers = client.customers.list(limit=10) for customer in
customers: print(f"{customer.id}: {customer.name}")
const customers = await
client.customers.list({ limit: 10 }); for (const customer of customers.data) {
console.log(`${customer.id}: ${customer.name}`); }
customers, err :=
client.Customers.List(ctx, &florentin.ListParams{ Limit: 10, }) for _, customer := range
customers.Data { fmt.Printf("%s: %s
", customer.ID, customer.Name) }

Nutzungsverfolgung

Erfasse und frage Nutzungsdaten für nutzungsbasierte Abrechnung ab.

Nutzung erfassen

POST /v1/usage

usage = client.usage.record( customer_id="cust_123",
product_id="prod_api", quantity=1500, unit="tokens" )
const usage = await
client.usage.record({ customerId: "cust_123", productId: "prod_api", quantity: 1500, unit: "tokens"
});
usage, err := client.Usage.Record(ctx, &florentin.UsageParams{ CustomerID:
"cust_123", ProductID: "prod_api", Quantity: 1500, Unit: "tokens", })

Nutzung abfragen

GET /v1/usage?customer_id=cust_123

summary = client.usage.summary( customer_id="cust_123",
start_date="2026-01-01", end_date="2026-01-31" ) print(f"Gesamt: {summary.total_quantity}
{summary.unit}")
const summary = await client.usage.summary({ customerId:
"cust_123", startDate: "2026-01-01", endDate: "2026-01-31" }); console.log(`Gesamt:
${summary.totalQuantity} ${summary.unit}`);
summary, err := client.Usage.Summary(ctx,
&florentin.UsageSummaryParams{ CustomerID: "cust_123", StartDate: "2026-01-01", EndDate:
"2026-01-31", }) fmt.Printf("Gesamt: %d %s
", summary.TotalQuantity, summary.Unit)

Fehlerbehandlung

Die API verwendet Standard-HTTP-Statuscodes. Fehler geben einen JSON-Body mit error- und message-Feldern zurück:

JSON — Fehlerantwort
{ "error": "invalid_request", "message": "customer_id is required" }