OpenPolicy
Reference

openpolicy.ts

Reference for the unified OpenPolicy configuration file

The openpolicy.ts file (or openpolicy.config.ts) is the recommended way to define all of your policies in one place. It uses defineConfig() from @openpolicy/sdk to declare a shared company block alongside optional privacy, terms, and cookie sections.

import { defineConfig } from "@openpolicy/sdk";

export default defineConfig({
  company: { ... },
  privacy: { ... },
  terms: { ... },
  cookie: { ... },
});

The Vite plugin and CLI both accept this file directly. At build/generate time, each section that is present produces its own output file — sections you omit are skipped.


company

Required. Shared company information reused across all policy sections.

FieldTypeDescription
namestringPublic-facing company name
legalNamestringFull legal entity name
addressstringBusiness address
contactstringPrivacy/legal contact email or URL
company: {
  name: "Acme Inc.",
  legalName: "Acme Corporation",
  address: "123 Main St, Springfield, USA",
  contact: "privacy@acme.com",
},

privacy

Optional. Compiles to privacy-policy.md / privacy-policy.html / privacy-policy.pdf.

FieldTypeRequiredDescription
effectiveDatestringYesISO date string (e.g. "2026-01-01")
dataCollectedRecord<string, string[]>YesCategories of data collected and examples
legalBasisstringYesLegal basis for processing (e.g. "Legitimate interests and consent")
retentionRecord<string, string>YesRetention period per data category
cookies{ essential, analytics, marketing }YesWhich cookie types are in use
thirdParties{ name, purpose }[]YesThird-party services that receive data
userRightsstring[]YesRights afforded to users (e.g. "access", "erasure")
jurisdictionsJurisdiction[]YesApplicable jurisdictions: "us", "eu", "ca", "au", "nz", "other"
children{ underAge, noticeUrl? }NoChildren's privacy policy details
privacy: {
  effectiveDate: "2026-01-01",
  dataCollected: {
    "Account Information": ["Name", "Email address"],
    "Usage Data": ["Pages visited", "IP address"],
  },
  legalBasis: "Legitimate interests and consent",
  retention: {
    "Account data": "Until account deletion",
    "Usage logs": "90 days",
  },
  cookies: {
    essential: true,
    analytics: false,
    marketing: false,
  },
  thirdParties: [],
  userRights: ["access", "erasure"],
  jurisdictions: ["us", "eu"],
},

terms

Optional. Compiles to terms-of-service.md / terms-of-service.html / terms-of-service.pdf.

FieldTypeRequiredDescription
effectiveDatestringYesISO date string
acceptance{ methods: string[] }YesHow users accept the terms
governingLaw{ jurisdiction: string }YesLegal jurisdiction for disputes
eligibility{ minimumAge, jurisdictionRestrictions? }NoAge and geographic requirements
accounts{ registrationRequired, userResponsibleForCredentials, companyCanTerminate }NoAccount management terms
prohibitedUsesstring[]NoList of prohibited activities
userContent{ usersOwnContent, licenseGrantedToCompany, licenseDescription?, companyCanRemoveContent }NoUser-generated content terms
intellectualProperty{ companyOwnsService, usersMayNotCopy }NoIP ownership terms
payments{ hasPaidFeatures, refundPolicy?, priceChangesNotice? }NoBilling and payment terms
availability{ noUptimeGuarantee, maintenanceWindows? }NoService availability terms
termination{ companyCanTerminate, userCanTerminate, effectOfTermination? }NoTermination conditions
disclaimers{ serviceProvidedAsIs, noWarranties }NoWarranty disclaimers
limitationOfLiability{ excludesIndirectDamages, liabilityCap? }NoLiability limits
indemnification{ userIndemnifiesCompany, scope? }NoIndemnification terms
thirdPartyServices{ name, purpose }[]NoThird-party services used
disputeResolution{ method, venue?, classActionWaiver? }NoDispute resolution method: "arbitration", "litigation", "mediation"
changesPolicy{ noticeMethod, noticePeriodDays? }NoHow users are notified of changes
privacyPolicyUrlstringNoLink to the privacy policy
terms: {
  effectiveDate: "2026-01-01",
  acceptance: {
    methods: ["using the service", "creating an account"],
  },
  eligibility: { minimumAge: 13 },
  prohibitedUses: [
    "Violating any applicable laws or regulations",
    "Transmitting spam or malicious content",
  ],
  termination: {
    companyCanTerminate: true,
    userCanTerminate: true,
  },
  disclaimers: {
    serviceProvidedAsIs: true,
    noWarranties: true,
  },
  limitationOfLiability: {
    excludesIndirectDamages: true,
    liabilityCap: "Total liability shall not exceed $100 or amounts paid in the past 12 months.",
  },
  governingLaw: { jurisdiction: "Delaware, USA" },
  changesPolicy: {
    noticeMethod: "email or prominent notice on our website",
    noticePeriodDays: 30,
  },
  privacyPolicyUrl: "/privacy",
},

