Edgio
Edgio

REST API

This guide covers the REST API provided by Edgio.

Authentication

To gain access to the api, provide a deploy token via the x-api-key header. Deploy tokens can be created from a site’s settings tab in the Edgio Developer Console.

Methods

clear-cache

POST https://app.layer0.co/api/v1/clear-cache

Purges entries from the cache for a specific environment. You can purge specific paths or surrogate keys. If no paths or surrogate keys are provided all entries will be purged.

Request Headers

The following request headers are required:

  • x-api-key: A site deploy token
  • content-type: "application/json"

Body

Provide the following parameters as JSON in the post body. Note that only one of the optional arguments can be passed at a time, for example paths and surrogateKeys cannot be cleared at once.

JSON
1{
2 "team": "the team name",
3 "site": "the site name",
4 "environment": "the environment name",
5 "paths": ["Optional. An array of paths to clear. Use * as a wildcard."],
6 "surrogateKeys": ["Optional. An array of surrogate keys to clear"],
7 "cacheHashes": ["Optional. An array of cache hashes to clear"]
8}

Example:

JavaScript
1const fetch = require('node-fetch')
2
3const deployToken = '*****'
4const team = 'my-team'
5const site = 'my-site'
6const environment = 'production'
7const paths = ['/some/path']
8
9async function clearCache() {
10 const res = await fetch('https://app.layer0.co/api/v1/clear-cache', {
11 method: 'POST',
12 headers: {
13 'content-type': 'application/json',
14 'x-api-key': deployToken,
15 },
16 body: JSON.stringify({
17 team,
18 site,
19 environment,
20 paths,
21 }),
22 })
23
24 console.log('Status:', res.status, res.statusText)
25 console.log('Body:', await res.text())
26}
27
28clearCache()