API Keys¶
Spendware separates management credentials from runtime credentials.
When To Use This¶
Use user API keys for automation and customer keys for provider-adapter or direct usage logging calls.
Create A Customer Key¶
curl "$SPENDWARE_BASE_URL/api/v1/customer-keys/" \
-H "Authorization: Bearer $SPENDWARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"end_customer_id":"CUSTOMER_ID","name":"Runtime key","scopes":["preflight:read","usage:write"]}'
from spendware_provider_sdk.management import EndCustomerKeyCreate, SpendwareManagementClient
client = SpendwareManagementClient(base_url="SPENDWARE_BASE_URL", api_key="SPENDWARE_API_KEY")
key = client.endcustomer_keys.create(
EndCustomerKeyCreate(
end_customer_id="CUSTOMER_ID",
name="Runtime key",
scopes=["preflight:read", "usage:write"],
)
)
client.close()
import { SpendwareManagementClient } from "@spendware/provider-adapters-sdk/management";
const client = new SpendwareManagementClient({ baseUrl: "SPENDWARE_BASE_URL", apiKey: "SPENDWARE_API_KEY" });
const key = await client.customerKeys.create({
end_customer_id: "CUSTOMER_ID",
name: "Runtime key",
scopes: ["preflight:read", "usage:write"],
});
Create A User API Key¶
User API key creation is covered by client.user_keys in Python and client.userKeys in TypeScript. Use scopes such as management:read, management:write, webhooks:read, and webhooks:write for automation.
Expected Result¶
Create responses include the full key once and a durable key_prefix. Store the full key securely and log only the prefix.
Common Errors¶
- Runtime calls fail if you use a user management key where a customer key is expected.
- Management calls fail if you use a customer key.
- A key scope can be valid while RBAC still blocks access to a resource.