All Products
Search
Document Center

Server Load Balancer:CreateAScripts

Last Updated:Sep 28, 2026

Creates a programmable script.

Operation description

Before you begin

  • Create a Standard Edition or WAF-enhanced ALB instance. For more information, see CreateLoadBalancer.

Usage notes

CreateAScripts is an asynchronous operation. After a request is sent, the system returns a request ID, but the programmable script is not yet created. The creation task continues in the background. Call ListAScripts to query the creation status of the programmable script:

  • If the programmable script is in the Creating state, the script is being created.

  • If the programmable script is in the Available state, the script is created successfully.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

alb:CreateAScripts

create

*LoadBalancer

acs:alb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ClientToken

string

No

The client token used to ensure the idempotence of the request.

Generate a unique value from your client for each request. ClientToken supports only ASCII characters.

5A2CFF0E-5718-45B5-9D4D-70B******

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: Sends a dry run request. No programmable script is created. The system checks whether the required parameters are specified, the request format is valid, and business limits are met. If the check fails, the corresponding error is returned. If the check passes, the error code DryRunOperation is returned.

  • false (default): Sends a regular request. If the check passes, an HTTP 2xx status code is returned and the operation is performed.

false

ListenerId

string

Yes

The listener ID.

lsn-6hfq3zs0x04ibn****

AScripts

array<object>

No

The list of programmable script information.

array<object>

No

The programmable script information.

AScriptName

string

Yes

The name of the programmable script.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), hyphens (-), and spaces. It must start with a letter, Chinese character, or digit.

test

Position

string

No

The execution position of the programmable script. Valid values:

  • RequestHead (default): before request-direction rules are executed.

  • RequestFoot: after request-direction rules are executed.

  • ResponseHead: before response-direction rules are executed.

RequestFoot

Enabled

boolean

No

Specifies whether to enable the programmable script. Valid values:

  • true: Enabled.

  • false (default): Disabled.

false

ScriptContent

string

Yes

The content of the programmable script.

if and(match_re($uri, '^/1.txt$'), $arg_type) { rewrite(concat('/1.', $arg_type), 'break') }

ExtAttributes

array<object>

No

The extended attributes.

object

No

The extended attribute information of the programmable script.

AttributeKey

string

No

The attribute key of the AScript script.

Valid values: EsDebug only. When a request carries the _es_dbg parameter and its value matches the key configured here, the corresponding debug response headers are enabled to output rule execution records.

EsDebug

AttributeValue

string

No

The attribute value. The value can contain uppercase and lowercase letters and digits, and must be 1 to 128 characters in length.

test123

ExtAttributeEnabled

boolean

No

Specifies whether to enable the extended attributes of the programmable script. Valid values:

  • true: Enabled.

  • false (default): Disabled.

true

Response elements

Element

Type

Description

Example

object

The response for creating a programmable script.

JobId

string

The asynchronous task ID.

5c607642-535e-4e06-9d77-df53049b****

RequestId

string

The request ID.

BF0FE763-9603-558F-A55B-0F4******

AScriptIds

array<object>

The list of programmable script IDs.

object

The programmable script ID.

AScriptId

string

The programmable script ID.

as-xvq5igaa7uv6vr****

Examples

Success response

JSON format

{
  "JobId": "5c607642-535e-4e06-9d77-df53049b****",
  "RequestId": "BF0FE763-9603-558F-A55B-0F4******",
  "AScriptIds": [
    {
      "AScriptId": "as-xvq5igaa7uv6vr****"
    }
  ]
}

Error codes

HTTP status code

Error code

Error message

Description

400 IncorrectStatus.Listener The status of %s [%s] is incorrect. This operation is not supported in the listener's current state.
400 ResourceQuotaExceeded.AScriptsNum The quota of %s is exceeded for resource %s, usage %s/%s. The quota %s has been exceeded. The current usage is %s, and the quota is %s.
400 ResourceQuotaExceeded.AScriptsTotalLinesNum The quota of %s is exceeded for resource %s, usage %s/%s. The quota %s has been exceeded. The current usage is %s, and the quota is %s.
400 ResourceQuotaExceeded.AScriptLinesNum The quota of %s is exceeded for resource %s, usage %s/%s. The quota %s has been exceeded. The current usage is %s, and the quota is %s.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.