# 5-minute DPDP quickstart

Mint a scoped API key, create a profile, publish a cited privacy notice, install the 4.94 KB gzipped banner loader, and export a verifiable receipt pack.

## 1. Mint a scoped API key

Call POST /v1/keys with the website owner's email and the narrowest scopes needed. Store the returned pgk_ secret in POLICYGRAIN_API_KEY and never commit it to git.

#### cURL

```bash
curl -X POST https://api.policygrain.com/v1/keys \
  -H "Content-Type: application/json" \
  -d '{"email": "owner@example.in", "scopes": ["documents", "sites:write"]}'
```

#### CLI

```bash
npx policygrain init --domain example.in
npx checkmydpdp https://example.in --json
```

#### TypeScript SDK

```ts
import { createClient, httpTransport } from "@policygrain/sdk";

const client = createClient({
  transport: httpTransport({
    baseUrl: "https://api.policygrain.com",
    tokens: { token: () => process.env.POLICYGRAIN_API_KEY ?? null },
  }),
});

const account = await client.account();
```

#### MCP

```json
{
  "mcpServers": {
    "policygrain": {
      "command": "npx",
      "args": ["-y", "@policygrain/mcp"],
      "env": { "POLICYGRAIN_API_KEY": "${POLICYGRAIN_API_KEY}" }
    }
  }
}
```

## 2. Create a profile and generate cited notices

Read GET /v1/questions to see the pinned Tier 1 question set, create a profile with POST /v1/profiles, trigger POST /v1/generations, and publish the approved version to pages.policygrain.com.

```bash
curl -X POST https://api.policygrain.com/v1/generations \
  -H "Authorization: Bearer $POLICYGRAIN_API_KEY" \
  -H "Idempotency-Key: gen-001" \
  -H "Content-Type: application/json" \
  -d '{"profile_id": "prof_01..."}'
```

## 3. Verify your domain and embed Consent Banner v2

Register your site with POST /v1/sites, verify domain ownership via DNS TXT or HTTPS well-known file at POST /v1/sites/{id}/domains/{domain}/verify, publish your banner config, and drop the single script tag into your root layout.

#### HTML

```html
<script
  src="https://cdn.policygrain.com/b/v1/loader.js"
  data-pg-site="site_01..."
  async
></script>
```

#### React / Next.js

```tsx
import { PolicyGrainProvider, PolicyGrainScript } from "@policygrain/react/next";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        <PolicyGrainScript siteKey="site_01..." regions={["IN"]} />
      </head>
      <body>
        <PolicyGrainProvider siteKey="site_01...">{children}</PolicyGrainProvider>
      </body>
    </html>
  );
}
```

#### WordPress / GTM

```bash
# WordPress: Activate PolicyGrain DPDP plugin, enter Site Key in Settings > PolicyGrain
# Shortcode for hosted notice embed:
[policygrain_notice slug="example-privacy"]
```

## 4. Verify in Chromium and export signed receipts

Run POST /v1/sites/{id}/verifications to confirm the banner loads before optional scripts fire, then inspect daily Ed25519 Merkle roots at GET /v1/sites/{id}/seal and export a date-bounded JSON/CSV evidence pack.
