Create namespace

Tạo namespace để lưu file và xử lý media. Tên namespace nằm trong path, chỉ gồm chữ thường, số và dấu -; API chuẩn hóa chữ hoa thành chữ thường. Dùng Application Credential của user BizflyCloud hoặc RBAC user được cấp quyền; không dùng namespace secret key vì namespace chưa tồn tại.

Request với Application Credential

curl --request POST \
  'https://mps.mediacdn.vn/v1/namespaces/my-namespace' \
  --header 'X-Auth-Type: application_credential' \
  --header 'X-App-Credential-Id: <credential-id>' \
  --header 'X-App-Credential-Secret: <credential-secret>' \
  --form 'description=Video storage for my application'

Request với RBAC on-premise

RBAC cần X-Tenant-Id để xác định project. Backend gọi API phải nằm trong whitelist của RBAC user.

RBAC_AUTH=$(printf '%s' '<username>:<user-secret-key>' | base64 | tr -d '\n')
curl --request POST \
  'https://mps.mediacdn.vn/v1/namespaces/my-namespace' \
  --header "X-User-Authen: Basic $RBAC_AUTH" \
  --header 'X-Tenant-Id: <tenant-id>' \
  --form 'description=Video storage for my application'

description là tùy chọn. DRM mặc định disabled; chỉ khi cần DRM, thêm form fields drm_status=enabled và drm_allow_sites=example.com,cdn.example.com theo cấu hình KMS của bạn.

Response

HTTP 200:

{
  "success": true,
  "status": true,
  "error_code": "",
  "message": "Namespace is created",
  "data": {
    "namespace": "my-namespace",
    "secret_key": "<new-namespace-secret-key>",
    "default_domain": "<default-serving-domain>",
    "tenant_id": "<tenant-id>",
    "permissions": ["upload", "overwrite", "delete", "rename"],
    "status": "running"
  },
  "description": "Namespace is created"
}

Lưu data.secret_key ở trusted backend. Để gọi API bằng key này, thêm IP backend vào namespace whitelist ; dùng Get domains để kiểm tra domain phục vụ file. Namespace trùng tên trả 406/E003; tên không hợp lệ trả 400/E001; vượt giới hạn namespace trả 400/E011.