Download the PHP package codelet/sdk without Composer
On this page you can find all versions of the php package codelet/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sdk
Codelet PHP SDK
Official PHP client for the Codelet public API.
Install
For local development from this monorepo:
Usage
Optional constructor args: $baseUrl, $maxAttempts, $headers, $httpClient.
Examples
Create metrics before plans, credit packs, or ingest. Unknown metric names return 400.
Create a metric
Create a credit pack
Create and publish a plan
Create checkout
Credit pack (one-time purchase):
Subscription (plan):
Pass either customer_id or customer_email, not both. Exactly one of
pack_id or plan_id is required.
API reference
All generated methods are available on the Client instance (for example
$codelet->customers->listCustomers). Prefer $codelet->ingest(…) over
$codelet->usage->ingestEvent(…) when recording usage; the helper fills
idempotency_key when omitted.
$codelet->ingest($body)
Ingest a usage event. Same as usage->ingestEvent, but generates
idempotency_key when omitted.
| Method | Description |
|---|---|
ingest(IngestEventRequest $body) |
POST /v1/ingest |
Account ($codelet->account)
| Method | Description |
|---|---|
getMe() |
API key context (project + environment) |
Checkout ($codelet->checkout)
| Method | Description |
|---|---|
createCheckout($create_checkout_request) |
Create a credit pack or subscription checkout |
Credit packs ($codelet->creditPacks)
| Method | Description |
|---|---|
listCreditPacks($metric = null, $active = 'true', $page_size = 20, $cursor = null) |
List packs (default: active only) |
createCreditPack($create_credit_pack_request) |
Create a pack |
getCreditPack($pack_id) |
Get a pack by ID |
updateCreditPack($pack_id, $update_credit_pack_request) |
Update name, description, and/or active |
Customers ($codelet->customers)
| Method | Description |
|---|---|
listCustomers($page_size = 20, $cursor = null) |
List customers |
createCustomer($create_customer_request) |
Create a customer |
getCustomer($customer_id) |
Get a customer |
updateCustomer($customer_id, $update_customer_request) |
Update editable fields |
getCustomerBalance($customer_id, $metric = null) |
Credit balances (all metrics, or one) |
Metrics ($codelet->metrics)
| Method | Description |
|---|---|
listMetrics($page_size = 20, $cursor = null) |
List metrics |
createMetric($create_metric_request) |
Create a metric |
getMetric($name) |
Get a metric by name |
updateMetric($name, $update_metric_request) |
Partial update (today: display_name) |
Plans ($codelet->plans)
| Method | Description |
|---|---|
listPlans($status = 'published', $page_size = 20, $cursor = null) |
List plans (default: published) |
createPlan($create_plan_request) |
Create a draft plan |
getPlan($plan_id, $include_pricing_details = false) |
Get a plan |
publishPlan($plan_id) |
Publish the draft version |
Subscriptions ($codelet->subscriptions)
| Method | Description |
|---|---|
listSubscriptions($customer = null, $status = null, $page_size = 20, $cursor = null) |
List subscriptions |
getSubscription($subscription_id) |
Get a subscription |
cancelSubscription($subscription_id, $cancel_subscription_request) |
Cancel (at_period_end or immediate) |
resumeSubscription($subscription_id) |
Clear a scheduled cancellation |
Usage ($codelet->usage)
| Method | Description |
|---|---|
ingestEvent($ingest_event_request) |
Ingest a usage event (no auto idempotency key) |
Request and response shapes match the OpenAPI spec. See also codelet.co/SKILL.md for merchant integration guidance.
Errors
Generated APIs throw ApiException from the OpenAPI client. The top-level
ingest helper maps those to CodeletException / RateLimitException.
Development
Hand-written surface (src/) stays stable. Generated code under generated/
is overwritten by make sdk-generate.
All versions of sdk with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
guzzlehttp/psr7 Version ^2.0