# Update Credit Balance

<mark style="color:orange;">`PUT`</mark> `/users/{user_id}/credits`

### **Overview**

**Updates a user’s credit balance** by increasing or decreasing the current amount.

This operation is typically used after a user action that consumes or restores credits.

**Typical use cases**

* Deducting credits when a service is used
* Adding credits through events or rewards
* Manually adjusting credits by an administrator

### **Header**

| Name                               | Value              |
| ---------------------------------- | ------------------ |
| Content-Type                       | `application/json` |
| Authorization <sup>(API Key)</sup> | `Bearer <API Key>` |

### Path

| Name      | Description                                                                                                                                                                                                 |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `user_id` | <p>User identifier (user\_id). <br>Optional on create — if not provided, a system-generated ID will be used<br><br><a href="../user/user_id-and-klaim_id" class="button secondary">More description</a></p> |

### Body

<table><thead><tr><th width="210.78125">Name</th><th width="132.0859375">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>credit_delta</code></td><td>number</td><td><p><strong>The amount by which the user’s credit balance should change.</strong></p><p><strong>A positive value</strong> will <strong>increase</strong> the user’s balance, and a <strong>negative value</strong> will <strong>decrease</strong> it.</p></td></tr><tr><td><code>description</code> <sub>(optional)</sub></td><td>string</td><td><p>A <strong>human-readable explanation</strong> of the action or transaction.</p><p>This text helps provide <strong>context or reasoning</strong> for why the credit was updated.</p></td></tr></tbody></table>

### Response

{% tabs %}
{% tab title="200" %}

```json
{
    "message": "resource updated successfully",
    "credit_balance": 706
}
```

{% endtab %}

{% tab title="400" %}
This http condition occurs when credit\_delta **doesn't contain a request body or credit\_delta** is **not a number**.

```json
{
    "message": "Invalid JSON format in request body"
}
```

{% endtab %}

{% tab title="404" %}
This HTTP status occurs when the system c**annot find a user profile** associated **with the given userId.**

```json
{
    "message": "Can not find user with the given user_id."
}
```

{% endtab %}
{% endtabs %}
