Enabling Prefinery API Access

Before you proceed, please keep these best practices in mind when using our API:

  • Always keep your API key a secret as it can be used to access your account. 
  • Never call the API from front-end code, such as a Single Page Application (SPA) as this would expose the API key publicly. Instead, you can follow our recommendations on how to use Prefinery with JavaScript Frameworks

Using our API, you can connect your Prefinery project with other web services, including your own website or application, and even no-code automation tools.  

Creating/Editing an API Key

Here's how you can create or edit an API key: 

1

From your Prefinery dashboard, click on your settings menu at the upper-right corner and select Company Settings on the dropdown. 

Alternatively, from your project dashboard you can navigate to Installation > 2. Push Users into Prefinery > Build Your Own Integration with our REST API > enable the API. This will bring you to the same page as step #2 below. 

2

In the Company Settings page, go to API Keys and then click the Create API Key button to generate a new API key. 

3

Give your new key an identifiable name and set usage permissions for this key. 

Setting the proper permissions allow you to limit and therefore secure access to your campaign. For example, you may want to make sure that the key can't be used to accidentally delete a project. 

Here's what each of these permissions does: 

Projects 

  • Read: Receive a list of all projects or get information about a specific project (e.g. users total, users count by status, etc.) by its ID. 
  • Delete: Delete a project by its ID. 

Users 

  • Create: Create a new user on a particular project using their email address (required) and other information (e.g. name, status, custom responses, etc.). 
  • Read: Receive a list of all users in the project or get information about a specific user (e.g. email, status, referral count, etc.) by their ID.
  • Update: Update a user's information by their ID or Checkin a user.
  • Delete: Delete a user by their ID from a particular project. 

Points

  • Create: Manually issue points to a specific user (by email address). 

Rewards

  • Create: Manually issue a reward (by descriptor) to a specific user (by email address). 
  • Read: Receive a list of all rewards in the project or get information about a specific reward (e.g. descriptor, type, user role, etc.) by its ID. 
  • Update: Mark a reward as delivered or revoked

Suppressions

  • Create: Add an email address to the suppressions list. 
  • Read: Receive a list of all email suppressions.
  • Delete: Remove a Manual or HardBounce suppression and reactivate the email address for email delivery.

Friend Invitations

Webhook Subscriptions

  • Create: Allow 3rd party apps to connect to your project and receive events. 
  • Read: Allow 3rd party apps to view the status of their connection.
  • Delete: Allow 3rd party apps to disconnect from your project and no longer receive events.

Webhook Events

  • Read: Allow 3rd party apps to get more details on events that happen in your project.

Full permissions to Webhook Subscriptions and Webhook Events are required in order to connect Prefinery to 3rd party apps such as Zapier, Make, Pabbly Connect, Integrately and Sync Spider.

4

Copy your key by clicking on it to use it for you intended purpose. 

You also have the option to Edit your key permissions or set it to Expire

When you Expire a key which happens immediately, all API calls using this key will fail, and the key will be in the Expired Keys section that appears right under Active Keys. You can Reactivate the key at any time.

You also have the option to Delete an expired key which permanently removes it from your account making it irretrievable. 

Tip: You can create multiple keys and give each a unique name. This allows you to do key rotation / rolling by adding a new key, updating your codebase to use the new key, expiring the old key once it's no longer being used, testing your integration works, and finally, deleting the old key.

The API Docs button will direct you to our comprehensive API Documentation

Getting your {beta_id}

Except for the betas#list API call, all other requests require you to specify your project/campaign's {beta_id} which can be either your Project UID or its API Beta ID

For example, a betas#show request can be made as follows where 12345 is the campaign's API Beta ID

curl https://api.prefinery.com/api/v2/betas/12345.json?api_key=secret

That request can also be written as follows where the Project UID a9b8c7de of the same campaign is used instead: 

curl https://api.prefinery.com/api/v2/betas/a9b8c7de.json?api_key=secret

Either requests work and will get the same response from Prefinery. 

As another example, the following testers#list request uses the Project UID a9b8c7de

curl https://api.prefinery.com/api/v2/betas/a9b8c7de/testers.json?api_key=secret

To get  your   {beta_id}  , from your project dashboard just navigate to Settings > General as shown below: 

Still need help? How can we help? How can we help?