Skip to content

General API

This API manages stored policies and flows, their draft/version lifecycle, ownership, groups, audit, and tenant-scoped access control.

https://api.policy2.net

Policies and flows both use a base ID plus one or more concrete records.

  • the base ID identifies the logical resource across its lifetime
  • a concrete policy ID or flow ID identifies a specific draft or version record

That split is important because listing, ownership, grouping, deletion, and execution do not always operate on the same identifier.

POST /policy

Creates a new draft policy.

Update a policy draft or publish a version

Section titled “Update a policy draft or publish a version”
PUT /policy/{policyId}

Behavior depends on the submitted status:

  • draft updates the current draft
  • non-draft publish requests create a new version from the draft
GET /policy/{policyId}

Returns a specific draft or version record by policy ID.

GET /policy/{policyId}/versions

Returns the draft and published/versioned records for the base policy.

Create a new draft from an existing version

Section titled “Create a new draft from an existing version”
GET /policy/{policyId}/draft

Creates a draft from an existing published/versioned policy record and returns the new draft.

GET /policies

Returns policies visible to the current user in the current tenant context.

POST /flow

Creates a new draft flow.

PUT /flow/{flowId}

Behavior depends on the submitted status:

  • draft updates the current draft
  • non-draft publish requests create a new version from the draft
GET /flow/{flowId}

Returns a specific draft or version record by flow ID.

GET /flow/{flowId}/versions

Returns the draft and published/versioned records for the base flow.

Create a new draft from an existing version

Section titled “Create a new draft from an existing version”
GET /flow/{flowId}/draft

Creates a draft from an existing published/versioned flow record and returns the new draft.

GET /flows

Returns flows visible to the current user in the current tenant context.

All execution endpoints require a valid API key via the x-api-key header. The key must have at least view scope.

x-api-key: <your-api-key>
POST /run

Runs an unsaved policy body directly. This is not tied to a stored policy record.

POST /run/policy/{baseId}

Executes the current runnable policy for the base.

Resolution order:

  • latest published/versioned policy, if one exists
  • otherwise the draft
POST /run/policy_version/{policyId}

Executes the exact stored policy record identified by policyId.

POST /run/flow/{baseId}

Executes the current runnable flow for the base.

Resolution order:

  • latest published/versioned flow, if one exists
  • otherwise the draft
POST /run/flow_version/{flowId}

Executes the exact stored flow record identified by flowId.

POST /flow/test

Runs an ad hoc flow definition without storing it.

The API applies both role checks and ownership checks.

If a policy or flow has never been published:

  • it is owned by the creating user
  • only that user sees it in normal listings
  • it can still be loaded directly by ID if the caller has the link

Once a policy or flow is published/versioned:

  • ownership becomes organization-level
  • users in that organization can see it according to their role permissions
POST /group

Creates a group.

GET /group/{groupId}

Returns group metadata.

PUT /group/{groupId}

Updates group metadata.

DELETE /group/{groupId}

Deletes the group and its membership records.

GET /groups

Returns groups visible to the current user.

POST /group/{groupId}/member

Adds a policy base or flow base to a group.

DELETE /group/{groupId}/member/{memberId}

Removes a policy base or flow base from its group.

GET /group/{groupId}/policies

Lists visible policies in the group.

GET /group/{groupId}/flows

Lists visible flows in the group.

Policies and flows currently use soft delete.

DELETE /policy/{policyId}

Deletes the base policy, not just the individual version/draft record passed in.

DELETE /flow/{flowId}

Deletes the base flow, not just the individual version/draft record passed in.

  • versions are tied to a base and are not deleted individually
  • once a base is deleted, it is hidden from lists and groups
  • deleted bases cannot be loaded or executed
  • execution by exact version ID is also denied if the base has been deleted
GET /audit

Returns tenant-scoped audit events for authorized users.

Current audit coverage includes stored resource lifecycle and execution events such as:

  • created
  • edited
  • published
  • assigned
  • executed
  • deleted

The tenant audit view is intended for admins and auditors.

Current platform role expectations are:

  • viewer: inspect and run visible resources
  • editor: create drafts, tests, and groups
  • publisher: publish versions
  • admin: manage roles, keys, and deletes
  • auditor: review tenant audit activity without becoming an authoring role