Tạo CDN Livestream bằng API

Tạo CDN Livestream bằng API

GreenNodeHelp Center

Creating a Livestream CDN via API on VNG Cloud

Step-by-step guide to provisioning a Livestream CDN distribution through the VNG Cloud CDN API, with instructions on locating the required liveEntrypointId.


1. Retrieving the liveEntrypointId

Step 1: Create a live entrypoint through the VNG Cloud portal. This step must be performed on the portal — creating a live entrypoint via API is not currently supported.

Step 2: After the live entrypoint is created, open it in edit mode from the portal. The liveEntrypointId is exposed as a UUID segment directly in the browser's URL bar on the edit page, as shown in the screenshots below.

Live entrypoint list page on VNG Cloud portal

Edit button location on the live entrypoint row

Browser URL bar showing the liveEntrypointId UUID after clicking Edit

⚠ Lưu ý: Copy the UUID from the URL and save it — this value is required as liveEntrypointId in the API request body in the next step.

2. Sending the API Request to Create the CDN

Step 3: Execute the following curl command to create the Livestream CDN distribution. Before running, replace every placeholder (marked with < >) with your actual values.

▸ <YOUR_BEARER_TOKEN>: Your API key token, obtainable from the VNG Cloud portal under API credentials.

▸ <YOUR_LIVE_ENTRYPOINT_ID>: The UUID retrieved in Step 2.

▸ <YOUR_DOMAIN>: The custom domain name to associate with this CDN distribution (e.g., example.com).

curl --location --request POST 'https://vcdn-api.vngcloud.vn/vcdn-api/v1/liv/cdn/create' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <YOUR_BEARER_TOKEN>' \
--data-raw '{
    "typeOrigin": "http",
    "useSsl": false,
    "corsConfiguration": {
        "configType": "simple",
        "allowOrigin": [],
        "allowHeader": [],
        "allowMethod": [],
        "exposeHeader": [],
        "allowCredentials": false
    },
    "accessFilters": [],
    "serviceType": "cdnpack",
    "segmentSize": 4,
    "channels": [
        "*"
    ],
    "liveEntrypointId": "<YOUR_LIVE_ENTRYPOINT_ID>",
    "cdnId": "",
    "cdnDomain": "",
    "domainName": "<YOUR_DOMAIN>",
    "checkCustomHeader": false,
    "originHostHeader": "",
    "sslId": "default",
    "cName": null,
    "status": 1,
    "lbType": "rr",
    "failOverErrorCode": [
        "500",
        "502",
        "503",
        "504"
    ],
    "upstreams": [],
    "minimumTls": "TLS 1.2",
    "cacheLevel": "2",
    "childrenRule": [],
    "childrenAdvanceRuleStr": "",
    "childrenAdvanceRule": {
        "id": "",
        "children": [],
        "behaviors": [],
        "criteria": [],
        "criteriaMustSatisfy": "all",
        "options": {},
        "variables": [],
        "comments": ""
    },
    "defaultRuleAction": [
        {
            "id": "",
            "actionName": "minimumTls",
            "value": "TLS 1.2",
            "order": 0,
            "status": 1
        },
        {
            "id": "",
            "actionName": "cacheLevel",
            "value": "2",
            "order": 0,
            "status": 1
        },
        {
            "actionName": "addCors",
            "value": {
                "configType": "simple",
                "allowOrigin": [],
                "allowHeader": [],
                "allowMethod": [],
                "exposeHeader": [],
                "allowCredentials": false
            },
            "order": 0,
            "status": 1
        }
    ]
}'
💡 Mẹo: The defaultRuleAction array pre-configures TLS 1.2 as the minimum protocol version, sets cache level to 2, and applies a simple CORS policy. Adjust these values if your distribution requires stricter security or custom caching behavior.
✅ Hoàn tất: A successful request returns HTTP 200 with the newly created CDN configuration object. The distribution becomes active within a short propagation period. You can verify the status from the VNG Cloud portal or by querying the CDN details endpoint.

References