easyCDN Logo

HTTP API Reference

Complete HTTP API reference for easyCDN, including all endpoints, request/response formats, and authentication details.

Authentication Required

All endpoints require authentication. See the Auth & Basic Usage section for complete authentication details and examples.

Endpoints

POST /asset/upload/persist

Persist a temporary asset uploaded from the client-side Dropzone, converting it to a permanent asset with a permanent CDN URL. This endpoint should be called from your backend after receiving the temporary asset ID from your frontend.

Signature

http
POST https://api.easycdn.co/asset/upload/persist
Authorization: Bearer YOUR_SECRET_KEY
Content-Type: application/json

Example: Request body

json
{
  "tempAssetId": "temp_abc123"
}

Example: Persist asset (curl)

bash
curl -X POST https://api.easycdn.co/asset/upload/persist \
  -H "Authorization: Bearer ${EASYCDN_SECRET_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "tempAssetId": "temp_abc123"
  }'

Example: Response

json
{
  "asset": {
    "_id": "507f1f77bcf86cd799439011",
    "bucket": "easycdn-assets",
    "key": "uploads/2024/01/15/image.jpg",
    "name": "image.jpg",
    "size": 1024000,
    "type": "image/jpeg",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z",
    "projectId": "507f1f77bcf86cd799439012",
    "url": "https://cdn.easycdn.co/uploads/2024/01/15/image.jpg",
    "expiresAt": null,
    "userId": "507f1f77bcf86cd799439013"
  }
}

Example: Backend integration (Python)

python
import requests
import os
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/api/persist', methods=['POST'])
def persist_asset():
    data = request.get_json()
    temp_asset_id = data.get('tempAssetId')

    response = requests.post(
        'https://api.easycdn.co/asset/upload/persist',
        json={'tempAssetId': temp_asset_id},
        headers={
            'Authorization': f"Bearer {os.environ.get('EASYCDN_SECRET_KEY')}",
            'Content-Type': 'application/json'
        }
    )

    return jsonify(response.json())

Example: Backend integration (Ruby)

ruby
require 'sinatra'
require 'httparty'
require 'json'

post '/api/persist' do
  content_type :json

  request_body = JSON.parse(request.body.read)
  temp_asset_id = request_body['tempAssetId']

  response = HTTParty.post(
    'https://api.easycdn.co/asset/upload/persist',
    body: { tempAssetId: temp_asset_id }.to_json,
    headers: {
      'Authorization' => "Bearer #{ENV['EASYCDN_SECRET_KEY']}",
      'Content-Type' => 'application/json'
    }
  )

  response.body
end

Parameters

tempAssetId:stringrequired - The temporary asset ID from client-side upload

Returns

Returns the persisted asset with permanent CDN URL

asset: - The persisted asset with permanent CDN URL

Need More Endpoints?

This HTTP API reference currently covers the core endpoints. Additional endpoints are available through our Node.js SDK and React SDK. More HTTP endpoints will be documented here as they become available.