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

# credits.redeem

> Apply a redeem code to the current wallet and return the granted credits and new balance.

```python theme={null}
await sdk.credits.redeem(code)
```

Applies a redeem code (for example, a promotional code or a top-up voucher) to your client's wallet. On success, returns the credits granted by the code, the wallet's new total balance, and the expiry date of the newly funded bucket (if any).

Pair with [`credits.get_balance`](/sdk-reference/credits/get-balance). Checking `warning_low` is a good place to prompt the operator for a code.

### Parameters

<ParamField path="code" type="string" required>
  The redeem code to apply, in its canonical format (for example `"SYN-XXXX-XXXX-XXXX-X"`). Codes are case-sensitive.
</ParamField>

### Returns

`RedeemResult` with the outcome of the redemption.

<ResponseField name="redemption_id" type="string">
  Stable identifier for this redemption. Use it to correlate with the matching ledger entry from [`credits.get_ledger`](/sdk-reference/credits/get-ledger).
</ResponseField>

<ResponseField name="credits_granted" type="float">
  Number of credits added to the wallet by this code.
</ResponseField>

<ResponseField name="new_balance_credits" type="float">
  Total wallet balance after the redemption, in credits.
</ResponseField>

<ResponseField name="expires_at" type="datetime | None">
  When the newly funded bucket expires, if the code carries an expiry. `None` means the granted credits do not expire.
</ResponseField>

### Example

```python theme={null}
from maximem_synap import MaximemSynapSDK
from maximem_synap.errors import InvalidInputError, InsufficientCreditsError

sdk = MaximemSynapSDK(api_key="synap_your_key_here")
await sdk.initialize()

try:
    result = await sdk.credits.redeem("SYN-XXXX-XXXX-XXXX-X")
except InvalidInputError as exc:
    print(f"Code rejected: {exc}")
except InsufficientCreditsError as exc:
    # Already redeemed, expired, or exhausted.
    print(f"Code not usable: {exc}")
else:
    print(
        f"Added {result.credits_granted} credits "
        f"(new balance: {result.new_balance_credits})"
    )
    if result.expires_at:
        print(f"These credits expire at {result.expires_at.isoformat()}")
```

### Raises

* `InvalidInputError`: when the code is malformed or unknown.
* `InsufficientCreditsError`: when the code has already been redeemed, has expired, or has been exhausted. The exception's `balance_credits` field is `None` for these cases, so you can surface the error message directly.
* `SynapAuthError`: when the API key is missing or invalid.

### See also

* [credits.get\_balance](/sdk-reference/credits/get-balance)
* [credits.get\_ledger](/sdk-reference/credits/get-ledger)
* [credits.estimate](/sdk-reference/credits/estimate)
