Skip to main content

Create a Policy

Creates a new access policy within a dock. Policies define who can retrieve which artifacts, under what conditions, using a composable recipe that specifies authentication factors, access methods, and matching rules per stakeholder persona.
POST /v1/docks/:dockId/policies

Path Parameters

ParameterTypeDescription
dockIdstringThe dock ID

Request Body

ParameterTypeRequiredDescription
namestringRequiredDisplay name for the policy
recipestringRequiredJSON string defining the access recipe (see examples below)

Recipe Structure

FieldTypeDescription
stakeholderClassstringTarget persona: mortgagee, agent, policyholder, auditor
artifactTypesarrayAllowed artifact types (use ["*"] for all)
auth.factorsarrayRequired authentication factors
access.methodstring/arrayAccess channel: bulk_api, portal, bulk_download, or array of multiple
match.identifiersarrayIdentifier keys used to scope artifact visibility
constraintsobjectOptional: time windows, auto-expiration

Example: Mortgagee Bulk API Access

Shared passphrase + mutual TLS, bulk retrieval of up to 10,000 documents:
curl -X POST https://api.docyard.io/v1/docks/dock_01HQ3K.../policies \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Mortgagee Bulk API Access",
    "recipe": "{\"stakeholderClass\":\"mortgagee\",\"artifactTypes\":[\"declaration-page\",\"certificate-of-insurance\",\"endorsement\"],\"auth\":{\"factors\":[\"shared_passphrase\",\"tls_certificate\"],\"tls\":{\"require_mutual\":true,\"min_version\":\"1.2\"}},\"access\":{\"method\":\"bulk_api\",\"max_batch_size\":10000},\"match\":{\"identifiers\":[\"lender_id\",\"policy_number\"]}}"
  }'

Example: Agent Portal & Download Access

WebAuthn challenge (FIDO2 security key or platform biometric), portal + bulk download:
curl -X POST https://api.docyard.io/v1/docks/dock_01HQ3K.../policies \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Agent Portal & Download Access",
    "recipe": "{\"stakeholderClass\":\"agent\",\"artifactTypes\":[\"declaration-page\",\"policy-packet\",\"endorsement\",\"renewal-notice\"],\"auth\":{\"factors\":[\"webauthn\"],\"webauthn\":{\"challenge_type\":\"platform_or_cross_platform\"}},\"access\":{\"method\":[\"portal\",\"bulk_download\"]},\"match\":{\"identifiers\":[\"agency_code\",\"policy_number\"]}}"
  }'

Example: Policyholder Self-Service

SMS OTP with 5-minute TTL, single document retrieval through the portal:
curl -X POST https://api.docyard.io/v1/docks/dock_01HQ3K.../policies \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Policyholder Self-Service",
    "recipe": "{\"stakeholderClass\":\"policyholder\",\"artifactTypes\":[\"declaration-page\",\"id-card\",\"renewal-notice\"],\"auth\":{\"factors\":[\"sms_otp\"],\"otp\":{\"delivery\":\"sms\",\"code_length\":6,\"ttl_seconds\":300}},\"access\":{\"method\":\"portal\",\"max_concurrent_downloads\":1},\"match\":{\"identifiers\":[\"email\",\"date_of_birth\",\"policy_number\"]}}"
  }'

Example: Auditor Time-Boxed Access

Badge ID + NDA hash validation, read-only portal, no downloads, auto-expires:
curl -X POST https://api.docyard.io/v1/docks/dock_01HQ3K.../policies \
  -H "Authorization: Bearer dk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Q1 2025 External Audit — Deloitte",
    "recipe": "{\"stakeholderClass\":\"auditor\",\"artifactTypes\":[\"*\"],\"auth\":{\"factors\":[\"badge_id\",\"nda_hash\"],\"nda\":{\"hash_algorithm\":\"sha256\",\"require_match\":true}},\"access\":{\"method\":\"portal\",\"read_only\":true,\"download_enabled\":false},\"match\":{\"identifiers\":[\"badge_id\",\"nda_hash\"]},\"constraints\":{\"time_window\":{\"start\":\"2025-01-15T00:00:00Z\",\"end\":\"2025-02-15T00:00:00Z\"},\"auto_expire\":true}}"
  }'

Response

{
  "id": "pol_01HQ3P...",
  "dockId": "dock_01HQ3K...",
  "name": "Mortgagee Bulk API Access",
  "recipe": "{\"stakeholderClass\":\"mortgagee\",\"artifactTypes\":[\"declaration-page\",\"certificate-of-insurance\",\"endorsement\"],\"auth\":{\"factors\":[\"shared_passphrase\",\"tls_certificate\"],\"tls\":{\"require_mutual\":true,\"min_version\":\"1.2\"}},\"access\":{\"method\":\"bulk_api\",\"max_batch_size\":10000},\"match\":{\"identifiers\":[\"lender_id\",\"policy_number\"]}}",
  "status": "DRAFT",
  "currentVersion": 1,
  "createdAt": "2025-01-15T11:00:00.000Z"
}

Error Handling

StatusCondition
400name or recipe is missing or invalid
400recipe contains invalid JSON or unknown fields
401Missing or invalid API key
404Dock not found
New policies are always created in DRAFT status. Use the Publish endpoint to promote a policy through the DRAFT -> PILOT -> PRODUCTION lifecycle. The recipe field must be a JSON string — stringify the recipe object before sending.