API action reference

Update a policy

Update a policy. This action uses the same domain service from REST and MCP, so successful calls produce the same canonical domain result.

Authorization and availability

Required scope: policies:write. Available in Test and Live. REST operation: PATCH /v1/policies/{id}. Equivalent MCP tool: veltor_update_policy.

Request schema

Unknown fields are rejected. Path values shown in the route are combined with the JSON body or query input before validation.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "definition": {
      "type": "object",
      "properties": {
        "default_result": {
          "type": "string",
          "enum": [
            "allow",
            "deny"
          ]
        },
        "rules": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "result": {
                "type": "string",
                "enum": [
                  "allow",
                  "deny"
                ]
              },
              "when": {
                "$ref": "#/definitions/__schema0"
              }
            },
            "required": [
              "id",
              "name",
              "result",
              "when"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "default_result",
        "rules"
      ],
      "additionalProperties": false
    },
    "revision": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "id",
    "name",
    "definition",
    "revision"
  ],
  "additionalProperties": false,
  "definitions": {
    "__schema0": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "fact": {
              "type": "string",
              "maxLength": 100
            },
            "operator": {
              "type": "string",
              "enum": [
                "eq",
                "neq",
                "gte",
                "gt",
                "lte",
                "lt",
                "is_missing",
                "is_unknown",
                "is_unavailable"
              ]
            },
            "value": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 128
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                }
              ]
            }
          },
          "required": [
            "fact",
            "operator"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "all": {
              "minItems": 1,
              "maxItems": 10,
              "type": "array",
              "items": {
                "$ref": "#/definitions/__schema0"
              }
            }
          },
          "required": [
            "all"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "any": {
              "minItems": 1,
              "maxItems": 10,
              "type": "array",
              "items": {
                "$ref": "#/definitions/__schema0"
              }
            }
          },
          "required": [
            "any"
          ],
          "additionalProperties": false
        }
      ]
    }
  }
}

Example request payload

{
  "id": "00000000-0000-4000-8000-000000000001",
  "name": "Signup protection",
  "definition": {
    "default_result": "allow",
    "rules": []
  },
  "revision": 1
}

Response schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "propertyNames": {
    "type": "string"
  },
  "additionalProperties": {}
}

Example success response

REST returns this canonical domain result as JSON. MCP returns the same value in structuredContent and adds only its transport request ID.

{
  "id": "00000000-0000-4000-8000-000000000001",
  "status": "available"
}

Errors and recovery

Relevant errors include invalid input (422), missing scope or organization access (403), missing resources (404), revision or idempotency conflicts (409), rate limits (429), and deadline exhaustion (504). Use the returned request ID when investigating a failure.

Idempotency, retries, and timeout

Send a stable idempotency key and reuse it only for an exact retry of this mutation. The server deadline is 5 seconds. Retry only when the error reports retryable true.

cURL

curl -X PATCH https://veltor.dev/v1/policies/RESOURCE_ID \
  -H "Authorization: Bearer $VELTOR_SECRET_KEY" \
  -H "Veltor-Organization: $VELTOR_ORGANIZATION" \
  -H "Idempotency-Key: operation_123" \
  -H "Content-Type: application/json" \
  --data '{"name":"Signup protection","definition":{"default_result":"allow","rules":[]},"revision":1}'

Node SDK

const result = await veltor.call("/v1/policies/RESOURCE_ID", {
  method: "PATCH",
  input: {"id":"00000000-0000-4000-8000-000000000001","name":"Signup protection","definition":{"default_result":"allow","rules":[]},"revision":1},
  idempotencyKey: "operation_123",
});

MCP

veltor_update_policy({
  "id": "00000000-0000-4000-8000-000000000001",
  "name": "Signup protection",
  "definition": {
    "default_result": "allow",
    "rules": []
  },
  "revision": 1,
  "idempotency_key": "operation_123"
})