Skip to content

Policy as code

Experimental

Policy as code is experimental. The document's shape mirrors the configuration bodies and may change.

The firewall, tool-scan and model configurations of a deployment as one declarative document, in JSON or YAML. Export it, keep it under version control, review a change, and apply it back. Both calls need a Configuration management (admin) key, see the Configuration API.

The document

matvis-policy.yaml
apiVersion: matvis/v1
prune: false
firewallConfigs:
- name: prod-inbound
  type: inbound
  # ... the complete firewall configuration
toolScanConfigs: []
modelBindings:
- name: gpt-4o-prod
  provider: openai
  config: { api_key: sk-..., chat_model: gpt-4o }
  inboundFirewall: prod-inbound
  outboundFirewall: prod-outbound
  toolInboundFirewall: null    # the tool response configuration
  toolOutboundFirewall: null   # the tool call configuration
Field Description
apiVersion The document version, matvis/v1.
prune true deletes the configurations of a type the document lists that the document does not name. A type the document leaves out is never pruned. false by default.
firewallConfigs Complete firewall configurations.
toolScanConfigs Complete tool-scan configurations.
modelBindings Model configurations: name, provider, the provider config, and the names of the configurations that screen the model's traffic.

Export

GET /api/v1/policy-as-code/export

Returns the current configuration as a document, the same shape apply accepts. Server-managed fields (uuid, created_at and the like) are left out, and model configurations reference firewall and tool-scan configurations by name. Provider secrets are replaced by REDACTED: put them back before you apply a document that carries model configurations.

Parameter In Description
format query yaml for a YAML document; JSON by default.
export MATVIS_URL="https://<your-matvis-host>"
export MATVIS_API_KEY="<your-admin-api-key>"
export CONFIG_UUID="<configuration-uuid>"


curl "$MATVIS_URL/api/v1/policy-as-code/export?format=yaml" \
  -H "Authorization: $MATVIS_API_KEY" > matvis-policy.yaml

Apply

POST /api/v1/policy-as-code/apply

Brings the deployment in line with the document you send, in JSON or YAML (Content-Type: application/yaml). Resources are identified by their name: firewall and tool-scan configurations by name and type, model configurations by name, and a model configuration references firewall and tool-scan configurations by name. Each entry must be the complete configuration, the same fields as a configuration body; a partial configuration is rejected. Leave created_at out.

curl -X POST "$MATVIS_URL/api/v1/policy-as-code/apply" \
  -H "Authorization: $MATVIS_API_KEY" \
  -H "Content-Type: application/yaml" \
  --data-binary @matvis-policy.yaml

The response lists what was done: applied, skipped (already as in the document), failed and notApplied. A document that names the same resource twice is refused with 422. When an action fails partway, the response is 502 with the same lists: apply the document again to converge.

Responses

See the status codes every Configuration API call shares.