Ana içeriğe atla

General Information

Policy Type

policy-time-restriction

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-time-restriction",
            "name": "business-hours-policy",
            "description": "Allow access only during business hours",
            "active": true,
            "actionType": "ALLOW",
            "zoneId": "+03:00",
            "restrictionList": [
              {
                "hourName": "Business Hours",
                "description": "Monday to Friday, 9 AM to 6 PM",
                "dayType": "WEEK",
                "enumWeekDayList": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"],
                "wholeDay": false,
                "startHour": 9,
                "startMinute": 0,
                "startSecond": 0,
                "endHour": 18,
                "endMinute": 0,
                "endSecond": 0
              }
            ]
          }
        ],
        "responsePolicyList": [],
        "errorPolicyList": []
      }
    }
  ],
  "resultCount": 1
}
Note: In list operations, restrictionList may be omitted for brevity.

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 - Weekday Restriction
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-time-restriction",
    "description": "Allow access only during business hours (Monday-Friday, 9 AM - 6 PM)",
    "active": true,
    "actionType": "ALLOW",
    "zoneId": "+03:00",
    "restrictionList": [
      {
        "hourName": "Business Hours",
        "description": "Monday to Friday, 9 AM to 6 PM",
        "dayType": "WEEK",
        "enumWeekDayList": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"],
        "wholeDay": false,
        "startHour": 9,
        "startMinute": 0,
        "startSecond": 0,
        "endHour": 18,
        "endMinute": 0,
        "endSecond": 0
      }
    ]
  }
}
Full JSON Body Example - Specific Date Restriction
{
  "operationMetadata": {
    "targetScope": "ALL",
    "targetPipeline": "REQUEST",
    "deploy": true,
    "deployTargetEnvironmentNameList": ["production"],
    "order": 1
  },
  "policy": {
    "type": "policy-time-restriction",
    "description": "Restrict access on December 25th",
    "active": true,
    "actionType": "RESTRICT",
    "zoneId": "+03:00",
    "restrictionList": [
      {
        "hourName": "Christmas Day",
        "description": "Full day restriction on December 25",
        "dayType": "CUSTOM",
        "day": 25,
        "month": 12,
        "wholeDay": true
      }
    ]
  }
}

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)
Enum: targetScope
  • ALL - Policy applies to all endpoints
  • ENDPOINT - Policy applies only to specified endpoint
Enum: targetPipeline
  • REQUEST - Executes in request pipeline
  • RESPONSE - Executes in response pipeline
  • ERROR - Executes in error pipeline
Enum: targetEndpointHTTPMethod
  • GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
policy
FieldTypeRequiredDefaultDescription
typestringYes-Policy type: policy-time-restriction
descriptionstringNo-Policy description
activebooleanNotrueWhether policy is active
actionTypestringYesRESTRICTAction type: ALLOW or RESTRICT
zoneIdstringNo”+03:00”Time zone ID (e.g., “+03:00”, “Europe/Istanbul”)
restrictionListarrayYes-List of time restriction rules (at least one required)

EnumRestrictionType (actionType)

  • ALLOW - Allow access during specified time periods
  • RESTRICT - Restrict access during specified time periods

Zone ID Format

  • Offset format: +03:00, -05:00, +00:00
  • Zone name: Europe/Istanbul, America/New_York, UTC
  • Must be a valid Java ZoneId

Note

  • restrictionList must contain at least one restriction rule.
  • When actionType: ALLOW, access is allowed only during specified periods.
  • When actionType: RESTRICT, access is blocked during specified periods.
restrictionList
Each restriction is an object with the following fields:
FieldTypeRequiredDefaultDescription
hourNamestringNo-Name for this restriction rule
descriptionstringNo-Description of the restriction
dayTypestringYes-Day type: WEEK or CUSTOM
enumWeekDayListarrayNo*-List of weekdays (required if dayType=WEEK)
dayintegerNo*-Day of month (required if dayType=CUSTOM, 0-31, 0=every day)
monthintegerNo*-Month (required if dayType=CUSTOM, 0-12, 0=every month)
wholeDaybooleanNofalseWhether restriction applies to whole day
startHourintegerNo*-Start hour (required if wholeDay=false, 0-24)
startMinuteintegerNo*-Start minute (required if wholeDay=false, 0-60)
startSecondintegerNo*-Start second (required if wholeDay=false, 0-60)
endHourintegerNo*-End hour (required if wholeDay=false, 0-24)
endMinuteintegerNo*-End minute (required if wholeDay=false, 0-60)
endSecondintegerNo*-End second (required if wholeDay=false, 0-60)

