> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/internal/credits/deposit

Handle credits deposit after payment

` POST /v1/internal/credits/deposit `

Handle credits deposit after payment

## Parameters

### ` x-api-key ` (header, required)

API key for authentication

- ` value `: type ` string `

## Request body (required)

Content type: ` application/json `

Credits deposit payload

- ` value `: type ` unknown `

  - ` oneOf alternative 1 `: type ` object `

  - ` oneOf alternative 2 `: type ` object `

    - Required fields: ` orgId `, ` referenceId `, ` source `, ` tier `

    - ` amountPaidCents `: type ` integer ` — optional payment validation

    - ` interval `: type ` string ` — from subscription metadata

    - ` orgId `: type ` string `

    - ` referenceId `: type ` string `

    - ` resetBeforeDeposit `: type ` boolean ` — default false = additive

    - ` source `: type ` string `

    - ` stripeCustomerId `: type ` string ` — from invoice.paid event

    - ` stripeSubscriptionId `: type ` string ` — from invoice.paid event

    - ` tier `: type ` string `

## Responses

### ` 200 ` — OK

Content type: ` application/json `

- ` value `: type ` object `

  - ` aiBalance `: type ` object `

    - ` new `: type ` number `

    - ` old `: type ` number `

  - ` creditsInserted `: type ` boolean `

  - ` cuBalance `: type ` object `

    - ` new `: type ` number `

    - ` old `: type ` number `

### ` 400 ` — Bad Request

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

### ` 401 ` — Unauthorized

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

## Request examples

### cURL

```curl
curl -X POST 'https://api.example.com/v1/internal/credits/deposit' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'x-api-key: string' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/internal/credits/deposit', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json",
      "x-api-key": "string"
  },
  body: JSON.stringify({})
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'x-api-key': 'string'
}

response = requests.post('https://api.example.com/v1/internal/credits/deposit', headers=headers, json={})
print(response.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{}`)
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/internal/credits/deposit", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-api-key", "string")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```