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, or a space whose content the sender can’t read (a private or members-only space they aren’t an active member of, or a space under one), 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" | "message"
What the grant is for. Must be supplied together with targetId. It need not be authored by the recipient. A grant with a spaceId must use the target’s space (an entity’s space, a comment’s entity’s space, a message’s space chat’s space; none for a target in no space), or it is rejected with 400 reputation-grant/space-mismatch — see The target is an annotation.
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 a SublayError carrying the status and code, 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