API v2 Changelog

< Back to Changelog

Support for Spaces CDN Endpoints

Date: September 27, 2018

Tagged In: API v2

Author Andrew Starr-Bochicchio

Today’s release brings Content Delivery Network (CDN) support to Spaces, DigitalOcean’s object storage solution. This can be configured and managed using our API. By sending requests to /v2/cdn/endpoints, you can list, create, or delete CDN endpoints as well as purge cached content.

To enable the CDN for your Space, send a POST request to /v2/cdn/endpoints. In the JSON body of your request, specify the origin of your content and the desired TTL. For example:

{
  "origin": "static-images.nyc3.digitaloceanspaces.com",
  "ttl": 3600
}

Currently, the origin must be a DigitalOcean Space.

To purge cached content from a CDN endpoint, send a DELETE request to /v2/cdn/endpoints/$ENDPOINT_ID/cache. The body of the request should include a files attribute containing a list of cached file paths to be purged. A path may be for a single file or may contain a wildcard (*) to recursively purge all files under a directory. When only a wildcard is provided, all cached files will be purged. For example, the body of your request might look like:

{
  "files": [
    "assets/img/hero.png",
    "assets/css/*"
  ]
}

For additional details, see the API reference documentation for managing CDN endpoints.