Personal access tokens#
Create and manage personal access tokens for API authentication.
Provider required
BrandwaveProvider ancestor in your component tree. See the React Hooks overview for setup instructions.useCreatePersonalAccessToken#
Create a new personal access token. The plaintext token is only returned once.
import { useCreatePersonalAccessToken } from '@brandwave/react';
const { mutate, isPending } = useCreatePersonalAccessToken();
mutate({
name: 'My Campaign',
});Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Display name for this token. |
| expiresAt | string (ISO 8601) | null | — | When this token should expire. |
Response#
Returns { data } with the result.
Underlying SDK method: bw.personalAccessTokens.create(params)
Store the token securely
useListPersonalAccessTokens#
List all personal access tokens for the authenticated user.
import { useListPersonalAccessTokens } from '@brandwave/react';
const { data, isLoading } = useListPersonalAccessTokens({
});Response#
Returns { items, totalCount, facets } with paginated results.
Underlying SDK method: bw.personalAccessTokens.list()
useRevokePersonalAccessToken#
Revoke a personal access token, immediately invalidating it.
import { useRevokePersonalAccessToken } from '@brandwave/react';
const { mutate, isPending } = useRevokePersonalAccessToken();
mutate({
id: 'abc-123',
});Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (UUID) | Required | Token identifier to revoke. |
Response#
Returns { data } with the result.
Underlying SDK method: bw.personalAccessTokens.revoke(params)
Immediate invalidation
useRotatePersonalAccessToken#
Rotate a personal access token by revoking the old one and creating a new one.
import { useRotatePersonalAccessToken } from '@brandwave/react';
const { mutate, isPending } = useRotatePersonalAccessToken();
mutate({
id: 'abc-123',
});Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (UUID) | Required | Token identifier to rotate (revokes old, creates new). |
Response#
Returns { data } with the result.
Underlying SDK method: bw.personalAccessTokens.rotate(params)