Configuration Examples

Ready-to-use snippets for common patterns.

Storage to CDN with the Management API

Set ACDN_API_TOKEN, ACDN_ZONE_NAME (a unique lowercase name), and ACDN_FILE (a local file path). This Python 3 example creates billable resources, uploads a public object, and connects CDN delivery. It uses only the standard library. Keep credentials private and do not blindly rerun after a timeout; first inspect your resources in the API or dashboard.

Python 3
import json
import os
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen

api = 'https://acdn.uz/api/user'
token = os.environ['ACDN_API_TOKEN']
name = os.environ['ACDN_ZONE_NAME']
file = Path(os.environ['ACDN_FILE'])

def management(method, path, body=None):
    request = Request(api + path, method=method, headers={
        'Authorization': 'Bearer ' + token,
        'Accept': 'application/json',
        'Content-Type': 'application/json',
    }, data=json.dumps(body).encode() if body is not None else None)
    with urlopen(request, timeout=60) as response:
        return json.load(response)['data']

storage = management('POST', '/storage-zones', {
    'name': name, 'storage_region': 'uz',
})
credentials = management('GET', '/storage-zones/credentials/' + storage['id'])
object_path = quote(file.name, safe='')
upload = Request(
    credentials['endpoint'] + '/' + credentials['bucket'] + '/' + object_path,
    method='PUT',
    headers={'AccessKey': credentials['access_key']},
    data=file.read_bytes(),
)
with urlopen(upload, timeout=120) as response:
    print('Upload:', response.status)

cdn = management('POST', '/pull-zones', {
    'name': name, 'source_type': 'storage_zone',
    'source_storage_zone_name': storage['name'], 'tier': 'std',
})
print('Delivery URL:', 'https://' + cdn['hostname'] + '/' + object_path)

The returned CDN URL may take time to become available while configuration propagates. For S3 uploads instead of the simple HTTP API, create an S3 credential and follow the S3 quick-start guide.

DNS records and deployment cache purge

Replace DOMAIN_ID and PULL_ZONE_ID with your resource IDs. DNS mutations and purge require a verified email. Record type 16 is TXT. Purge clears the entire zone cache asynchronously and can increase origin traffic; it does not delete stored objects.

curl
curl --fail-with-body --request POST \
  'https://acdn.uz/api/user/dns-zones/entries/DOMAIN_ID' \
  --header "Authorization: Bearer $ACDN_API_TOKEN" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"name":"_acme-challenge","type":16,"ttl":60,"value":"challenge-value"}'

curl --fail-with-body --request POST \
  'https://acdn.uz/api/user/pull-zones/purge/PULL_ZONE_ID' \
  --header "Authorization: Bearer $ACDN_API_TOKEN" \
  --header 'Accept: application/json'

See the complete API reference for settings, hostname verification, and key rotation.

Configuration Examples

Replace EXPIRES_UNIX with a future Unix timestamp and calculate TOKEN_VALUE for that exact expiry using the token-authentication guide.

Tokenized query URL:

URL
https://cdn.example.uz/video/intro.mp4?acdn_token=TOKEN_VALUE&expires=EXPIRES_UNIX

Tokenized path URL:

URL
https://cdn.example.uz/acdn_token=TOKEN_VALUE&expires=EXPIRES_UNIX/video/intro.mp4

Edge rule for origin sharding by first path segment:

Edge rule
Condition:
  field = request_url
  match = any
  values = ["/node-*"]

Action:
  action = override_origin_url
  value  = "https://node%{Path.0}.origin.example"

Edge rule for upstream API key header injection:

Edge rule
Condition:
  field = request_url
  match = any
  values = ["/media/*"]

Action:
  action = set_request_header
  header = "X-Origin-Key"
  value  = "your-secret-value"