AddFirewallRule

AddFirewallRule

Add a firewall rule to an owned VM or container.

Endpoint: https://sive.host/modules/addons/shapi/sh-api.php

Method: POST using application/x-www-form-urlencoded.

Changes account or service state. Access is limited to directly owned records or explicitly assigned Partner-managed client services after both relationships are verified.

Request parameters

ParameterTypeRequiredDescription
actionstringYesExact SHAPI action name shown in this article.
api_keystringYesClient API key generated in the Sive.Host SHAPI page.
api_secretstringYesSecret paired with the API key. Send it only in the POST body.
serviceidpositive integerYesActive WHMCS service ID owned by the authenticated client.
typein|outYesTraffic direction.
doACCEPT|DROP|REJECTYesRule action.
protostringNoProtocol such as tcp or udp.
dportstringNoDestination port or range.
sportstringNoSource port or range.
sourcestringNoSource CIDR/address.
enable0|1NoWhether the rule is enabled; default 1.
commentstringNoOptional rule comment.

Example request

Set the four environment variables from the authenticated SHAPI page. Do not put credentials in source control or URLs.

curl --request POST 'https://sive.host/modules/addons/shapi/sh-api.php' \
  --user "${SHAPI_HTTP_USER}:${SHAPI_HTTP_PASSWORD}" \
  --header 'Accept: application/json' \
  --data-urlencode "action=AddFirewallRule" \
  --data-urlencode "api_key=${SHAPI_API_KEY}" \
  --data-urlencode "api_secret=${SHAPI_API_SECRET}" \
  --data-urlencode "serviceid=12345" \
  --data-urlencode "type=in" \
  --data-urlencode "do=ACCEPT" \
  --data-urlencode "proto=tcp" \
  --data-urlencode "dport=443" \
  --data-urlencode "source=0.0.0.0/0" \
  --data-urlencode "enable=1" \
  --data-urlencode "comment=Allow HTTPS"

Response

SHAPI always returns JSON. Check result; panel responses can vary by the server module and DirectAdmin version.

{
    "result": "success",
    "message": {
        "action": "AddFirewallRule",
        "data": "Panel- or action-specific response"
    }
}

Common errors

  • Unauthorized access!: source IP or HTTP Basic authentication failed.
  • Invalid API Key or secret.: the customer key is wrong, disabled, or deleted.
  • Unable to retrieve an active service owned by this client.: the service is inactive or belongs to another client.
  • Missing required parameters.: one or more required fields were omitted.

SHAPI documentation version 2.0 — generated from the current endpoint contract.

  • API
  • 0 Basebedisi ba Fumane Sena se na le Molemo
Na karabo ena e ile ya thusa?

Dihlooho tse Amanang

BuyNow

BuyNowOrder one supported VM or container product with an explicit OS and optional compatible...

Operating System Codes

Operating System CodesUse these exact aliases with BuyNow. Availability also depends on the...

Virtual Machine Addon Codes

Virtual Machine Addon CodesBillable resource actions use the following addonid values.Addon...

Virtual Machine Disk Codes

Virtual Machine Disk CodesDisk identifiers are the names assigned by the compute...

IncreaseDiskSize

IncreaseDiskSizePurchase capacity and grow an existing disk.Endpoint:...