# Consents

> Consent per record and purpose: the purposes an organization asks consent for with their lawful basis and version, each decision with who made it (the person or a representative) and its signature, form or file as evidence, withdrawals and expiry. consent_active() answers whether processing may go ahead.

- Category: Admin & compliance
- Module: `consents`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/consents
- Page: https://bettersupabase.com/blocks/consents

## Install

```bash
npx better-supabase add consents
```

The command also installs `updated-at`, `memberships`, `permissions`, `subjects`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by consents; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    subjects: {},
    // Modes: "managed", "custom". The default is "managed".
    consents: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/consents`.

## Events

- `consent.expired`
- `consent.granted`
- `consent.refused`
- `consent.withdrawn`
- `consent_purpose.created`
- `consent_purpose.updated`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [subjects](https://bettersupabase.com/blocks/subjects.md)

Works with: [contacts](https://bettersupabase.com/blocks/contacts.md), [relations](https://bettersupabase.com/blocks/relations.md), [guests](https://bettersupabase.com/blocks/guests.md), [signatures](https://bettersupabase.com/blocks/signatures.md), [forms](https://bettersupabase.com/blocks/forms.md), [attachments](https://bettersupabase.com/blocks/attachments.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [audit](https://bettersupabase.com/blocks/audit.md)

## Recipes

- [Consent register](https://bettersupabase.com/recipes/consent-register.md): The purposes an organization asks consent for, with their lawful basis, version, how long a grant lasts and whether it needs a signature.
