Overview
Introduction to Rewardful's REST API
The Rewardful API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
We highly recommend checking out Insomnia, a desktop app that makes testing API requests and responses a breeze 👍
Authentication
All API requests require authentication with HTTP Basic Auth, similar to how Stripe authenticates. Provide your API Secret as the basic auth username
value. You do not need to provide a password.
Be sure to replace YOUR_API_SECRET
with your actual API Secret. For example, if your API secret was ABC123
, the curl
command to fetch all affiliates would be:
Your API Secret can be found on the Company Settings page.
Keep your API Secret safe!
Your API Secret grants full access to your Rewardful account. Do not:
Share your API Secret with third parties
Commit your API Secret to version control (i.e. Git)
Share your API Secret over email or chat
Send your API Secret to the web browser in HTML or JavaScript
Contact us as soon as possible if you believe your API Secret has been compromised so we can rotate it for you.
Request and Response Formats
Rewardful will provide a JSON-based REST API through which merchants can create affiliate accounts and fetch data for reporting. Endpoints accept form-encoded request bodies and return JSON-encoded responses.
Rewardful uses UUID strings for primary keys (IDs) for all resources. If you plan to store Rewardful IDs in your database, make sure to use a column type (string, UUID, etc) appropriate for your database engine.
Dates and times in the Rewardful API are represented as ISO 8601 formatted strings.
Errors
Missing or invalid authorization will return a 401 Unauthorized
JSON response:
Requesting a nonexistent object will return a 404 Not Found
JSON response:
Passing invalid data to a create/update endpoint will return a 422 Unprocessable
Entity JSON response:
Pagination
API endpoints that return a list of objects include pagination, unless noted otherwise. The data structure has two root objects:
The `pagination` object
Example
This example demonstrates the pagination
for a collection of 150 objects in total, split into 3 pages of 50 objects per page:
Expanding objects
Many objects allow you to request additional information as an expanded response by using the expand
request parameter. You can use expand
to expand a single type of object, or expand[]
to expand multiple types of objects.
The documentation for each endpoint will list which objects are expandable (if any) for that endpoint.
For example, to expand an affiliate
you would prepend this query string parameter to the request URL:
To expand both affiliate
and sale
objects, prepend this query string parameter to the request URL:
Rate limits
The Rewardful REST API uses rate limiting to help maximize its uptime and stability. Users who send many requests in quick succession may see error responses that show up as HTTP status code 429
. These 429
responses will include RateLimit header fields which you can use to gracefully handle failures and retry requests when your quota resets.
In most cases the API rate limit is 45 requests per 30 second window. Please treat these limits as absolute maximums and do not generate unnecessary load.
If you plan to run a batch script (such as programmatically creating many affiliates via API), please throttle your API usage by adding sleep/delay mechanisms to your script. We may reduce limits at any time to prevent abuse.
Last updated