API keys#

Create and manage API keys for server-side integrations.

Provider required

All hooks require a BrandwaveProvider ancestor in your component tree. See the React Hooks overview for setup instructions.

useCreatePersonalAccessToken#

Create a new API key that can expire. The secret is only returned once.

typescript
import { useCreatePersonalAccessToken } from '@brandwave/react';

const { mutate, isPending } = useCreatePersonalAccessToken();

mutate({
  name: 'My Campaign',
});

Parameters#

NameTypeRequiredDescription
namestringRequiredDisplay name for this token.
expiresAtstring (ISO 8601) | nullWhen this token should expire.

Response#

Returns { data } with the result.

Underlying SDK method: bw.personalAccessTokens.create(params)

Store the key securely

The API key secret is only returned in the creation response. It cannot be retrieved again. Store it securely.

useListPersonalAccessTokens#

List API keys for the authenticated user.

typescript
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 an API key, immediately invalidating it.

typescript
import { useRevokePersonalAccessToken } from '@brandwave/react';

const { mutate, isPending } = useRevokePersonalAccessToken();

mutate({
  id: 'abc-123',
});

Parameters#

NameTypeRequiredDescription
idstring (UUID)RequiredToken identifier to revoke.

Response#

Returns { data } with the result.

Underlying SDK method: bw.personalAccessTokens.revoke(params)

Immediate invalidation

Revoking an API key immediately invalidates it. Any integrations using this key will stop working. This action cannot be undone.

useRotatePersonalAccessToken#

Rotate an API key by revoking the old key and creating a new one.

typescript
import { useRotatePersonalAccessToken } from '@brandwave/react';

const { mutate, isPending } = useRotatePersonalAccessToken();

mutate({
  id: 'abc-123',
});

Parameters#

NameTypeRequiredDescription
idstring (UUID)RequiredToken identifier to rotate (revokes old, creates new).

Response#

Returns { data } with the result.

Underlying SDK method: bw.personalAccessTokens.rotate(params)