Skip to main content

General Information

Policy Type

policy-log

Description

Log policy captures a snapshot of the current message state at any point in the message processing pipeline and sends it to designated connectors. It supports HTTP, WebSocket, and gRPC protocols with synchronous and asynchronous execution modes.

Endpoints

List Policies

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Add Policy

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Update Policy

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Delete Policy

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

List Policies

Endpoint

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Request

Headers

HeaderValue
AuthorizationBearer {token}

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Response

Success Response (200 OK)

{
  "success": true,
  "resultList": [
    {
      "apiProxy": {
        "name": "MyAPI",
        "requestPolicyList": [
          {
            "type": "policy-log",
            "name": "request-snapshot",
            "description": "Log request snapshot before transformation",
            "active": true,
            "executionType": "ASYNC",
            "connectorRefs": [
              {
                "connectionName": "Production Elasticsearch"
              }
            ],
            "logCorrelationId": true,
            "logEnvironmentInfo": true,
            "logApiProxyInfo": true,
            "logUserInfo": true,
            "logHttpContext": true,
            "logHeaders": true,
            "logParameters": true,
            "logBody": true,
            "logResultInfo": true,
            "bodyLogMode": "FULL",
            "enablePrivacy": false
          }
        ],
        "responsePolicyList": [],
        "errorPolicyList": []
      }
    }
  ],
  "resultCount": 1
}

cURL Example

curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/" \
  -H "Authorization: Bearer YOUR_TOKEN"

Add Policy

Endpoint

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-log",
    "description": "Capture request snapshot before transformation",
    "active": true,
    "executionType": "ASYNC",
    "connectorRefs": [
      {
        "connectionName": "Production Elasticsearch"
      },
      {
        "connectionName": "Backup Kafka"
      }
    ],
    "logCorrelationId": true,
    "logEnvironmentInfo": true,
    "logApiProxyInfo": true,
    "logUserInfo": true,
    "logHttpContext": true,
    "logHeaders": true,
    "logParameters": true,
    "logBody": true,
    "logResultInfo": true,
    "bodyLogMode": "FULL",
    "bodyMaxBytes": 0,
    "enablePrivacy": false,
    "privacyDefinitionList": []
  }
}

Request Body Fields

operationMetadata
FieldTypeRequiredDefaultDescription
targetScopestringYes-Policy scope: ALL or ENDPOINT
targetEndpointstringNo*-Endpoint path (required if targetScope=ENDPOINT)
targetEndpointHTTPMethodstringNo*-HTTP method (required if targetScope=ENDPOINT)
targetPipelinestringYes-Pipeline: REQUEST, RESPONSE, or ERROR
deploybooleanNotrueWhether to deploy after adding policy
deployTargetEnvironmentNameListarrayNo[]List of environment names to deploy to
orderintegerNonullPolicy execution order (starts from 1)
policy
FieldTypeRequiredDefaultDescription
typestringYes-Policy type: policy-log
descriptionstringNo-Policy description
activebooleanNotrueWhether policy is active
executionTypestringNoSYNCExecution type: SYNC or ASYNC
connectorRefsarrayYes-List of connector references by connection name
logCorrelationIdbooleanNotrueLog correlation ID
logEnvironmentInfobooleanNotrueLog environment information (environment ID, project ID)
logApiProxyInfobooleanNotrueLog API proxy information (proxy name, method, endpoint)
logUserInfobooleanNotrueLog user information (username, credential)
logHttpContextbooleanNotrueLog HTTP context (IP address, method, URI, port, status code)
logHeadersbooleanNotrueLog request/response headers
logParametersbooleanNotrueLog request parameters
logBodybooleanNotrueLog request/response body
logResultInfobooleanNotrueLog result information (result type, error details)
bodyLogModestringNoFULLBody logging mode: FULL or PARTIAL
bodyMaxBytesintegerNo0Maximum body size in bytes (only for PARTIAL mode)
enablePrivacybooleanNofalseEnable policy-level privacy processing
privacyDefinitionListarrayNo[]List of privacy definitions (element name + operation)
connectorRefs[]
FieldTypeRequiredDescription
connectionNamestringYesName of a connection configuration defined in the project or admin project
Connectors are referenced by their connection name, not by ID. The system resolves the connection name to the appropriate connector at runtime. This allows policies to work across all environments where the connection is configured.

