Content API
Content API
Section titled “Content API”Overview
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “Endpoints”Send Content
Section titled “Send Content”URL: /v1
Method: POST
Description: Publish HTML content to a specific URL path.
Request Body
Section titled “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
Section titled “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
Section titled “Upload Asset”URL: /v1
Method: POST
Description: Upload static assets like images, JavaScript, CSS, etc.
Request Headers
Section titled “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
Section titled “Request Body”Multipart form data with the file to upload.
Example
Section titled “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
Section titled “Response”Status Code: 200 OK
{ "message": "File uploaded successfully", "url": "/images/banner.jpg", "revision": 1}
Get Metadata
Section titled “Get Metadata”URL: /global-meta
Method: GET
Description: Retrieve metadata about all files in your project.
Response
Section titled “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
Section titled “Get URL Metadata”URL: /url-meta
Method: POST
Description: Retrieve metadata for specific URLs.
Request Body
Section titled “Request Body”{ "Quant-Url": ["/styles.css", "/about-us"]}
Response
Section titled “Response”Similar to the /global-meta
endpoint but filtered to the requested URLs.
Unpublish Content
Section titled “Unpublish Content”URL: /unpublish
Method: PATCH
Description: Unpublish content at a specific URL path.
Request Headers
Section titled “Request Headers”Header | Type | Required | Description |
---|---|---|---|
Quant-Url | string | Yes | The URL path to unpublish |
Example
Section titled “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
Section titled “Response”Status Code: 200 OK
{ "message": "Content unpublished successfully", "url": "/path/to/unpublish"}
Restore Previous Revision
Section titled “Restore Previous Revision”URL: /publish/{revision_id}
Method: PATCH
Description: Restore a previous revision as the published version.
Request Headers
Section titled “Request Headers”Header | Type | Required | Description |
---|---|---|---|
Quant-Url | string | Yes | The URL path of the content |
Example
Section titled “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
Section titled “Response”Status Code: 200 OK
{ "message": "Revision 123 published successfully", "url": "/content"}
Create Redirect
Section titled “Create Redirect”URL: /redirect
Method: POST
Description: Create a redirect from one URL path to another.
Request Body
Section titled “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
Section titled “Response”Status Code: 200 OK
{ "message": "Redirect created successfully", "url": "/url/to/redirect", "redirect_url": "/target/path"}
Purge Cache
Section titled “Purge Cache”URL: /purge
Method: POST
Description: Purge content from edge caches.
Request Headers
Section titled “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
Section titled “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
Section titled “Response”Status Code: 200 OK
{ "message": "Cache purged successfully", "purged": ["/content"]}
Error Responses
Section titled “Error Responses”400 Bad Request
Section titled “400 Bad Request”{ "error": "Invalid parameter", "message": "URL parameter is required"}
401 Unauthorized
Section titled “401 Unauthorized”{ "error": "Unauthorized", "message": "Invalid API token"}
404 Not Found
Section titled “404 Not Found”{ "error": "Not found", "message": "Resource not found"}
Rate Limits
Section titled “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.