API Docs

Usage and requests

Read the shared credit balance, reconcile recent usage, and recover stored results after a client timeout.

GET/usage

Read balance and recent usage

Returns the shared balance and a latest-50-attempt summary. Follow next_cursor with GET /usage?cursor=...&limit=20 to read every retained attempt.

curl --request GET \
  --url https://www.lahjty.com/api/v1/usage \
  --header "Authorization: Bearer $LAHJTY_API_KEY"

Example response

response.json
{
  "object": "usage_summary",
  "plan": "business",
  "balance": 500,
  "recent_requests": 1,
  "successful_requests": 0,
  "credits_used": 0,
  "net_credits_used": 0,
  "summary_scope": "latest_50_attempts",
  "summary_limit": 50,
  "summary_truncated": false,
  "credits_used_basis": "gross_successful_generation_credits",
  "retention_days": 30,
  "is_done": true,
  "next_cursor": null,
  "requests": [
    {
      "id": "req_01jexample",
      "operation": "copy.ad_copy",
      "status": "failed",
      "credits": 2,
      "net_credits": 0,
      "partial_refund_credits": 0,
      "credits_charged": true,
      "credits_refunded": true,
      "refund_pending": false,
      "created_at": "2026-09-05T00:00:00.000Z"
    }
  ]
}
GET/requests/req_01jexample

Recover a request after timeout

Terminal request records and generated payloads are retained for 30 days. Use the previously returned request_id.

curl --request GET \
  --url https://www.lahjty.com/api/v1/requests/req_01jexample \
  --header "Authorization: Bearer $LAHJTY_API_KEY"

Example response

response.json
{
  "id": "req_01jexample",
  "object": "api_request",
  "operation": "copy.ad_copy",
  "status": "failed",
  "credits": 2,
  "net_credits": 0,
  "partial_refund_credits": 0,
  "credits_charged": true,
  "credits_refunded": true,
  "refund_pending": false,
  "status_code": 502,
  "error_code": "provider_unavailable",
  "created_at": "2026-09-05T00:00:00.000Z",
  "updated_at": "2026-09-05T00:00:05.000Z",
  "result": {
    "type": "https://www.lahjty.com/problems/provider-unavailable",
    "title": "Request failed",
    "status": 502,
    "code": "provider_unavailable",
    "detail": "The generation could not complete. Retry with the same key.",
    "request_id": "req_01jexample"
  }
}

Reconciliation fields

  • Persist request_id from every success and problem response.
  • Use external_id for your campaign and external_customer_id for the merchant.
  • credits_used counts gross successful generation credits in the latest 50 attempts. It is not a net ledger total and excludes later template-outcome refunds. Inspect credits_charged, credits_refunded and refund_pending per attempt, and the template outcome refund status separately.