Hear from Slack, the ACLU, TED, & more at our customer summit in San Francisco Register
LOG IN SIGN UP
Documentation

Fastly offers an active content purging system. The API calls related to purging are listed below. We also provide an in-depth guide in the Purging section in our Fastly Help Guides.

As always, if something does not work as expected or differs from the web interface, please contact us right away via our Support Desk or IRC (#fastly on Freenode, or webchat).

Authentication

Nearly all API calls require your request to be authenticated though a few do not. You will use API tokens to authenticate your requests. See our authentication page for more information.

Rate limiting

Certain API calls related to purging are rate limited. See the rate limiting section for details.

API reference

The main entry point for the API is https://api.fastly.com/. For the sake of brevity, examples below omit this.

Purging

Instant Purging removes content from Fastly immediately so it can be refreshed from your origin servers. The main entry point for the API, https://api.fastly.com/, is not needed for an individual URL Instant Purge.


Actions

PURGE /*

Instant Purge an individual URL.

Authentication

Disabled by default. See Authenticating URL purge requests via API to enable.

Parameters
parameter type description
* string

Full path of the URL.

Request Example
curl -X PURGE http://www.example.com/image.jpg
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"status":"ok",
"id":"108-1391560174-974124"
}
POST /service/service_id/purge_all

Instant Purge everything from a service.

Authentication

API token of a user with at least Engineer permissions.

Request Example
POST /service/SU1Z0isxPaozGVKXdv0eY/purge_all
Fastly-Key: YOUR_FASTLY_TOKEN
Accept: application/json
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"status":"ok"
}
POST /service/service_id/purge/key

Instant Purge a particular service of items tagged with a Surrogate Key. Only one surrogate key can be purged at a time. Multiple keys can be purged using a batch surrogate key purge request.

Authentication

API token.

Parameters
parameter type description
key string

Surrogate Key to purge.

Request Example
POST /service/SU1Z0isxPaozGVKXdv0eY/purge/hTE5dRlSBICGPJxJwCH4M
Fastly-Key: YOUR_FASTLY_TOKEN
Accept: application/json
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"status":"ok",
"id":"108-1391560174-974124"
}
POST /service/service_id/purge

Instant Purge a particular service of items tagged with Surrogate Keys in a batch. Multiple surrogate keys can be purged in one batch request.

Authentication

API token.

Request Example
POST /service/SU1Z0isxPaozGVKXdv0eY/purge
Surrogate-Key: key_1 key_2 key_3
Fastly-Key: YOUR_FASTLY_TOKEN
Accept: application/json
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"key_1":"108-1391560174-974124",
"key_2":"108-1391560174-974125",
"key_3":"108-1391560174-974126"
}
POST /service/service_id/purge

Instant Purge a particular service of items tagged with Surrogate Keys in a batch using a JSON POST body.

Authentication

API token.

Request Example
POST /service/SU1Z0isxPaozGVKXdv0eY/purge
Fastly-Key: YOUR_FASTLY_TOKEN
Content-Type: application/json
Accept: application/json
{"surrogate_keys":["key_1","key_2","key_3"]}
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"key_1":"108-1391560174-974124",
"key_2":"108-1391560174-974125",
"key_3":"108-1391560174-974126"
}

Soft Purging

Soft Purging sets an object's TTL to 0s, forcing revalidation. For best results, Soft Purging should be used in conjuction with stale_while_revalidate and stale_if_error. The main entry point http://api.fastly.com/ for the API is not needed for a single URL Soft Purge.


Actions

PURGE /*

Soft Purge an individual URL.

Authentication

Disabled by default. See Authenticating URL purge requests via API to enable.

Parameters
parameter type description
* string

Full path of the URL

Request Example
curl -X PURGE -H "Fastly-Soft-Purge:1" http://www.example.com/image.jpg
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"status":"ok",
"id":"108-1391560174-974124"
}
POST /service/service_id/purge/key

Soft Purge a particular service of items tagged with a key.

Authentication

API token.

Request Example
POST /service/SU1Z0isxPaozGVKXdv0eY/purge/hTE5dRlSBICGPJxJwCH4M
Fastly-Key: YOUR_FASTLY_TOKEN
Accept: application/json
Fastly-Soft-Purge: 1
Response Example
HTTP/1.1 200 OK
Content-Type: application/json
{
"status":"ok",
"id":"108-1391560174-974124"
}