Projects¶
Projects group usage, customers, pricing, and reporting for an application or product area.
When To Use This¶
Create a project before creating customers or logging customer usage. Use external IDs when your application already has a stable project identifier.
Example¶
curl "$SPENDWARE_BASE_URL/api/v1/projects/" \
-H "Authorization: Bearer $SPENDWARE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: project:acme-ai" \
-d '{"title":"Acme AI","currency":"USD","external_id":"acme-ai"}'
from spendware_provider_sdk.management import ProjectCreate, SpendwareManagementClient
client = SpendwareManagementClient(base_url="SPENDWARE_BASE_URL", api_key="SPENDWARE_API_KEY")
project = client.projects.create(
ProjectCreate(title="Acme AI", currency="USD", external_id="acme-ai"),
idempotency_key="project:acme-ai",
)
client.close()
import { SpendwareManagementClient } from "@spendware/provider-adapters-sdk/management";
const client = new SpendwareManagementClient({ baseUrl: "SPENDWARE_BASE_URL", apiKey: "SPENDWARE_API_KEY" });
const project = await client.projects.create(
{ title: "Acme AI", currency: "USD", external_id: "acme-ai" },
{ idempotencyKey: "project:acme-ai" },
);
Expected Result¶
The response includes the project id, title, currency, timestamps, owner information, and optional external_id. Use the returned id when creating customers.
Common Errors¶
401: management key is missing or invalid.403: key scopes or RBAC role do not allow project writes.409: an idempotent retry reused a key with different request parameters.