> ## Documentation Index
> Fetch the complete documentation index at: https://docs.grantex.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Consent Notice

> Register a versioned consent notice. Required before creating consent records — the notice content is hashed and linked to each record.

## Endpoint

```
POST /v1/dpdp/consent-notices
```

## Authentication

Requires a developer API key in the `Authorization` header.

## Request Headers

| Header          | Value              |
| --------------- | ------------------ |
| `Authorization` | `Bearer <api_key>` |
| `Content-Type`  | `application/json` |

## Request Body

| Field                  | Type       | Required | Description                                                             |
| ---------------------- | ---------- | -------- | ----------------------------------------------------------------------- |
| `noticeId`             | `string`   | Yes      | A developer-chosen identifier for the notice (e.g., `"privacy-notice"`) |
| `version`              | `string`   | Yes      | Version string (e.g., `"2.0"`)                                          |
| `title`                | `string`   | Yes      | Human-readable notice title                                             |
| `content`              | `string`   | Yes      | Full consent notice content (HTML or plain text)                        |
| `purposes`             | `object[]` | Yes      | Array of purpose objects (`{ code, description }`)                      |
| `language`             | `string`   | No       | ISO language code (default: `"en"`)                                     |
| `dataFiduciaryContact` | `string`   | No       | Contact information for the data fiduciary                              |
| `grievanceOfficer`     | `object`   | No       | Grievance officer details (`{ name, email, phone? }`)                   |

## Example Request

```bash theme={null}
curl -X POST https://grantex-auth-dd4mtrt2gq-uc.a.run.app/v1/dpdp/consent-notices \
  -H "Authorization: Bearer gx_..." \
  -H "Content-Type: application/json" \
  -d '{
    "noticeId": "privacy-notice",
    "version": "2.0",
    "title": "Data Processing Consent Notice",
    "content": "We collect and process your data for the following purposes...",
    "purposes": [
      { "code": "analytics", "description": "Usage analytics for service improvement" },
      { "code": "personalization", "description": "Personalized recommendations" }
    ],
    "language": "en",
    "grievanceOfficer": {
      "name": "Jane Doe",
      "email": "grievance@acme.com",
      "phone": "+91-9876543210"
    }
  }'
```

## Response -- 201 Created

```json theme={null}
{
  "id": "ntc_01HXYZ...",
  "noticeId": "privacy-notice",
  "version": "2.0",
  "language": "en",
  "contentHash": "a1b2c3d4e5f6...",
  "createdAt": "2026-04-05T12:00:00.000Z"
}
```

## Response Fields

| Field         | Type     | Description                        |
| ------------- | -------- | ---------------------------------- |
| `id`          | `string` | Unique internal notice ID          |
| `noticeId`    | `string` | Developer-chosen notice identifier |
| `version`     | `string` | Version string                     |
| `language`    | `string` | ISO language code                  |
| `contentHash` | `string` | SHA-256 hash of the notice content |
| `createdAt`   | `string` | ISO-8601 creation timestamp        |

## Error Responses

| Status | Code           | Description                                                                     |
| ------ | -------------- | ------------------------------------------------------------------------------- |
| 400    | `BAD_REQUEST`  | Missing required fields (`noticeId`, `version`, `title`, `content`, `purposes`) |
| 401    | `UNAUTHORIZED` | Invalid or missing API key                                                      |
| 409    | `CONFLICT`     | Notice version already exists                                                   |

## SDK Examples

<CodeGroup>
  ```typescript TypeScript theme={null}
  import Grantex from '@grantex/sdk';

  const grantex = new Grantex({ apiKey: 'gx_...' });

  const notice = await grantex.dpdp.createConsentNotice({
    noticeId: 'privacy-notice',
    version: '2.0',
    title: 'Data Processing Consent Notice',
    content: 'We collect and process your data...',
    purposes: [
      { code: 'analytics', description: 'Usage analytics' },
    ],
    grievanceOfficer: {
      name: 'Jane Doe',
      email: 'grievance@acme.com',
    },
  });
  ```

  ```python Python theme={null}
  from grantex import Grantex

  grantex = Grantex(api_key="gx_...")

  notice = grantex.dpdp.create_consent_notice(
      notice_id="privacy-notice",
      version="2.0",
      title="Data Processing Consent Notice",
      content="We collect and process your data...",
      purposes=[{"code": "analytics", "description": "Usage analytics"}],
      grievance_officer={"name": "Jane Doe", "email": "grievance@acme.com"},
  )
  ```
</CodeGroup>
