Net::Fastly - client library for interacting with the Fastly web acceleration service


    my $fastly = Net::Fastly->new(%login_opts);
    my $current_user     = $fastly->current_user;
    my $current_customer = $fastly->current_customer;
    my $user     = $fastly->get_user($current_user->id);
    my $customer = $fastly->get_customer($current_customer->id);
    print "Name: ".$user->name."\n";
    print "Works for ".$user->customer->name."\n";
    print "Which is the same as ".$customer->name."\n";
    print "Which has the owner ".$customer->owner->name."\n";
    # Let's see which services we have defined
    foreach my $service ($customer->list_services) {
        print $service->id."\n";
        print $service->name."\n";
        foreach my $version ($service->versions) {
            print "\t".$version->number."\n";
    my $service        = $fastly->create_service(name => "MyFirstService");
    my $latest_version = $service->version;
    # Create a domain and a backend for the service ...
    my $domain         = $fastly->create_domain(service_id => $service->id, version => $latest_version->number, name => "");
    my $backend        = $fastly->create_backend(service_id => $service->id, version => $latest_version->number, ipv4 => "", port => 80);
    # ... and activate it. You're now hosted on Fastly.
    # Let's take a peek at the VCL that Fastly generated for us
    my $vcl = $latest_version->generated_vcl;
    print "Generated VCL file is:\n".$vcl->content."\n";
    # Now let's create a new version ...
    my $new_version    = $latest_version->clone;
    # ... add a new backend ...
    my $new_backend    = $fastly->create_backend(service_id => $service->id, version => $new_version->number, ipv4 => "", port => 8080);
    # ... and upload some custome vcl (presuming we have permissions)
    $new_version->upload_vcl($vcl_name, slurp($vcl_file));    



new <opt[s]>

Create a new Fastly client. Options are

user - your Fastly login
password - your Fastly password
api_key - your Fastly api key

You only need to pass in api_key OR user and password.

Some methods require full username and password rather than just auth token.


Get the current Net::Fastly::Client


Whether or not we're authed at all by either username & password or API key


Whether or not we're fully (username and password) authed


Return a User object representing the current logged in user.


Return a Customer object representing the customer of the current logged in user.


Return a hash representing all commands available.

Useful for information.

purge <path>

Purge the specified path from your cache.

create_user <opts>

create_customer <opts>

create_service <opts>

create_version service_id => <service id>, [opts]

create_backend service_id => <service id>, version => <version number>, name => <name> <opts>

create_director service_id => <service id>, version => <version number>, name => <name> <opts>

create_domain service_id => <service id>, version => <version number>, name => <name> <opts>

create_match service_id => <service id>, version => <version number>, name => <name> <opts>

create_origin service_id => <service id>, version => <version number>, name => <name> <opts>

create_vcl service_id => <service id>, version => <version number>, name => <name> <opts>

Create new objects.

get_user <id>

get_customer <id>

get_service <id>

get_version <service id> <number>

get_backend <service id> <version number> <name>

get_director <service id> <version number> <name>

get_domain <service id> <version number> <name>

get_match <service id> <version number> <name>

get_origin <service id> <version number> <name>

get_vcl <service id> <version number> <name>

get_version <service id> <version number> <name>

get_settings <service id> <version number>

Get existing objects.

update_user <obj>

update_customer <obj>

update_service <obj>

update_version <obj>

update_backend <obj>

update_director <obj>

update_domain <obj>

update_match <obj>

update_origin <obj>

update_vcl <obj>

update_version <obj>

update_settings <obj>

Update existing objects.

Note - you can also do


delete_user <obj>

delete_customer <obj>

delete_service <obj>

delete_version <obj>

delete_backend <obj>

delete_director <obj>

delete_domain <obj>

delete_match <obj>

delete_origin <obj>

delete_vcl <obj>

delete_version <obj>

Delete existing objects.

Note - you can also do



Get a list of all the services that the current customer has.

search_services <param[s]>

Search all the services that the current customer has.

In general you'll want to do

        my @services = $fastly->search_services(name => $name);


        my ($service) = $fastly->search_services(name => $name, version => $number);

list_invoices [<year> <month>]

Return an array of Net::Fastly::Invoice objects representing invoices for all services.

If a year and month are passed in returns the invoices for that whole month.

Otherwise it returns the invoices for the current month so far.


load_options <file>

Attempts to load various config options in the form

   <key> = <value>

From a file.

Skips whitespace and lines starting with #.

get_options <file[s]>

Tries to load options from the file[s] passed in using, load_options, stopping when it finds the first one.

Then it overrides those options with command line options of the form



Copyright 2011 - Fastly Inc

Mail support at fastly dot com if you have problems.