Skip to main content

Overview

useCreateReputationGrant returns a callable that transfers reputation from the logged-in user to another user. The amount leaves the sender’s bucket and lands in the recipient’s bucket for the same space — nothing is created, and reputation never crosses between the project-general bucket and a space bucket. There is no actor argument: the sender is always the user the token belongs to. Naming a different sender requires a service key, which the React SDK never holds — see @sublay/node. Requires the reputation bundle.

Usage Example

Parameters

string
required
The user receiving the reputation. Cannot be the logged-in user.
number
required
Whole number from 1 to 2147483647 (the signed 32-bit maximum, which is also the width of a reputation balance). A transfer can never be zero, negative, or fractional, and it can never exceed what the sender holds in the source bucket.
string | null
The bucket both legs move in. Omitted or null = the project-general bucket. The space is validated before anything moves: an ID naming no space rejects with 404 reputation-grant/space-not-found, and naming one at all on a project without the spaces bundle rejects with 403 database/tables-not-available.
string | null
Free-text note. Trimmed, up to 2000 characters.
Record<string, any>
Arbitrary key-value data. Up to 1 MB. Omit when unused.
"entity" | "comment" | "chat-message"
What the grant is for. Must be supplied together with targetId. The target is an annotation — it never determines which bucket is used, and it need not be authored by the recipient.
string
The rewarded record’s ID. Must be supplied together with targetType, and must exist.

Returns

Returns a Promise<ReputationGrant> — the created ReputationGrant, with sourceType: "user".

Failure Modes

The hook validates locally before the round trip and throws for a missing projectId, a missing recipientId or amount, or a half-filled target (targetType without targetId, or vice versa). Server rejections surface as the axios error, most usefully:
Grant creation is not idempotent. A retried request creates a second grant and moves the points a second time. Disable your button while the promise is in flight.

See Also