OptimizeMentor Webhooks
Getting started
OptimizeMentor webhooks are used to preform basic actions on your OptimizeMentor content and members. It uses the WordPress REST API as a base.
The base URL for the can be found under OptimizeMentor / Settings / API Settings. So all endpoints need to have this URL set as the base.
Under the same settings page you can find your API Key which will be used for authorizing your requests.
Authentication
You can authenticate your request by passing the API Key as a header parameter. The header parameter needs to be called: X-OPM-API-KEY. So the request looks something like this:
curl -H "X-OPM-API-KEY: YOUR-API-KEY" http://YOUR-BASE-URL/memberships
Another way to authenticate your requests it to simply send the API key via a query string, like this:
curl http://YOUR-BASE-URL/memberships?opm_api_key=YOUR-API-KEY
Endpoints
GET /memberships
Returns a list of your memberships. Example of returned data in JSON format:
{
"status": 200,
"data": [
{
"id": 1,
"title": "Gold",
"priority": 1,
"override_redirects": false,
"login_redirect_id": 8121,
"after_login_redirect_id": 8117,
"after_register_redirect_id": "8119",
"protected_redirect_id": 8125,
"drip_redirect_id": "8123",
"access_duration": "lifetime",
"expires_in_type": "years",
"expires_in_value": 1,
"expires_at": null,
"created_at": "2022-06-15 08:05:36",
"updated_at": "2022-06-15 08:05:36"
},
{
"id": 2,
"title": "Silver",
"priority": 2,
"override_redirects": false,
"login_redirect_id": 8121,
"after_login_redirect_id": 8117,
"after_register_redirect_id": "8119",
"protected_redirect_id": 8125,
"drip_redirect_id": "8123",
"access_duration": "lifetime",
"expires_in_type": "years",
"expires_in_value": 1,
"expires_at": null,
"created_at": "2022-06-15 10:11:09",
"updated_at": "2022-06-15 10:11:09"
}
]
}
GET /members
Get all your members. The results are limited to max 20 results.
Available incoming parameters are:
Name | Type | Default | Required |
per_page | int | 20 | No |
page | int | 1 | No |
Example of returned data in JSON format:
{
"status": 200,
"data": {
"total_pages": 1,
"total_items": 19,
"current_page": 1,
"per_page": 20,
"items": [
{
"id": 109,
"email": "admin@admin.com",
"username": "admin",
"first_name": "Admin",
"last_name": "Administrator",
"full_name": "Admin Administrator",
"display_name": "Admin Administrator",
"url": "",
"registered_at": "2022-06-15 12:13:42",
"last_login": "2022-06-15 12:14:26",
"previous_login": "2022-06-15 12:13:56"
},
{
"id": 1,
"email": "user@user.com",
"username": "user",
"first_name": "User",
"last_name": "The User",
"full_name": "User The User",
"display_name": "User The User",
"url": "",
"registered_at": "2022-02-18 21:53:52",
"last_login": "2022-06-20 07:50:38",
"previous_login": "2022-06-17 07:57:00"
}
]
}
}
POST /members
Create a new member for your site.
Available incoming parameters are:
Name | Type | Default | Required |
string | Yes | ||
first_name | string | No | |
last_name | string | No | |
notify | bool | false | No |
memberships | array/string | No |
Example response:
{
"status": 200,
"data": {
"id": 128,
"email": "user@email.com",
"username": "user@email.com",
"first_name": "John",
"last_name": "Smith",
"full_name": "John",
"display_name": "Smith",
"registered_at": "2022-06-23 10:10:52",
"last_login": null,
"previous_login": null
}
}
If a member with the same email address exists, then the response looks like this:
{
"code": 409,
"message": "Error occurred when creating a new member: Member already exists.",
"data": {
"status": 409
}
}
POST /members/{member_id}/add-membership
Attach an existing membership to a member. You need to pass the ID of the user into the URL, and pass the membership ID through the POST parameters.
Available incoming parameters are:
Name | Type | Default | Required |
membership_id | int | Yes |
Example response:
{
"status": 200,
"data": {
"member": {
"id": 128,
"email": "user@email.com",
"username": "user@email.com",
"first_name": "John",
"last_name": "Smith",
"full_name": "John",
"display_name": "Smith",
"registered_at": "2022-06-23 10:10:52",
"last_login": null,
"previous_login": null
"memberships": [
{
"id": 2,
"title": "Silver",
"priority": 2,
"override_redirects": false,
"access_duration": "lifetime",
"expires_in_type": "years",
"expires_in_value": 1,
"expires_at": null,
"created_at": "2022-06-15 10:11:09",
"updated_at": "2022-06-15 10:11:09"
}
]
}
}
}
POST /members/{member_id}/remove-membership
Remove an existing membership from a member. You need to pass the ID of the user into the URL, and pass the membership ID through the POST parameters.
Name | Type | Default | Required |
membership_id | int | Yes |
Available incoming parameters are:
Example response:
{
"status": 200,
"message": "Membership removed",
"data": {
"message": "Membership removed"
}
}
POST /members/{member_id}/delete
Delete a member from your site You need to pass the ID of the user into the URL.
Example response:
{
"status": 200,
"message": "Member deleted.",
"data": {
"message": "Member deleted."
}
}
Webhooks
This is a simpler way to use the API. This way of invoking the API is best used inside the Rules Engine in OptimizePress Dashboard.
A few examples are below:
Create new member
Create a webhook with a POST request type and enter the following URL:
http://YOUR-BASE-URL/members?memberships=1,2,3&opm_api_key=YOUR_API_KEY
Assign membership to member (by email)
Create a webhook with a POST request type and enter the following URL:
http://YOUR-BASE-URL/members/add-membership?membership_id=3&opm_api_key=YOUR_API_KEY
Remove membership from member (by email)
Create a webhook with a POST request type and enter the following URL:
http://YOUR-BASE-URL/members/remove-membership?membership_id=3&opm_api_key=YOUR_API_KEY