---
title: "Credit Grant"
method: POST
path: "/api/workspaces/{slug}/billing/credit-grant"
tags: ["Workspace Billing"]
---

# Credit Grant

`POST /api/workspaces/{slug}/billing/credit-grant`

## Request

- Base URL: `https://api.kolens.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.kolens.ai/api/workspaces/{slug}/billing/credit-grant`
- Auth: none declared

Webhook callback — credit a workspace from a confirmed Stripe payment.

Called by ``kolens-web/app/api/stripe/webhook/route.ts`` after
Stripe's signature verifies. Idempotent on
``stripe_session_id`` (UNIQUE) — a duplicate delivery short-circuits
and returns ``credited=False`` with the current balance.

NOT api-key-gated — the Vercel webhook may not have a user session
when Stripe re-delivers, so we gate purely on ``X-Admin-Secret``.

## Path parameters

- `slug` string, required

## Headers

- `X-Admin-Secret` string, nullable

## Request body

- CreditGrantRequest
  - `stripe_session_id` string, required
  - `credits` number, required
  - `amount_cents` integer, required
  - `user_id` string, nullable
  - `receipt_url` string, nullable

## Response `200`

Successful Response

- CreditGrantResponse: Return shape for the webhook callback. ``credited`` is False when the request was deduplicated (replayed webhook with the same ``stripe_session_id``); in that case ``balance`` reflects the existing post-credit balance, so the webhook can log "already processed" without re-crediting.
  - `credited` boolean, required
  - `workspace_id` string, required
  - `balance` number, required
  - `purchase_id` string, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kolens/apis/kolens-api.md) · [All operations](https://skmtc.dev/kolens/apis/kolens-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kolens/apis/kolens-api/revisions/5d6865ab0a24?raw)
