Download the PHP package sparkpost/sparkpost without Composer

On this page you can find all versions of the php package sparkpost/sparkpost. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.


After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

All versions of sparkpost with dependencies

Informations about the package sparkpost

Sign up for a SparkPost account and visit our Developer Hub for even more content.

SparkPost PHP Library

Travis CI Coverage Status Downloads Packagist

The official PHP library for using the SparkPost REST API.

Before using this library, you must have a valid API Key. To get an API Key, please log in to your SparkPost account and generate one in the Settings page.


Please note: The composer package sparkpost/php-sparkpost has been changed to sparkpost/sparkpost starting with version 2.0.

The recommended way to install the SparkPost PHP Library is through composer.

Sparkpost requires php-http client (see providers available. If you were using guzzle6 your install might look like this.

Next, run the Composer command to install the SparkPost PHP Library:

After installing, you need to require Composer's autoloader:

Note: Without composer the costs outweigh the benefits of using the PHP client library. A simple function like the one in issue #164 wraps the SparkPost API and makes it easy to use the API without resolving the composer dependencies.

Running with IDEs

When running with xdebug under an IDE such as VS Code, you may see an exception is thrown in file vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php:

This is usual. Puli is not required to use the library. You can resume running after the exception.

You can prevent the exception, by setting the discovery strategies, prior to creating the adapter object:

Setting up a Request Adapter

Because of dependency collision, we have opted to use a request adapter rather than requiring a request library. This means that your application will need to pass in a request adapter to the constructor of the SparkPost Library. We use the HTTPlug in SparkPost. Please visit their repo for a list of supported clients and adapters. If you don't currently use a request library, you will need to require one and create a client from it and pass it along. The example below uses the GuzzleHttp Client Library.

A Client can be setup like so:


new Sparkpost(httpClient, options)


request(method, uri [, payload [, headers]])

syncRequest(method, uri [, payload [, headers]])

Sends a synchronous request to the SparkPost API and returns a SparkPostResponse

asyncRequest(method, uri [, payload [, headers]])

Sends an asynchronous request to the SparkPost API and returns a SparkPostPromise






Send An Email Using The Transmissions Endpoint

More examples here:



Message Events

Send An API Call Using The Base Request Function

We provide a base request function to access any of our API resources.

Be sure to not have a leading / in your resource URI.

For complete list of resources, refer to API documentation.

Handling Responses

The API calls either return a SparkPostPromise or SparkPostResponse depending on if async is true or false



Asynchronous an be handled in two ways: by passing callbacks or waiting for the promise to be fulfilled. Waiting acts like synchronous request.

Wait (Synchronous)
Then (Asynchronous)

Handling Exceptions

An exception will be thrown in two cases: there is a problem with the request or the server returns a status code of 400 or higher.



See contributing.

Requires php Version ^7.1 || ^8.0
php-http/httplug Version ^1.0 || ^2.0
php-http/message Version ^1.0
php-http/client-implementation Version ^1.0
php-http/discovery Version ^1.0

The package sparkpost/sparkpost contains the following files

Loading the files please wait ....