Optional. Compiles to cookie-policy.md / cookie-policy.html / cookie-policy.pdf.

FieldTypeRequiredDescription
effectiveDatestringYesISO date string
cookies{ essential, analytics, functional, marketing }YesWhich cookie categories are in use
jurisdictionsJurisdiction[]YesApplicable jurisdictions
thirdParties{ name, purpose, policyUrl? }[]NoThird-party cookie providers
trackingTechnologiesstring[]NoOther tracking technologies in use (e.g. "web beacons", "local storage")
consentMechanism{ hasBanner, hasPreferencePanel, canWithdraw }NoConsent UI details
cookie: {
  effectiveDate: "2026-01-01",
  cookies: {
    essential: true,
    analytics: true,
    functional: false,
    marketing: false,
  },
  thirdParties: [
    {
      name: "Google Analytics",
      purpose: "Website analytics and performance monitoring",
      policyUrl: "https://policies.google.com/privacy",
    },
  ],
  trackingTechnologies: ["web beacons", "local storage"],
  consentMechanism: {
    hasBanner: true,
    hasPreferencePanel: true,
    canWithdraw: true,
  },
  jurisdictions: ["us", "eu"],
},

Full example

import { defineConfig } from "@openpolicy/sdk";

export default defineConfig({
  company: {
    name: "Acme Inc.",
    legalName: "Acme Corporation",
    address: "123 Main St, Springfield, USA",
    contact: "privacy@acme.com",
  },
  privacy: {
    effectiveDate: "2026-01-01",
    dataCollected: {
      "Account Information": ["Name", "Email address"],
      "Usage Data": ["Pages visited", "Browser type", "IP address"],
    },
    legalBasis: "Legitimate interests and consent",
    retention: {
      "Account data": "Until account deletion",
      "Usage logs": "90 days",
    },
    cookies: { essential: true, analytics: false, marketing: false },
    thirdParties: [],
    userRights: ["access", "erasure"],
    jurisdictions: ["us", "eu"],
  },
  cookie: {
    effectiveDate: "2026-01-01",
    cookies: { essential: true, analytics: true, functional: false, marketing: false },
    thirdParties: [
      {
        name: "Google Analytics",
        purpose: "Website analytics and performance monitoring",
        policyUrl: "https://policies.google.com/privacy",
      },
    ],
    trackingTechnologies: ["web beacons", "local storage"],
    consentMechanism: { hasBanner: true, hasPreferencePanel: true, canWithdraw: true },
    jurisdictions: ["us", "eu"],
  },
  terms: {
    effectiveDate: "2026-01-01",
    acceptance: { methods: ["using the service", "creating an account", "clicking 'I Agree'"] },
    eligibility: { minimumAge: 13 },
    accounts: {
      registrationRequired: false,
      userResponsibleForCredentials: true,
      companyCanTerminate: true,
    },
    prohibitedUses: [
      "Violating any applicable laws or regulations",
      "Infringing on the intellectual property rights of others",
    ],
    intellectualProperty: { companyOwnsService: true, usersMayNotCopy: true },
    termination: {
      companyCanTerminate: true,
      userCanTerminate: true,
      effectOfTermination: "Your right to use the service ceases immediately.",
    },
    disclaimers: { serviceProvidedAsIs: true, noWarranties: true },
    limitationOfLiability: {
      excludesIndirectDamages: true,
      liabilityCap: "Total liability shall not exceed the greater of $100 or amounts paid in the past 12 months.",
    },
    governingLaw: { jurisdiction: "Delaware, USA" },
    changesPolicy: { noticeMethod: "email or prominent notice", noticePeriodDays: 30 },
    privacyPolicyUrl: "/privacy",
  },
});

On this page