Skip to main content

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.

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 — checking warning_low is a good place to prompt the operator for a code.

Parameters

code
string
required
The redeem code to apply, in its canonical format (for example "SYN-XXXX-XXXX-XXXX-X"). Codes are case-sensitive.

Returns

RedeemResult with the outcome of the redemption.
redemption_id
string
Stable identifier for this redemption. Use it to correlate with the matching ledger entry from credits.get_ledger.
credits_granted
float
Number of credits added to the wallet by this code.
new_balance_credits
float
Total wallet balance after the redemption, in credits.
expires_at
datetime | None
When the newly funded bucket expires, if the code carries an expiry. None means the granted credits do not expire.

Example

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