## Attest a consent grant

**post** `/v1/consent`

Records a consent grant your brand attests to; for example, an opt-in
collected on your website.

**Requirements**

- Your brand's `consent_mode` must be `brand_attested`. Otherwise the
  call returns HTTP 409 `code` 2014. Read your mode before
  building against this endpoint: `GET /v1/settings` reports it as
  `consent_mode`.
- No `Idempotency-Key`: the server neither requires nor consults one
  here.

**Behavior**

- Grants only. Revocations are never attested through this endpoint:
  an opt-out is honored in the channel where the customer expressed it.

### Body Parameters

- `category: "account_notification" or "marketing" or "invitation"`

  The category being granted (`transactional` is not grantable returns HTTP 422 `code` 1010).

  - `"account_notification"`

  - `"marketing"`

  - `"invitation"`

- `source: "website" or "app" or "phone" or "in_person"`

  Where the brand captured the opt-in.

  - `"website"`

  - `"app"`

  - `"phone"`

  - `"in_person"`

- `subject: string`

  The subject: an opaque customer handle, or a bare E.164 when `subject_kind` is `tel` (normalized on record).

- `expires_at: optional string`

  Expiry, clamped to `granted_at` + 2 years, which is Apple's ceiling; absent → that ceiling.

- `granted_at: optional string`

  When the customer opted in; absent → now.

- `subject_kind: optional "opaque" or "tel"`

  Defaults to `opaque`. `invitation` requires `tel`; the organic categories require `opaque`; cross-kind returns HTTP 422 `code` 1068.

  - `"opaque"`

  - `"tel"`

### Returns

- `ok: true`

  - `true`

- `subject: string`

  The normalized subject; for `tel`, the `tel:+E164` handle form that equals a tel chat's `customer_handle`.

- `subject_kind: "opaque" or "tel"`

  The namespace the grant was written under (`opaque` when the request omitted it).

  - `"opaque"`

  - `"tel"`

### Example

```http
curl https://messages.api.linqapp.com/v1/consent \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $LINQ_AMB_API_KEY" \
    -d '{
          "category": "marketing",
          "source": "website",
          "subject": "urn:mbid:AQAAY7c1"
        }'
```

#### Response

```json
{
  "ok": true,
  "subject": "urn:mbid:AQAAY7c1",
  "subject_kind": "opaque"
}
```
