We launched the multi-tenant WordPress Marketplace! 🎉

Creating tenants with Zapier

sybren@wpcs.io

The WPCS API can be used as an action in Zapier zaps. In this article, we will create a Zapier action that creates a tenant.

This article assumes you already have a Zapier account and are able to use the premium action Webhooks. Let’s start creating tenants with Zapier!

Add a Webhooks by Zapier action to your zap

Firstly, add an action using the app Webhooks by Zapier.

Add action

Then, choose the Action Event called POST.

Pick post action event

Press continue.

Set up your action

To set up the action, we need to fill in some data.

  • Data
  • Wrap
  • Request
  • In Array
  • File
  • Unflatten
  • Basic Auth
  • Headers

URL

Fill in the URL field with https://api.eu1.wpcs.io/v1/tenants.

Payload Type

In the Payload Type dropdown, choose the JSON option. Any other option will not work.

Data

The data we will send to the WPCS API is the actual description of the tenant we want to create. You can read more about how you can define the tenant data here.

For now, let’s assume the following:

  1. Your own administrative system has given your customer the unique ID 9999. This will be the external ID

    NOTE
    The external ID must be unique. When a tenant with a certain external ID already exists, WPCS will respond with a 409 Conflict HTTP status code. The reason this value must remain unique is because actions like deleting a tenant can be based on this value, if you would have two tenants with the same external ID, WPCS would not be able to tell which tenant should be deleted.
  2. You want the tenant to be created under the name Doe Corp.
  3. Your customer’s username should be johndoe.
  4. Your customer’s E-mail is john@doecorp.com.
  5. Your customer filled in the password 123verystrong123 in your signup form.

This means the data you filled in for the action so far should look like this:

Static data example

Of course, we don’t want to create the same tenant over and over again. The static values you have filled in (9999Doe Corp or 123verystrong123 for example) should be replaced by fields from the Zapier Trigger that precedes the action. You can read more about how data passes through Zapier zaps at https://zapier.com/help. When you have configured your Trigger properly, Zapier will show you the available options.

DANGER

If you allow your customers to specify a password, make sure it is never displayed or stored in plain text.

Wrap Request In Array

Pick the No option.

File

The File field should be left empty.

Unflatten

Pick the Yes option.

Basic Auth

We need to authenticate Zapier to allow it to call the WPCS API. To do this, we need WPCS API keys. You can read more about those here. For now, let’s assume you have created an API key for Zapier. The created API key has the value 12345678-1234-1234-1234-1234567890ab, and its secret has the value 11112222333344445555.

Fill in the Basic Auth field with the following value, note the pipe symbol (|) separating the two values:

12345678-1234-1234-1234-1234567890ab|11112222333344445555

Headers#

This field can be left as-is. The WPCS API does not require additional headers.

Test your action

After setting up the action as described above, you can test your action. With the data above, the test section should look something like this:

Action test section

When you test the action, you should see a new tenant be created in the WPCS Console under the product you made your API key for.

CAUTION

Be sure to clean up your test tenants to avoid incurring unnecessary costs. Go to the tenant and click ‘Delete tenant’ under the ‘Actions’ dropdown.

Build a low code SaaS today

Start a 30-day free trial – Cancel anytime

Plugin name

Author

Zapier

Description

The WPCS API can be used as an action in Zapier zaps. In this article, we will create a Zapier action that creates a tenant. This article assumes you already have a Zapier account and are able to use the premium action Webhooks.

Code Snippet