EnumDayType (dayType)

  • WEEK - Restriction applies to specific weekdays
  • CUSTOM - Restriction applies to specific dates

EnumWeekDays (enumWeekDayList)

  • MONDAY - Monday
  • TUESDAY - Tuesday
  • WEDNESDAY - Wednesday
  • THURSDAY - Thursday
  • FRIDAY - Friday
  • SATURDAY - Saturday
  • SUNDAY - Sunday
  • ALL - All days of the week

Day and Month Values

  • day: 0 - Every day of the month
  • day: 1-31 - Specific day of the month
  • month: 0 - Every month
  • month: 1-12 - Specific month (1=January, 12=December)

Time Values

  • startHour/endHour: 0-24 (24-hour format)
  • startMinute/endMinute: 0-60
  • startSecond/endSecond: 0-60
  • Start time must be before end time

Note

  • If dayType: WEEK, provide enumWeekDayList (at least one weekday).
  • If dayType: CUSTOM, provide day and month.
  • If wholeDay: false, provide all time fields (startHour, startMinute, startSecond, endHour, endMinute, endSecond).
  • If wholeDay: true, time fields are ignored.

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/business-hours/" \
  -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-time-restriction",
      "description": "Business hours restriction",
      "active": true,
      "actionType": "ALLOW",
      "zoneId": "+03:00",
      "restrictionList": [
        {
          "dayType": "WEEK",
          "enumWeekDayList": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"],
          "wholeDay": false,
          "startHour": 9,
          "startMinute": 0,
          "startSecond": 0,
          "endHour": 18,
          "endMinute": 0,
          "endSecond": 0
        }
      ]
    }
  }'

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-time-restriction",
    "description": "Updated business hours restriction",
    "active": true,
    "actionType": "ALLOW",
    "zoneId": "+05:00",
    "restrictionList": [
      {
        "hourName": "Updated Business Hours",
        "description": "Monday to Friday, 8 AM to 7 PM",
        "dayType": "WEEK",
        "enumWeekDayList": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"],
        "wholeDay": false,
        "startHour": 8,
        "startMinute": 0,
        "startSecond": 0,
        "endHour": 19,
        "endMinute": 0,
        "endSecond": 0
      }
    ]
  }
}
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/business-hours/" \
  -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-time-restriction",
      "description": "Updated business hours",
      "active": true,
      "actionType": "ALLOW",
      "zoneId": "+03:00",
      "restrictionList": [
        {
          "dayType": "WEEK",
          "enumWeekDayList": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"],
          "wholeDay": false,
          "startHour": 9,
          "startMinute": 0,
          "startSecond": 0,
          "endHour": 18,
          "endMinute": 0,
          "endSecond": 0
        }
      ]
    }
  }'

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
  }
}

Request Body Fields

operationMetadata
FieldTypeRequiredDefaultDescription
targetScopestringYes-Policy scope: ALL or ENDPOINT
targetPipelinestringYes-Pipeline: REQUEST, RESPONSE, or ERROR
deploybooleanNofalseWhether to deploy after deletion

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/business-hours/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "operationMetadata": {
      "targetScope": "ALL",
      "targetPipeline": "REQUEST",
      "deploy": false
    }
  }'

Notes and Warnings

  • Action Type:
    • ALLOW - Access is allowed only during specified periods (all other times are blocked)
    • RESTRICT - Access is blocked during specified periods (all other times are allowed)
  • Zone ID:
    • Use offset format: +03:00, -05:00, +00:00
    • Or zone name: Europe/Istanbul, America/New_York, UTC
    • Must be a valid Java ZoneId
  • Day Type:
    • WEEK - Use enumWeekDayList to specify weekdays
    • CUSTOM - Use day and month to specify dates
  • Day and Month Values:
    • day: 0 - Every day of the month
    • day: 1-31 - Specific day
    • month: 0 - Every month
    • month: 1-12 - Specific month
  • Time Values:
    • Hours: 0-24 (24-hour format)
    • Minutes/Seconds: 0-60
    • Start time must be before end time
  • Whole Day:
    • When wholeDay: true, restriction applies to entire day (time fields ignored)
    • When wholeDay: false, provide all time fields
  • Multiple Restrictions:
    • Multiple restrictions in the list are evaluated together
    • For ALLOW: Access allowed if any restriction matches
    • For RESTRICT: Access blocked if any restriction matches
  • Time Zone: All times are evaluated in the specified time zone
  • Deployment: Policy changes require deployment to take effect. Set deploy: true or deploy manually.