> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/zga/accelerator/createaccelerator.md). Agents can also search and read this documentation through its [MCP server](https://docs.console.zenlayer.com/api-reference/~gitbook/mcp).

# CreateAccelerator

## 1. API Description

This API (CreateAccelerator) is used to create an accelerator.

#### Preparation

* Query available origin regions: Call [`DescribeOriginRegions`](https://docs.console.zenlayer.com/api-reference/zga/region/describeorginregions.md).
* Query available acceleration regions: Call [`DescribeAccelerateRegions`](https://docs.console.zenlayer.com/api-reference/zga/region/describeaccelerateregions.md).
* Create certificate: If HTTPS acceleration is required, you need to call [`CreateCertificate`](https://docs.console.zenlayer.com/api-reference/zga/certificate/createcertificate.md) in advance to upload the certificate and key.

{% hint style="info" %}
**Notes**

* If the domain parameter is empty, the accelerator is IP acceleration, which only supports configuring L4 acceleration rules.
* Domain is globally unique, and accelerators cannot be configured with the same domain.
* Domain cannot be the same as origin, otherwise it will form a loop and prevent acceleration from working.
* When creating a `Standard` type acceleration, configure `Anycast` in [accelerateRegions](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#accelerateRegion), this region cannot coexist with other acceleration regions.
* This is an asynchronous API. After the API returns successfully, the accelerator creation operation is not immediately completed. During this period, the accelerator status will be `Deploying`. You can query the accelerator status by calling the `DescribeAccelerators` API. If the accelerator status (acceleratorStatus) changes from `Deploying` to `Accelerating`, it indicates successful acceleration. `AccelerateFailure` indicates acceleration failure, and you can call the redeploy API to retry.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API Input Parameters.

| Parameter Name    | Required | Type                                                                                                                                   | Description                                                                                                                                                                                                                                                                 |
| ----------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| acceleratorName   | No       | String                                                                                                                                 | <p>Accelerator name</p><p>No more than 64 characters</p>                                                                                                                                                                                                                    |
| chargeType        | No       | String                                                                                                                                 | <p><a href="https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#acceleratorchargetype">Billing type</a></p><p>If not provided, the default billing type of the account is used</p>                                                                         |
| resourceGroupId   | No       | String                                                                                                                                 | <p>Resource Group ID.</p><p>If not provided, the default resource group is used</p>                                                                                                                                                                                         |
| certificateId     | No       | String                                                                                                                                 | <p>Certificate ID<br>This parameter can be obtained from the certificateId field in the response of calling <a href="https://docs.console.zenlayer.com/api-reference/zga/certificate/describecertificates.md">DescribeCertificates</a>.</p>                                 |
| domain            | No       | [Domain](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#domain)                                                  | <p>Domain is globally unique, duplicate domains are not allowed.</p><p>If not specified, IP acceleration is indicated, and 7-layer acceleration cannot be configured for IP acceleration</p><p>Domain cannot be the same as the origin address, which will cause a loop</p> |
| origin            | Yes      | [Origin](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#origin)                                                  | Origin information                                                                                                                                                                                                                                                          |
| accelerateRegions | Yes      | Array of [AccelerateRegion](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#accelerateRegion)                     | Acceleration region information                                                                                                                                                                                                                                             |
| l4Listeners       | No       | Array of [AccelerationRuleL4Listener](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#accelerationrulel4listener) | <p>L4 acceleration rules</p><p>L4 and L7 cannot both be empty</p>                                                                                                                                                                                                           |
| l7Listeners       | No       | Array of [AccelerationRuleL7Listener](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#accelerationrulel7listener) | <p>L7 acceleration rules</p><p>L4 and L7 cannot both be empty</p>                                                                                                                                                                                                           |
| protocolOpts      | No       | [AccelerationRuleProtocolOpts](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#accelerationruleprotocolopts)      | Acceleration rule protocol options                                                                                                                                                                                                                                          |
| healthCheck       | No       | [HealthCheck](https://docs.console.zenlayer.com/api-reference/zga/datastructure.md#healthcheck)                                        | Health check configuration                                                                                                                                                                                                                                                  |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| acceleratorId  | String | Accelerator ID                                                                                                        |

## 4. Code Examples

{% tabs %}
{% tab title="Example" %}

1. **Create accelerator**

```json
POST /api/v2/zga HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateAccelerator
<Common Request Params>

Request:
{
    "acceleratorName": "xx.xx.com_Singapore",
    "chargeType": "ByTrafficPackage",
    "resourceGroupId":"xxx-xx",
    "certificateId": "f0864***66c6fa",
    "domain": {
        "domain": "xx.xx.com",
        "relateDomains": "xx.xx.cn"
    },
    "origin": {
        "originRegionId": "SG",
        "origin": "10.10.10.10",
        "backupOrigin": ""
    },
    "accelerateRegions": [
        {
            "accelerateRegionId": "FR",
        }
    ],
    "l4Listeners": [
        {
            "portRange": "53/54",
            "protocol": "udp"
        }
    ],
    "l7Listeners": [
        {
            "port": 443,
            "backPort": 443,
            "backProtocol": "https",
            "protocol": "https"
        }
    ],
    "protocolOpts": {
        "toa": false,
        "toaValue": 253,
        "websocket": false,
        "proxyProtocol": false,
        "gzip": false,
        "sniCheck": false,
        "httpRedirect": false
    },
    "healthCheck": {
        "enable": true,
        "alarm": true,
        "port": 80
    }
}


Response:
{
    "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
    "response": {
        "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
        "acceleratorId": "acceleratorIdxxxxx",
    }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                        | Description                                                                         |
| ---------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------- |
| 400              | IP\_ACCELERATOR\_NOT\_SUPPORT\_L7                 | IP accelerator does not support 7-layer acceleration                                |
| 400              | NOT\_SUPPORT\_RELATE\_DOMAINS                     | IP acceleration does not support related domains                                    |
| 400              | RELATE\_DOMAINS\_EXCEED\_LIMIT                    | Related domain configuration exceeds limit                                          |
| 400              | RELATE\_DOMAINS\_CONFLICT\_WITH\_DOMAIN           | Related domains conflict with domain                                                |
| 400              | PORT\_NOT\_AVAILABLE                              | Port is not available, please check port range                                      |
| 400              | PORT\_CONFLICT                                    | Port conflict                                                                       |
| 400              | PORT\_FORBIDDEN                                   | Acceleration port is forbidden                                                      |
| 400              | PORT\_EXCEEDED\_LIMIT                             | Port count exceeds limit                                                            |
| 400              | HTTPS\_NEED\_CRT                                  | HTTPS requires certificate configuration                                            |
| 400              | PROXYPROTOCOL\_NOT\_ALLOW\_CONFIGURED\_WITH\_TOA  | ProxyProtocol and Toa cannot be configured simultaneously                           |
| 400              | ORIGIN\_FORBIDDEN                                 | Origin is forbidden                                                                 |
| 400              | ORIGIN\_NOT\_AVAILABLE                            | Origin is not available                                                             |
| 400              | IP\_CNAME\_EXIST\_SAME\_TIME                      | Origin cannot have both IP and CNAME at the same time                               |
| 400              | MULTIPLE\_CNAMES\_EXIST                           | Origin cannot have multiple CNAMEs                                                  |
| 400              | CNAME\_ORIGIN\_NOT\_SUPPORT\_BACKUP\_ORIGIN       | Backup origin is not supported when the primary origin is CNAME type                |
| 400              | CERT\_NOT\_MATCH\_DOMAIN\_OR\_EXPIRED             | Certificate is expired or does not match domain                                     |
| 500              | FIND\_RESOUCE\_GROUP\_ERROR                       | Failed to query user resource group                                                 |
| 400              | ACCELERATE\_REGION\_ONLY                          | This region is only available for acceleration regions                              |
| 400              | ANYCAST\_ONLY                                     | This region is only available for Anycast                                           |
| 400              | DOMAIN\_SAME\_AS\_ORIGIN                          | Domain cannot be the same as origin                                                 |
| 400              | ACCELERATOR\_DOMAIN\_EXIST                        | Domain already exists                                                               |
| 400              | NO\_FIT\_LINE                                     | Acceleration region unavailable                                                     |
| 404              | INVALID\_REGION\_NOT\_FOUND                       | Region not found                                                                    |
| 400              | ANYCAST\_NOT\_ALLOW\_WITH\_NORMAL\_REGION         | Anycast acceleration cannot be used simultaneously with normal acceleration regions |
| 400              | CUSTOMER\_ACCOUNT\_NOT\_AVAILABLE                 | Customer account is not available                                                   |
| 400              | TRAFFIC\_PACKAGE\_NOT\_EXIST                      | Metering package does not exist                                                     |
| 400              | TRAFFIC\_PACKAGE\_EXPIRED                         | Metering package has expired, please renew                                          |
| 400              | LINE\_NOT\_ENOUGH                                 | Account ip resources have reached the limit                                         |
| 400              | NO\_ENOUGH\_BANDWIDTH                             | User does not have sufficient bandwidth                                             |
| 400              | ONLY\_ONE\_CN2\_SELECTED                          | Only one CN2 acceleration region can be selected                                    |
| 500              | ADD\_RESOURCE\_GROUP\_ERROR                       | Failed to add resource group                                                        |
| 500              | FOUND\_AVAILABLE\_REGION\_ERROR                   | Failed to query available regions                                                   |
| 404              | INVALID\_CERTIFICATE\_NOT\_FOUND                  | Specified certificate not found                                                     |
| 400              | IP\_ACCELERATOR\_NOT\_SUPPORT\_GZIP               | IP acceleration does not support gzip configuration                                 |
| 400              | IP\_ACCELERATOR\_NOT\_SUPPORT\_WEBSOCKET          | IP acceleration does not support websocket configuration                            |
| 400              | IP\_ACCELERATOR\_NOT\_SUPPORT\_SNI\_CHECK         | IP acceleration does not support SNI check configuration                            |
| 400              | IP\_ACCELERATOR\_NOT\_SUPPORT\_HTTP\_REDIRECT     | IP acceleration does not support HTTP redirect configuration                        |
| 400              | HTTP\_REDIRECT\_MUST\_CONFIGURED\_REQUIRED\_PORTS | HTTP redirect must configure 80/HTTP and 443/HTTPS acceleration ports               |
