Content API
Content API
Overview
The Content API provides an interface to create and manage content and revisions in QuantCDN. It allows you to publish, update, and unpublish content, manage assets, create redirects, and control caching behavior.
Authentication
Method: Bearer Token
All API requests must include the following headers:
Header | Description |
---|---|
Quant-Token | Your project’s API token (found in your dashboard) |
Quant-Customer | Your customer identifier |
Quant-Project | Your project identifier |
These headers will be validated to ensure the request is authorized.
Example:
curl -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ https://api.quantcdn.io/v1/ping
Base URL
All API requests must be directed to:
https://api.quantcdn.io/v1/
The path is prefixed with the API version. If backwards-breaking changes are introduced, the version number will be incremented. Old versions of the API will be maintained and deprecated with advance notice.
Pagination
Requests that return multiple items are paginated to 100 items by default. You can control pagination with these parameters:
Parameter | Type | Description |
---|---|---|
page | integer | Page number to retrieve |
per_page | integer | Number of items per page (default: 100) |
Paginated API endpoints return data under a records
key and include metadata with page
, page_size
, total_records
, and total_pages
.
Endpoints
Send Content
URL: /v1
Method: POST
Description: Publish HTML content to a specific URL path.
Request Body
{ "content": "<html><body><h1>My static web page</h1></body></html>", "url": "/example-page", "published": true, "info": { "author_name": "Joe Static", "log": "Revision log message" }, "headers": { "content-type": "text/html" }}
Property | Type | Required | Description |
---|---|---|---|
content | string | Yes | The HTML content to publish |
url | string | Yes | The URL path where the content will be accessible |
published | boolean | No | Whether the content should be published (default: true) |
info | object | No | Metadata about the content |
info.author_name | string | No | Name of the content author |
info.log | string | No | Revision log message |
headers | object | No | Custom HTTP headers to serve with the content |
Response
Status Code: 200 OK
{ "message": "Content created successfully", "url": "/example-page", "revision": 1, "assets": [ { "url": "/banner.jpg", "md5": "a1b2c3d4e5f6g7h8i9j0" } ]}
The response includes a list of assets detected in your content that already exist in Quant, so you only need to upload files that have changed or don’t exist.
Upload Asset
URL: /v1
Method: POST
Description: Upload static assets like images, JavaScript, CSS, etc.
Request Headers
Header | Type | Required | Description |
---|---|---|---|
Quant-File-Url | string | Yes | The URL path where the file will be accessible |
Quant-File-Headers | JSON string | No | Custom headers to serve with the file |
Request Body
Multipart form data with the file to upload.
Example
curl -X POST https://api.quantcdn.io/v1 \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-File-Url: /images/banner.jpg" \ -F "filename=@./banner.jpg"
Response
Status Code: 200 OK
{ "message": "File uploaded successfully", "url": "/images/banner.jpg", "revision": 1}
Get Metadata
URL: /global-meta
Method: GET
Description: Retrieve metadata about all files in your project.
Response
Status Code: 200 OK
{ "global_meta": { "records": [ { "last_modified": "2023-07-01T10:21:11", "meta": { "url": "/about-us", "type": "content", "seq_num": 3, "published": true, "byte_length": 41750, "published_md5": "1476374aafe25fb499729ee7e4505e62", "date_timestamp": 1595240471, "revision_count": 3, "published_revision": 3, "highest_revision_number": 3 } } ], "page": 1, "page_size": 100, "total_records": 1, "total_pages": 1 }}
Get URL Metadata
URL: /url-meta
Method: POST
Description: Retrieve metadata for specific URLs.
Request Body
{ "Quant-Url": ["/styles.css", "/about-us"]}
Response
Similar to the /global-meta
endpoint but filtered to the requested URLs.
Unpublish Content
URL: /unpublish
Method: PATCH
Description: Unpublish content at a specific URL path.
Request Headers
Header | Type | Required | Description |
---|---|---|---|
Quant-Url | string | Yes | The URL path to unpublish |
Example
curl -X PATCH \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-Url: /path/to/unpublish" \ https://api.quantcdn.io/v1/unpublish
Response
Status Code: 200 OK
{ "message": "Content unpublished successfully", "url": "/path/to/unpublish"}
Restore Previous Revision
URL: /publish/{revision_id}
Method: PATCH
Description: Restore a previous revision as the published version.
Request Headers
Header | Type | Required | Description |
---|---|---|---|
Quant-Url | string | Yes | The URL path of the content |
Example
curl -X PATCH \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-Url: /content" \ https://api.quantcdn.io/v1/publish/123
Response
Status Code: 200 OK
{ "message": "Revision 123 published successfully", "url": "/content"}
Create Redirect
URL: /redirect
Method: POST
Description: Create a redirect from one URL path to another.
Request Body
{ "url": "/url/to/redirect", "redirect_url": "/target/path", "redirect_http_code": 301, "published": true}
Property | Type | Required | Description |
---|---|---|---|
url | string | Yes | The source URL path |
redirect_url | string | Yes | The destination URL path |
redirect_http_code | integer | No | HTTP status code (default: 301) |
published | boolean | No | Whether the redirect is active (default: true) |
Response
Status Code: 200 OK
{ "message": "Redirect created successfully", "url": "/url/to/redirect", "redirect_url": "/target/path"}
Purge Cache
URL: /purge
Method: POST
Description: Purge content from edge caches.
Request Headers
Header | Type | Required | Description |
---|---|---|---|
Quant-Url | string | No | URL path to purge (use /* for entire cache) |
Cache-Keys | string | No | Space-separated cache tags/keys to purge |
Soft-Purge | boolean | No | If true, mark as stale instead of deleting |
Examples
Purge an individual content path:
curl -X POST \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-Url: /content" \ https://api.quantcdn.io/v1/purge
Purge the entire cache:
curl -X POST \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-Url: /*" \ https://api.quantcdn.io/v1/purge
Soft-purge a content path:
curl -X POST \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Quant-Url: /content" \ -H "Soft-Purge: true" \ https://api.quantcdn.io/v1/purge
Purge using cache keys:
curl -X POST \ -H "Quant-Customer: example-customer" \ -H "Quant-Project: example-project" \ -H "Quant-Token: your-project-token" \ -H "Cache-Keys: azbe5 gormb1" \ https://api.quantcdn.io/v1/purge
Response
Status Code: 200 OK
{ "message": "Cache purged successfully", "purged": ["/content"]}
Error Responses
400 Bad Request
{ "error": "Invalid parameter", "message": "URL parameter is required"}
401 Unauthorized
{ "error": "Unauthorized", "message": "Invalid API token"}
404 Not Found
{ "error": "Not found", "message": "Resource not found"}
Rate Limits
The Content API has a rate limit of 100 requests per minute per project. If you exceed this limit, you’ll receive a 429 Too Many Requests response.