Authenticating with Curl
Authentication to the API requires a Client ID and Client Secret, both of which can be found on your Subscribe Pro Environment. Visit System > API Clients and click the View button on the far right of the table to see both credentials.
There are two ways to authenticate with a Client ID and Client Secret: OAuth and Http Basic Authentication.
Authenticating with an OAuth Access Token
Open a command line interface and ensure you have the curl
command installed. Run the following command, substituting "<client_id>" and "<client_secret>" with their respective values.
curl https://api.subscribepro.com/oauth/v2/token -d 'grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>'
You should get a response similar to the following:
{
"access_token": "<access_token>",
"expires_in": 3600,
"token_type": "bearer",
"scope": null,
"refresh_token": "<refresh_token>"
}
In the above, "<access_token>" is an 86-character, alpha-numeric string that can then be used to perform other operations on your Subscribe Pro Environment. It will expire after 3600 seconds (one hour).
As an example, if you wanted to get all of the subscriptions a specific customer has in your Subscribe Pro Environment, you can use the "/services/v2/subscriptions.{_format}" endpoint. {_format} can be one of "xml", "json", and "html". Below, "<customer_id>" is a number corresponding to the Customer ID in Subscribe Pro.
curl https://api.subscribepro.com/services/v2/subscriptions.json?access_token=<access_token>&customer_id=<customer_id>
This will return a JSON-encoded list of all subscriptions associated with that customer.
Authenticating with Http Basic Authentication
NOTE: Basic Authentication is only supported with API v1 and v2 endpoints. It is not currently supported with API v3 endpoints.
Open a shell terminal with curl installed, and type the following command. Substitute "<client_id>" and "<client_secret>" with their respective values. The following command will fetch a JSON-encoded array of data about all subscriptions for the given customer ID.
curl --user <client_id>:<client_secret> https://api.subscribepro.com/services/v2/subscriptions.json?customer_id=<customer_id>
This will return a JSON-encoded list of all subscriptions associated with that customer.