EnumExecutionType (executionType)

  • SYNC - Synchronous execution (blocks pipeline until delivery completes; errors break the pipeline)
  • ASYNC - Asynchronous execution (non-blocking; errors are logged but suppressed)

EnumBodyLogMode (bodyLogMode)

  • FULL - Log complete body content
  • PARTIAL - Log body content up to bodyMaxBytes limit

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}

cURL Example

curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/request-snapshot/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operationMetadata": {
      "targetScope": "ALL",
      "targetPipeline": "REQUEST",
      "deploy": true,
      "deployTargetEnvironmentNameList": ["production"],
      "order": 1
    },
    "policy": {
      "type": "policy-log",
      "description": "Capture request snapshot",
      "active": true,
      "executionType": "ASYNC",
      "connectorRefs": [
        { "connectionName": "Production Elasticsearch" }
      ],
      "logCorrelationId": true,
      "logEnvironmentInfo": true,
      "logApiProxyInfo": true,
      "logUserInfo": true,
      "logHttpContext": true,
      "logHeaders": true,
      "logParameters": true,
      "logBody": true,
      "logResultInfo": true,
      "bodyLogMode": "FULL",
      "enablePrivacy": false
    }
  }'

Update Policy

Endpoint

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-log",
    "description": "Updated - Log with partial body and privacy",
    "active": true,
    "executionType": "ASYNC",
    "connectorRefs": [
      { "connectionName": "Production Elasticsearch" }
    ],
    "logCorrelationId": true,
    "logEnvironmentInfo": true,
    "logApiProxyInfo": true,
    "logBody": true,
    "bodyLogMode": "PARTIAL",
    "bodyMaxBytes": 2048,
    "enablePrivacy": true,
    "privacyDefinitionList": [
      {
        "elementName": "creditCardNumber",
        "operation": "MASK"
      }
    ]
  }
}
Note: Request body structure is the same as Add Policy. All fields should be provided for update.

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}

cURL Example

curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/request-snapshot/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operationMetadata": {
      "targetScope": "ALL",
      "targetPipeline": "REQUEST",
      "deploy": true,
      "deployTargetEnvironmentNameList": ["production"],
      "order": 1
    },
    "policy": {
      "type": "policy-log",
      "description": "Updated - Log with partial body",
      "active": true,
      "executionType": "ASYNC",
      "connectorRefs": [
        { "connectionName": "Production Elasticsearch" }
      ],
      "logBody": true,
      "bodyLogMode": "PARTIAL",
      "bodyMaxBytes": 2048,
      "enablePrivacy": false
    }
  }'

Delete Policy

Endpoint

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request

Headers

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body

Full JSON Body Example
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": false
  }
}

Response

Success Response (200 OK)

{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": []
  }
}

cURL Example

curl -X DELETE \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/request-snapshot/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operationMetadata": {
      "targetScope": "ALL",
      "targetPipeline": "REQUEST",
      "deploy": false
    }
  }'

Notes and Warnings

  • Execution Types:
    • SYNC - Synchronous execution blocks the pipeline until all connectors are delivered to. If a connector fails, the pipeline breaks and an error is returned to the client.
    • ASYNC - Asynchronous execution runs delivery in the background. Connector failures are logged but do not affect the client request.
  • Connector References: Connectors are referenced by their connection name. The system resolves the name to the corresponding connection configuration and matches it to the appropriate connector in the current environment at runtime. This allows global policies to work across all environments.
  • Privacy: Privacy settings can be applied at two levels: policy-level and connector-level. Both are applied in sequence when enabled.
  • Protocol Support: HTTP supports headers, parameters, and body. WebSocket supports headers and body. gRPC supports body only.
  • Deployment: Policy changes require deployment to take effect. Set deploy: true or deploy manually.