Introduction
Welcome to the UserWise platform API documentation page!
This website is here to provide you and your team with all the necessary documentation to get up and running with our platform.
Security
Authentication
# Header Authentication Example
curl https://api.userwise.io/api/v1/countries
-H 'X-Api-Key: NTAyMTVhOGQtZjFhMy00ZjI0LThiYmQtNzExZTdmMzcyMWE4'
# Query Parameter Authentication Example
curl https://api.userwise.io/api/v1/countries?api_key=50215a8d-a1a3-4f24-8xbd-721e763721a8
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI("https://api.userwise.io/api/v1/countries")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request["X-Api-Key"] = Base64.encode64("50215a8d-a1a3-4f24-8xbd-721e763721a8")
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: "https://api.userwise.io/api/v1/countries",
content_type: "application/json",
headers: {
"X-Api-Key": Base64.encode64("50215a8d-a1a3-4f24-8xbd-721e763721a8")
}
)
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/countries",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"X-Api-Key: " . base64_encode("50215a8d-a1a3-4f24-8xbd-721e763721a8")
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/countries"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("50215a8d-a1a3-4f24-8xbd-721e763721a8")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/countries",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("50215a8d-a1a3-4f24-8xbd-721e763721a8").toString('base64')
}
};
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write();
request.end();
All requests made via either the server or sdk API requires the use of API key based authentication.
There are two primary methods for authenticating via your API key:
- Provide your base64 encoded API key in the
X-Api-Key
HTTP header. - Provide your API key in the
api_key
query parameter.
HTTP Header Encoder for API Keys
IP Whitelisting (Optional)
Within your app's api settings page, you can provide a list of whitelisted static IP addresses. The IP addresses provided only pertain to the server-to-server api requests. Requests that do not originate from one of the IPs provided will be rejected.
To enable this feature go to your app's api settings and provide a list of ip addresses.
Request Hashing (Required)
The What?
Request hashing is used by UserWise to validate the authenticity of a given request. We do this through hashing api requests, along with your company’s secret key. The hashing algorithm used currently defaults to sha3-256, which is the recommended algorithm to be used with our system.
The Why?
Request hashing is a required feature of the UserWise API that allows us to validate the authenticity of API requests made on your company's behalf.
The How?
Request hashing is accomplished by creating a hash of your request url (including query parameters), your company’s secret key, and the request's raw post body (if provided). The hashed value is then added to the end of your request url using the enc query parameter.
# Using rhash
echo "{{ request_url }}{{ json_body}}{{ secret_key }}" > /tmp/checksum_test
rhash --sha3-256 /tmp/checksum_test
require 'sha3'
request_url = 'https://api.userwise.io/api/v1/countries'
json_body = { :key => 'value' }
secret_key = 'abcd1234'
secret_url = request_url + json_body.to_json + secret_key
hash = SHA3::Digest.hexdigest :sha256, secret_url
hashed_url = request_url + '?enc=' + hash
<?php
$request_url = 'https://api.userwise.io/api/v1/countries';
$json_body = ['key' => 'value'];
$secret_key = 'abcd1234';
$secret_url = $request_url . json_encode($json_body) . $secret_key;
$hash = hash('sha3-256', $secret_url);
$hashed_url = $request_url . '?enc=' . $hash;
import json
import hashlib
request_url = 'https://api.userwise.io/api/v1/countries'
json_body = { 'key': 'value' }
secret_key = 'abcd1234'
secret_url = "{}{}{}".format(request_url, json.dumps(json_body), secret_key)
h = hashlib.sha3_256()
h.update(secret_url.encode('utf-8'))
hashed_url = "{}?enc={}".format(request_url, h.hexdigest())
const { SHA3 } = require('sha3');
const requestUrl = 'https://api.userwise.io/api/v1/countries';
const jsonBody = { 'key': 'value' };
const secretKey = 'abcd1234';
const secretUrl = requestUrl + JSON.encode(jsonBody) + secretKey;
const hash = new SHA3(256);
hash.update(secretUrl);
hashedUrl = `${requestUrl}?enc=${hash.digest('hash')}`;
GET/DELETE Requests
Given the values
Request URL: https://userwise.io/api/endpoint?param_one=value_one
Company Secret Key: UbsXaKTGWNd3wD8y5ZeV
we hash them
hashfunc('https://userwise.io/api/endpoint?param_one=value_oneUbsXaKTGWNd3wD8y5ZeV')
which gives the hash
5d0cf6bfeca88e853cd4330cffaaed87febb5038b3c4835681f8f34d8966dc27
and gets added to the URL's query params
https://userwise.io/api/endpoint?param_one=value_one&enc=5d0cf6bfeca88e853cd4330cffaaed87febb5038b3c4835681f8f34d8966dc27
POST/PUT Requests
Given the values
Request URL: http://www.example.com/endpoint
Company Secret Key: UbsXaKTGWNd3wD8y5ZeV
Payload: {“key”:“value”}
we hash them
hashfunc('https://userwise.io/api/endpoint{“key”:“value”}UbsXaKTGWNd3wD8y5ZeV')
which gives the hash
1c3893648029aa032e8eec93fb5e5db9347abf7d36c107db3409de975f1f4290
and gets added to the URL's query params or JSON Payload
https://userwise.io/api/endpoint?enc=1c3893648029aa032e8eec93fb5e5db9347abf7d36c107db3409de975f1f4290
Guides
Environments
UserWise environments are designed to facilitate content and configuration at the various stages of your app's lifecycle, such as development, quality assurance, and production. You have the flexibility to create and configure these environments directly through the UserWise dashboard.
It's important to note that nearly all server-to-server API endpoints necessitate the specification of an environment. This environment selection is determined by a combination of your app_id
and an environment_stage
, which corresponds to the specific key defined for that environment.
In addition to server-to-server API endpoints, you must also define an environment when creating new user sessions. This ensures that the user is associated with the correct environment and that their data is processed accordingly.
Environment Types
UserWise has three environment types: dev
, qa
, & live
.
Dev Type
While there is a seeming correlation between your application's development environments and UserWise's development environments, they are functionally different.
UserWise's dev environments are for the development of campaigns, journeys, & content. Meaning, dev environments do not have the ability to access content or to create player sessions!
QA Type
Quality assurance environment types are one of the two environment types which can have player sessions, and can have accessible content.
Campaigns, journeys, and general content are shared with QA environments, from a dev environment. Each time anything is shared with a QA environment, we generate a release. Releases make the current configuration of the objects immutable, and any new changes within the parent dev environment will be accrued as non-sync'd. This enables rapid development and testing to occur in parallel.
Live Type
Live environment types are one of the two environment types which can have player sessions, and can have accessible content.
Campaigns, journeys, and general content are shared with Live environments, from a dev environment. Each time anything is shared with a Live environment, we generate a release. Releases make the current configuration of the objects immutable, and any new changes within the parent dev environment will be accrued as non-sync'd. This enables development to continue, or configuration changes to be applied and tested while still delivering the content within your live environment.
Journeys and Odysseys
What is a Journey?
A Journey is designed to enable you to guide your players through personalized experiences, based on specific segmentation criteria or triggers (actions).
Creating and Updating Journeys
While you may use the Journeys CRUD API to manage Journeys, the Journey Canvas within the dashboard is the recommended tool for creating and updating Journeys.
The Journey Canvas is a specially crafted tool to help teams visualize and plan the personalized experiences they wish to create.
What are Edges?
Edges are the connections between two Steps within a Journey. Entry edges will contain no from_id
, but will always point to a Step. Each Edge controls the path that a player MAY take throughout a Journey.
There are three types of Edges:
Default Edges
A Default Edge is a path that once a player has encountered, they will always follow. Default Edges are indicated by edges having the type
of default
.
Branch Edges
A Branch Edge is a path that comes from a Branching Step. Branch Edges are indicated by edges having the type
of branch
, and have custom config
properties: { "outcome": "yes|no", "label_background_color: "" }
.
Once a player has encountered a Branch Edge, they will be routed based on the outcome of the branching logic.
Engagement Outcome Edges
An Engagement Outcome Edge is a path that comes from a Content Step which have an advancement criteria of Engagement Outcome. Engagement Outcome Edges are indicated by edges having the type
of engagement_outcome
, and have custom config
properties: { "engagement_outcome_key": "" }
.
When a player encounters Engagement Outcome-based Advancement, they will be sticky to the current Step until a matching Engagement Outcome is received.
What are Steps?
A Journey is made up of a series of Steps, which are interconnected via Edges. Each Step can be content-based, or control flow-based.
There are two primary types of Steps:
Content Steps
Content Steps are designed to enable you and your team to deliver personalized pieces of content to your players. When a player enters a content Step, they will remain sticky to that Step until they:
- The player receives that content
- The player meets the advancement criteria of the content Step
Content Steps may be configured to deliver:
- Emails
- Events
- In-app Messages
- Offers
- Push Notifications
Control Flow Steps
Control Flow Steps are designed to enable the creation of personalized pathways the player may emabark upon.
When a player enters a control flow Step, advancement criteria is defined as immediate, but when that advancement occurs is Step-dependent:
- Branching: The player will be immediately routed through their customize pathway, based on the outcome of the branching logic. Potential types are: segment or trigger based.
- Delay: The player will be once the criteria has been met. Potential types are: time or trigger based delays.
- Exit: The player will not advance to any further steps in the Journey, and their active Odyssey will be marked as completed.
Step Advancement
Advancement at Player Entry
When a player enters the Journey, they are immediately routed to all entry Step(s). Entry Steps are indicated by having incoming Edges which have a from_id
of null
.
Advancement While Active
Journey Step Advancement is determined by each Step's advancement criteria.
Advancement criteria can be one of:
- Immediate: The player will be immediately routed to the next Step (upon Step processing time).
- Engagagement Outcome: The player will be routed to the next Step based on the outcome of the engagement. Outcomes can be defined through the dashboard or the Engagement Outcomes CRUD API.
With the caveat that all control flow Steps are designed to always be Immediate.
Players and Journeys
Embarking upon a Journey (Odyssey)
When players enter a Journey they embark on a personalized experience (an Odyssey). Each Step of the Journey that a player encounters is recorded as an Odyssey Leg.
During their Odyssey, players may encounter one or more legs, and may even have multiple legs active at a given time.
The steps that a player will receive at the start is covered in the Journey Step Advancement section.
Advancing through the Odyssey
Each advancement while an Odyssey is active is determined by the advancement criteria of the Step.
Exiting a Journey
A player's Odyssey ends when a qualifying exit event has occurred. Some potential exit events are:
- The player has exhausted all Steps in the Journey
- The player has activated an exit Step
- Some exit Steps may be configured to include side-effects such as: entering/starting a Journey, or exiting/ending an active Odyssey
- Exit Steps will always always exit the player from their current Odyssey.
Integrating with Journeys
The amount of integration required to get started with Journeys is dependent on the complexity of your use case. The following sections will guide you through the necessary steps to get started.
How do I retrieve active content?
With the v1 Player Session API, we've integrated Journeys to function similarly as Scheduled Campaigns. To learn about how to retrieve active content, please refer to the Player Session API and/or the Unity SDK Integration Guide.
This enables previous integrations to easily use Journeys without needing to alter much of their content retrieval integration. Though, being reactive to emitted Webhook Events is recommended for Server-to-Server, and would require additional integration changes.
How does advancement work in the integration?
Most advancements from one step to another are handled by UserWise. However, in the case of Engagement Outcome advancement criteria or any form of trigger (action), integration with Player Attributes, Player Engagment Outcomes, Player Events, and/or Region transition may be required.
How do I get notified of player progress?
You can get notified of a player's progress through the use of our Webhook API. This will enable you to become reactive to when a player starts a Journey/Odyssey, advances through to one or more Steps, and when a player exits a Journey/Odyssey.
Reacting to Content Steps
When a player encounters a Content Step, you will receive a player_journey_step_advanced
event. This event will contain the previous leg & step, as well as information regarding the newly ready legs & steps.
Content retrieval can be acted upon, and can be tuned depending on the step configuration and type.
Attribute Targeting
Attributes (along with Event Targeting) are the bread-and-butter of the UserWise targeting framework.
Attributes can be thought of as a key-value store for your app user. You can set various traits that a user has currently; and then in the future you can overwrite those values. So, given that our fictious game UserWise Hero Wars
has a premium currency of diamonds
and a general currency of coins
, we can keep our app user updated within the UserWise platform by updating their coins and diamonds attributes via a Platform SDK or through the Server-to-Server API.
Supported Attribute Data Types
The UserWise platform tries to be as fluid as possible. At the moment we provide native support for the following data types:
Data Type Name | UserWise Platform Representation |
---|---|
String | string |
Boolean | boolean |
Integer | integer |
Float | float |
DateTime | datetime |
Setting an App User's Attributes
Setting the value of an app user's attributes can be done through the use of the Server API or Unity SDK. The choice is up to you and what works best with your flow.
Event Targeting
Targeting events are named events that may occur within your game. These events can be registered on the fly, allowing you to not worry about updating the UserWise platform.
At a minimum, an event is an unique string identifying an event that the app user has experienced. offer_123_shown
, offer_123_purchased
, tutorial_completed
are all examples of possible events that could occur within your game.
Event Attributes
Events can have uniquely (or non-uniquely) defined attributes. These attributes are not tied to the app user's current attributes, but rather give you an opportunity to track various attributes that were present during an event's execution.
The event attributes abide by the same set of rules as general Attribute Targeting.
Setting Event Attributes
Assigning events can be done through the use of the Server API or Unity SDK. The choice is up to you and what works best with your flow. Each of those sections will guide you through how to assign attributes given the environment.
Segment Targeting
When using the attribute and event targeting functionality, there is a specific schema you must abide by in order for your segment to not only be saved, but also target the proper segment of app users. Below, you can find sections describing how to use each of the targeting functions appropriately.
Attribute Targeting Groups
Attribute Targeting Schema
[
// an example attribute targeting group
{
"group_logical_operator": "and|or",
"name": "attribute_name",
"values": ["array", "of", "values", 123, true],
"operator": "equal|greater_than|less_than|contain|between"
}
]
Attribute Targeting Example (whale player, <500 diamonds, last purchase >30 days)
[
{ "name": "is_whale", "operator": "equal", "values": [true] },
{ "group_logical_operator": "and", "name": "current_diamonds", "operator": "less_than", "values": [500] },
{ "group_logical_operator": "and", "name": "last_offer_purchase_date", "operator": "less_than", "values": ["2020-02-04T00:00:00Z"] }
]
Attribute targeting is the simplest segment targeting method offered, and can be used in conjunction with event targeting.
As with the event targeting methods, our first field is the group_logical_operator
, which acts as the connecting logical operator between the current and previous group.
Next, we have the name
and values
fields. The name
field refers to the attribute to target against, and values is an array of data to compare the app user's current attribute values against, in conjunction with the final field - operator
. The operators available for each attribute are dependent upon their data type. Each operator functions as you would expect, except for maybe equal
and contain
. equal
does a hard equals while contain
allows you to do a form of fuzzy searching of strings.
Attribute Operator Availability
Data Type | Operators Available |
---|---|
string | equal, contain |
integer | equal, greater_than, less_than, between |
float | equal, greater_than, less_than, between |
datetime | equal, greater_than, less_than, between |
boolean | equal |
Event Targeting Groups
Event Targeting Schema
[
// event targeting group
{
"group_logical_operator": "and|or",
"logical_operator": "and|or|not",
"event_sets": [
{ "event_id": "played_halloween_event", attributes: [] },
{ "event_id": "iap_purchased", attributes: [
{ "name": "bundle_cost", "operator": "greater_than", "values": [9.99] },
{ "name": "snapshot_player_ltv", "operator": "greater_than", "values": [100] }
] }
]
},
...
]
Event targeting is slightly more complex and makes use of basic event_id
matching, along with intermixed event attribute targeting. Event attributes are attributes that pertain to only the event they were attached to and allows finer control over targeting your userbase based on the events that have occurred.
As you can see from the schema to the right, our system expects an array of hash maps, aptly nicknamed event targeting groups. These groups are interconnected through the use of the group_logical_operator
field, which acts as the connecting logical operator between the current and previous group. Next we have the logical_operator
field which acts as the logical operator (and
/or
/not
) for the event_sets
defined within each group.
Though it can seem somewhat confusing initially, event_groups
are just containers for inner event_sets
which define the individual event_id
+ attribute
targeting.
Event Targeting Example (purchased offer 123, did not purchase offer 456)
[
{ "logical_operator": "and", "event_ids": ["offer_123_viewed", "offer_123_purchased", "offer_456_viewed"] },
{ "group_logical_operator": "and", "logical_operator": "not", "event_ids": ["offer_456_purchased"] }
]
Server API
AB Tests
Get AB Tests
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/a_b_tests?query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "ae2d0dc0-180d-498f-88f4-a41f7484c63d",
"name": "AB Test Name",
"campaign_id": "042e7353-1de5-4bde-9adc-a8adf0b99c5b",
"campaign_content_id": null,
"testable_type": "campaign",
"created_at": "2024-01-10T16:33:36Z",
"updated_at": "2024-01-10T16:33:56Z"
},
...
]
}
Retrieves a list of A/B Test records.
HTTP Request
GET https://api.userwise.io/api/v1/a_b_tests
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter surveys by names matching the query string provided. This is a fuzzy search. |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
page_size | No | None | How many results to return, per page. Default: 10 |
page | No | None | Which page of results should be returned. (1 thru n). Default: 1 |
enc | Yes | None | Generated request hash |
Get AB Test
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/a_b_tests/{{ a_b_test_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "e6b43635-6eb1-46fd-9cba-526b8b38a187",
"name": "AB Test Name",
"campaign_id": "c8a5d241-6935-4d99-99be-4306b9e1619a",
"campaign_content_id": "4240e476-45b1-4c06-8717-f2cc16b2acc5",
"testable_type": "campaign_content",
"created_at": "2024-01-10T16:33:36Z",
"updated_at": "2024-01-10T16:33:56Z",
"variants": [
{
"id": "925a2a6e-fab8-4cbe-8cff-f9ca944f1071",
"name": "Variant 1",
"percentage": 20,
"type": "offer",
"control_group": false,
"assigned_users_count": 2000
},
{
"id": "bde542d8-5c18-4c69-9e21-ac960dfa93a2",
"name": "Variant 2",
"percentage": 40,
"type": "offer",
"control_group": false,
"assigned_users_count": 4000
},
{
"id": "c0f376ba-23bd-47fc-95dc-a4da005f7e84",
"name": "Variant 3",
"percentage": 40,
"type": "offer",
"control_group": true,
"assigned_users_count": 4000
}
]
}
}
Retrieves an ab test resource.
HTTP Request
GET https://api.userwise.io/api/v1/a_b_tests/{{ a_b_test_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
App Currencies
Get All Currencies
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_currencies?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 No Content
{
"data": [
{
"id": "7e72fdbf-0fec-4a8d-983d-0e333ed6a22e",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name_singular": "Diamond",
"name_plural": "Diamonds",
"external_currency_id": "your-internal-currency-id",
"icon_attachment_id": "e64f274c-eb5e-4f1e-a630-9d1685709a5c"
},
...
]
}
Retrieves a list of currency resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_currencies
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter currencies that have any of the following that case-insentive match the query string: name_singular and name_plural |
app_id | No | None | Filter currencies by the provided app_id. By default UserWise will return currencies for all of your apps. |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
enc | Yes | None | Generated request hash |
Get Currency
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "7e72fdbf-0fec-4a8d-983d-0e333ed6a22e",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name_singular": "Diamond",
"name_plural": "Diamonds",
"external_currency_id": "your-internal-currency-id",
"icon_attachment_id": "e64f274c-eb5e-4f1e-a630-9d1685709a5c"
}
}
Retrieves a single currency resource from our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Currency
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_currencies?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name_singular=>"Diamond", :name_plural=>"Diamonds", :external_currency_id=>"your-internal-currency-id", :icon_attachment_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/app_currencies?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name_singular=>"Diamond", :name_plural=>"Diamonds", :external_currency_id=>"your-internal-currency-id", :icon_attachment_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_currencies?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_attachment_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_currencies?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_attachment_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_currencies?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_attachment_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_currencies?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_attachment_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "7e72fdbf-0fec-4a8d-983d-0e333ed6a22e",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name_singular": "Diamond",
"name_plural": "Diamonds",
"external_currency_id": "your-internal-currency-id",
"icon_attachment_id": "e64f274c-eb5e-4f1e-a630-9d1685709a5c"
},
}
Creates a new currency resource with the provided data.
HTTP Request
POST https://api.userwise.io/api/v1/app_currencies
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | The app's id that should be associated with the currency | |
name_singular | Yes | string | The display name for the new currency | |
name_plural | Yes | string | The cost for the currency (should be the same as the android and ios store currencies). | |
external_currency_id | Yes | string | Your internal id for this specific currency. | |
icon_attachment_id | Yes | string | The media library media used by this currency. |
Update a Currency
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name_singular=>"Diamond", :name_plural=>"Diamonds", :external_currency_id=>"your-internal-currency-id", :icon_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}',
payload: {:name_singular=>"Diamond", :name_plural=>"Diamonds", :external_currency_id=>"your-internal-currency-id", :icon_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_id":""}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name_singular":"Diamond","name_plural":"Diamonds","external_currency_id":"your-internal-currency-id","icon_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "7e72fdbf-0fec-4a8d-983d-0e333ed6a22e",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name_singular": "Diamond",
"name_plural": "Diamonds",
"external_currency_id": "your-internal-currency-id",
"icon_attachment_id": "e64f274c-eb5e-4f1e-a630-9d1685709a5c"
}
}
Updates an existing currency resource in our system with the provided data.
HTTP Request
PUT https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name_singular | No | string | Singular-form name for the currency | |
name_plural | No | string | Plural-form name for the currency. | |
external_currency_id | No | string | Your internal id for this specific currency. | |
icon_id | No | string | The media library media used to attach to this currency. |
Delete a Currency
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_currencies/{{ currency_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the app currency." }
Deletes the currency resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/app_currencies/{{ currency_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
App Items
Get All Items
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_items?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 No Content
{
"data": [
{
"id": "e7ff1c09-ecd1-4a35-8364-e28d019cabbf",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Sword of the Mountain Elder",
"external_item_id": "your-internal-item-id",
"icon_attachment_id": "6e010ead-f046-4413-b445-1f1dbff30942"
},
...
]
}
Retrieves a list of item resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_items
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter items that have any of the following that case-insentive match the query string: name_singular and name_plural |
app_id | No | None | Filter items by the provided app_id. By default UserWise will return items for all of your apps. |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
enc | Yes | None | Generated request hash |
Get Item
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "e7ff1c09-ecd1-4a35-8364-e28d019cabbf",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Sword of the Mountain Elder",
"external_item_id": "your-internal-item-id",
"icon_attachment_id": "6e010ead-f046-4413-b445-1f1dbff30942"
}
}
Retrieves a single item resource from our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_items/{{ item_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Item
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_items?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"", :external_item_id=>"your-internal-item-id", :icon_attachment_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/app_items?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"", :external_item_id=>"your-internal-item-id", :icon_attachment_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_items?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_items?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_items?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_items?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "e7ff1c09-ecd1-4a35-8364-e28d019cabbf",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Sword of the Mountain Elder",
"external_item_id": "your-internal-item-id",
"icon_attachment_id": "6e010ead-f046-4413-b445-1f1dbff30942"
},
}
Creates a new item resource with the provided data.
HTTP Request
POST https://api.userwise.io/api/v1/app_items
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | The app's id that should be associated with the item | |
name | Yes | string | The name of the item. | |
external_item_id | Yes | string | Your internal id for this specific item. | |
icon_attachment_id | Yes | string | The media library media used by this item. |
Update a Item
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"", :external_item_id=>"your-internal-item-id", :icon_attachment_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"", :external_item_id=>"your-internal-item-id", :icon_attachment_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"","external_item_id":"your-internal-item-id","icon_attachment_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "e7ff1c09-ecd1-4a35-8364-e28d019cabbf",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Sword of the Mountain Elder",
"external_item_id": "your-internal-item-id",
"icon_attachment_id": "6e010ead-f046-4413-b445-1f1dbff30942"
}
}
Updates an existing item resource in our system with the provided data.
HTTP Request
PUT https://api.userwise.io/api/v1/app_items/{{ item_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | Singular-form name for the item | |
external_item_id | No | string | Your internal id for this specific item. | |
icon_attachment_id | No | string | The media library media used by this item. |
Delete a Item
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_items/{{ item_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the app item." }
Deletes the item resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/app_items/{{ item_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
App Products
Get All Products
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_products?query={{ query }}&app_id={{ app_id }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "0a57007f-21f2-44fe-bc0a-3d4ecc77a783",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "My Product",
"cost": 0.99,
"android_id": "my-playstore-product-id",
"ios_id": "my-appstore-product-id"
},
...
]
}
Retrieves a list of product resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_products
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter products that have any of the following that case-insentive match the query string: name, cost, android_id, and ios_id. |
app_id | No | None | Filter products by the provided app_id. By default UserWise will return products for all of your apps. |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
enc | Yes | None | Generated request hash |
Get Product
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "0a57007f-21f2-44fe-bc0a-3d4ecc77a783",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "My Product",
"cost": 0.99,
"android_id": "my-playstore-product-id",
"ios_id": "my-appstore-product-id"
}
}
Retrieves a single product resource from our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_products/{{ product_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Product
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_products?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"My Product", :cost=>0.99, :android_id=>"my-playstore-product-id", :ios_id=>"my-appstore-product-id"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/app_products?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"My Product", :cost=>0.99, :android_id=>"my-playstore-product-id", :ios_id=>"my-appstore-product-id"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_products?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_products?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_products?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_products?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "0a57007f-21f2-44fe-bc0a-3d4ecc77a783",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "My Product",
"cost": 0.99,
"android_id": "my-playstore-product-id",
"ios_id": "my-appstore-product-id"
},
}
Creates a new product resource with the provided data.
HTTP Request
POST https://api.userwise.io/api/v1/app_products
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | The app's id that should be associated with the product | |
name | Yes | string | The display name for the new product | |
cost | Yes | float | The cost for the product (should be the same as the android and ios store products). | |
android_id | No | string | The Android App Store product id | |
ios_id | No | string | The iOS App Store product id |
Update a Product
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Product", :cost=>0.99, :android_id=>"my-playstore-product-id", :ios_id=>"my-appstore-product-id"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My Product", :cost=>0.99, :android_id=>"my-playstore-product-id", :ios_id=>"my-appstore-product-id"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Product","cost":0.99,"android_id":"my-playstore-product-id","ios_id":"my-appstore-product-id"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "0a57007f-21f2-44fe-bc0a-3d4ecc77a783",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "My Product",
"cost": 0.99,
"android_id": "my-playstore-product-id",
"ios_id": "my-appstore-product-id"
}
}
Updates an existing product resource in our system with the provided data.
HTTP Request
PUT https://api.userwise.io/api/v1/app_products/{{ product_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the new product | |
cost | No | float | The cost for the product (should be the same as the android and ios store products). | |
android_id | No | string | The Android Play Store product id | |
ios_id | No | string | The iOS App Store product id |
Delete a Product
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_products/{{ product_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the app product." }
Deletes the product resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/app_products/{{ product_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
App Regions
Get All App Regions
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_regions?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_regions?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_regions?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_regions?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_regions?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_regions?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"df793da5-ba44-431a-bedb-e28d9054bc63": [
{ "name": "main_menu", "metadata": [] },
{ "name": "settings", "metadata": [] },
{ "name": "team_battle", "metadata": [
{ "name": "is_pvp", "data_type": "boolean" },
{ "name": "team_one_power_level", "data_type": "float" },
{ "name": "team_two_power_level", "data_type": "float" }
] }
],
"{{ app_id }}": [{}]
}
}
Retrieves a unique set of all defined app regions with any metadata definitions we've encountered, broken out by each app.
HTTP Request
GET https://api.userwise.io/api/v1/app_regions
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Campaigns
Get All Campaigns
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&delivery_type={{ delivery_type }}&state={{ state }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "278e1046-cdec-4604-9571-1804d709a4a5",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"environment_id": "b01d1ab6-41e4-4b51-a15b-896c4871ea30",
"environment_type": "live",
"environment_key": "live",
"name": "Christmas 2023 Campaign",
"description": "Campaign for all users in 2023",
"category_id": "ff8b4d42-1a6b-4481-a119-f0314235a08e",
"contents": [
{
"type": "campaign_event"
},
{
"type": "message"
},
{
"type": "offer"
},
{
"type": "offer"
},
{
"type": "message"
}
],
"furthest_state": "live",
"state": "draft",
"previous_state": "draft",
"delivery_type": "scheduled",
"start_at": "2023-12-10T00:00:00Z",
"start_at_tz": "utc",
"end_at": "2023-12-31T00:00:00Z",
"end_at_tz": "utc (always matches start_at_tz)",
"ui_schedule_in_timezone": "utc",
"tags": [
"one_tag",
"another_tag"
],
"segment_ids": [
"078130e9-e34a-422e-85b9-f11b31ec7cce"
],
"created_at": "02-02-2022T00:00:00Z",
"updated_at": "02-22-2022T00:00:00Z"
},
...
]
}
Retrieves a list of campaign resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1/campaigns
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
query | No | None | Filter campaigns that have any of the following that case-insentive match the query string: name & tags. |
delivery_type | No | None | 'scheduled' or 'triggered' |
state | No | None | Query for campaigns in a specific state. (draft, running, paused, attention_required, completed) |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
page | No | None | The pagination page. |
page_size | No | None | Number of records to return in each page. Used for pagination. |
enc | Yes | None | Generated request hash |
Get Campaign
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "06637a6c-3813-40b7-83c9-bfae79d1a50b",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"environment_id": "3ea5c3e5-283d-4aea-bfc4-839340661ffa",
"environment_type": "live",
"environment_key": "live",
"name": "Christmas 2023 Campaign",
"description": "Campaign for all users in 2023",
"category_id": "bedd2f02-6b7c-4da2-b7b1-e5954d90151a",
"contents": [
{
"type": "campaign_event"
},
{
"type": "message"
},
{
"type": "offer"
},
{
"type": "offer"
},
{
"type": "message"
}
],
"furthest_state": "live",
"state": "draft",
"previous_state": "draft",
"delivery_type": "triggered",
"trigger": {
"type": "event_trigger|attribute_trigger|region_trigger",
"logic": {
},
"settings": {
}
},
"tags": [
"one_tag",
"another_tag"
],
"segment_ids": [
],
"created_at": "02-02-2022T00:00:00Z",
"updated_at": "02-22-2022T00:00:00Z"
}
}
Retrieves a single campaign resource from our system.
HTTP Request
GET https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Create a Campaign
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"Christmas 2023 Campaign", :delivery_type=>"triggered", :description=>"", :category_id=>"", :start_at=>"", :start_at_tz=>"", :end_at=>"", :end_at_tz=>"", :tags=>"", :segment_ids=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {:name=>"Christmas 2023 Campaign", :delivery_type=>"triggered", :description=>"", :category_id=>"", :start_at=>"", :start_at_tz=>"", :end_at=>"", :end_at_tz=>"", :tags=>"", :segment_ids=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"Christmas 2023 Campaign","delivery_type":"triggered","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"Christmas 2023 Campaign","delivery_type":"triggered","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"Christmas 2023 Campaign","delivery_type":"triggered","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"Christmas 2023 Campaign","delivery_type":"triggered","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "06637a6c-3813-40b7-83c9-bfae79d1a50b",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"environment_id": "3ea5c3e5-283d-4aea-bfc4-839340661ffa",
"environment_type": "live",
"environment_key": "live",
"name": "Christmas 2023 Campaign",
"description": "Campaign for all users in 2023",
"category_id": "bedd2f02-6b7c-4da2-b7b1-e5954d90151a",
"contents": [
{
"type": "campaign_event"
},
{
"type": "message"
},
{
"type": "offer"
},
{
"type": "offer"
},
{
"type": "message"
}
],
"furthest_state": "live",
"state": "draft",
"previous_state": "draft",
"delivery_type": "triggered",
"trigger": {
"type": "event_trigger|attribute_trigger|region_trigger",
"logic": {
},
"settings": {
}
},
"tags": [
"one_tag",
"another_tag"
],
"segment_ids": [
],
"created_at": "02-02-2022T00:00:00Z",
"updated_at": "02-22-2022T00:00:00Z"
},
}
Creates a new campaign with the provided details.
HTTP Request
POST https://api.userwise.io/api/v1/campaigns
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the campaign | |
delivery_type | No | string | 'scheduled' or 'triggered' | |
description | No | string | A description of this campaign | |
category_id | No | string | The id of the category for this campaign | |
start_at | No | datetime | Start DateTime in ISO8601 format | |
start_at_tz | No | string (enum) | "utc" or "player_local" | |
end_at | No | datetime | End DateTime in ISO8601 format | |
end_at_tz | No | string (enum) | "utc" or "player_local" | |
tags | No | string[] | Array of tags for this campaign | |
segment_ids | No | string[] | Array of segment ids for this campaign. A user must be in one of these segments to receive the campaign |
Update a Campaign
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"", :description=>"", :category_id=>"", :start_at=>"", :start_at_tz=>"", :end_at=>"", :end_at_tz=>"", :tags=>"", :segment_ids=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {:name=>"", :description=>"", :category_id=>"", :start_at=>"", :start_at_tz=>"", :end_at=>"", :end_at_tz=>"", :tags=>"", :segment_ids=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"","description":"","category_id":"","start_at":"","start_at_tz":"","end_at":"","end_at_tz":"","tags":"","segment_ids":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "06637a6c-3813-40b7-83c9-bfae79d1a50b",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"environment_id": "3ea5c3e5-283d-4aea-bfc4-839340661ffa",
"environment_type": "live",
"environment_key": "live",
"name": "Christmas 2023 Campaign",
"description": "Campaign for all users in 2023",
"category_id": "bedd2f02-6b7c-4da2-b7b1-e5954d90151a",
"contents": [
{
"type": "campaign_event"
},
{
"type": "message"
},
{
"type": "offer"
},
{
"type": "offer"
},
{
"type": "message"
}
],
"furthest_state": "live",
"state": "draft",
"previous_state": "draft",
"delivery_type": "triggered",
"trigger": {
"type": "event_trigger|attribute_trigger|region_trigger",
"logic": {
},
"settings": {
}
},
"tags": [
"one_tag",
"another_tag"
],
"segment_ids": [
],
"created_at": "02-02-2022T00:00:00Z",
"updated_at": "02-22-2022T00:00:00Z"
},
}
Updates a campaign with the provided details.
HTTP Request
PUT https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the campaign | |
description | No | string | A description of this campaign | |
category_id | No | string | The id of the category for this campaign | |
start_at | No | datetime | Start DateTime in ISO8601 format | |
start_at_tz | No | string (enum) | "utc" or "player_local" | |
end_at | No | datetime | End DateTime in ISO8601 format | |
end_at_tz | No | string (enum) | "utc" or "player_local" | |
tags | No | string[] | Array of tags for this campaign | |
segment_ids | No | string[] | Array of segment ids for this campaign. A user must be in one of these segments to receive the campaign |
Delete a Campaign
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the app campaign." }
Deletes the campaign resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Duplicate a Campaign
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "373d39a4-149d-4bed-8e9a-731c59d7f566",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"environment_id": "3ea5c3e5-283d-4aea-bfc4-839340661ffa",
"environment_type": "live",
"environment_key": "live",
"name": "Christmas 2023 Campaign (Duplicate)",
"description": "Campaign for all users in 2023",
"category_id": "bedd2f02-6b7c-4da2-b7b1-e5954d90151a",
"contents": [
{
"type": "campaign_event"
},
{
"type": "message"
},
{
"type": "offer"
},
{
"type": "offer"
},
{
"type": "message"
}
],
"furthest_state": "live",
"state": "draft",
"previous_state": "draft",
"delivery_type": "triggered",
"trigger": {
"type": "event_trigger|attribute_trigger|region_trigger",
"logic": {
},
"settings": {
}
},
"tags": [
"one_tag",
"another_tag"
],
"segment_ids": [
],
"created_at": "02-02-2022T00:00:00Z",
"updated_at": "02-22-2022T00:00:00Z"
},
}
Creates a new campaign resource by duplicate the provided campaign resource. Copies all contents and settings.
HTTP Request
POST https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/duplicate
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Campaign Contents
Get Content
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "37fe2508-b16a-4594-ba04-6f40e8d3189e",
"type": "offer",
"delivery": {
"start_at_type": "concrete",
"start_at_time": "2023-12-10T00:00:00Z",
"start_at_tz": "utc",
"end_at_type": "concrete",
"end_at_time": "2023-12-10T00:00:00Z",
"segment_ids": [
"405162c1-b4bf-46ef-a01a-e4ba03f9db09",
"..."
]
},
"content": {
"name": "My Offer",
"title": "Upgrade Your Hero!",
"body": "Buy this offer to upgrade your hero.",
"portrait_image_id": "b6425b08-f0e4-484a-b8bf-06c3c05abcb7",
"landscape_image_id": "90aa25bd-5406-4f44-8759-6adbab2d2fdc",
"app_bundle_id": "e373f5ef-b6d0-449e-8bdd-8aa582599918"
}
}
}
Retrieves the data for the provided campaign content.
HTTP Request
GET https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Create new Content
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:type=>"offer", :"delivery.start_at_type"=>"concrete", :"delivery.start_at_time"=>"2023-12-10T00:00:00Z", :"delivery.start_at_tz"=>"utc", :"delivery.end_at_type"=>"concrete", :"delivery.end_at_time"=>"2023-12-10T00:00:00Z", :"delivery.segment_ids"=>["405162c1-b4bf-46ef-a01a-e4ba03f9db09", "..."], :content=>{:name=>"My Offer", :title=>"Upgrade Your Hero!", :body=>"Buy this offer to upgrade your hero.", :portrait_image_id=>"b6425b08-f0e4-484a-b8bf-06c3c05abcb7", :landscape_image_id=>"90aa25bd-5406-4f44-8759-6adbab2d2fdc", :app_bundle_id=>"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {:type=>"offer", :"delivery.start_at_type"=>"concrete", :"delivery.start_at_time"=>"2023-12-10T00:00:00Z", :"delivery.start_at_tz"=>"utc", :"delivery.end_at_type"=>"concrete", :"delivery.end_at_time"=>"2023-12-10T00:00:00Z", :"delivery.segment_ids"=>["405162c1-b4bf-46ef-a01a-e4ba03f9db09", "..."], :content=>{:name=>"My Offer", :title=>"Upgrade Your Hero!", :body=>"Buy this offer to upgrade your hero.", :portrait_image_id=>"b6425b08-f0e4-484a-b8bf-06c3c05abcb7", :landscape_image_id=>"90aa25bd-5406-4f44-8759-6adbab2d2fdc", :app_bundle_id=>"e373f5ef-b6d0-449e-8bdd-8aa582599918"}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/content?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "37fe2508-b16a-4594-ba04-6f40e8d3189e",
"type": "offer",
"delivery": {
"start_at_type": "concrete",
"start_at_time": "2023-12-10T00:00:00Z",
"start_at_tz": "utc",
"end_at_type": "concrete",
"end_at_time": "2023-12-10T00:00:00Z",
"segment_ids": [
"405162c1-b4bf-46ef-a01a-e4ba03f9db09",
"..."
]
},
"content": {
"name": "My Offer",
"title": "Upgrade Your Hero!",
"body": "Buy this offer to upgrade your hero.",
"portrait_image_id": "b6425b08-f0e4-484a-b8bf-06c3c05abcb7",
"landscape_image_id": "90aa25bd-5406-4f44-8759-6adbab2d2fdc",
"app_bundle_id": "e373f5ef-b6d0-449e-8bdd-8aa582599918"
}
},
}
Creates a new piece of campaign content with the provided details.
HTTP Request
POST https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
type | Yes | string (enum) | The type of content to create. (survey, poll, offer, campaign_event, message, variables) | |
delivery.start_at_type | No | string (enum) | parent | Sets the start type for the content. ("parent" or "concrete") |
delivery.start_at_time | No | datetime | Sets the start at date time for the piece of content. Must be in ISO8601 format. Must be within the campaigns start and end. | |
delivery.start_at_tz | No | string (enum) | Sets the timezone setting for the start of the content. ("utc" or "player_local") | |
delivery.end_at_type | No | string (enum) | parent | Sets the end type for the content. ("parent" or "concrete") |
delivery.end_at_time | No | datetime | Sets the end at date time for the piece of content. Must be in ISO8601 format. Must be within the campaigns start and end. | |
delivery.segment_ids | No | string[] | Array of segment ids for this campaign content. A user must be in one of these segments to receive the campaign | |
content | No | object | A dynamic object containing fields that are content-type dependent. |
Event Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.template_json | Yes | object | Valid JSON that is compatible with JSON Schema Form |
content.campaign_event_framework_id | Yes | string | ID of the campaign event framework to use |
content.json | Yes | object | Valid JSON that fits the template_json |
Email Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.subject | No | string | ID of the localization to use for the subject |
content.body | Yes | string | Raw body that is injected into the email framework's template (replaces {{body}} ) |
content.framework_id | Yes | string | ID of the email framework to use |
Message Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.title | No | string | Title of the message, must be a valid localization id |
content.body | No | string | Body of the message, must be a valid localization id |
content.portrait_image_id | No | string | ID of a media library image, used when displaying the message in portrait mode |
content.landscape_image_id | No | string | ID of a media library image, used when displaying the message in landscape mode |
content.message_type | No | string | The type of message |
content.additional_fields_schema | No | object | The schema used to define the structure of the extra message content |
content.additional_fields_data | No | object | The data that which matches the provided schema |
Offer Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.title | No | string | Title of the offer, must be a valid localization id |
content.body | No | string | Body of the offer, must be a valid localization id |
content.portrait_image_id | No | string | ID of a media library image |
content.landscape_image_id | No | string | ID of a media library image |
content.payment.payment_type | Yes | string | "product" or "currency" |
content.payment.product_id | No | string | ID of the product (ONLY if payment_type = "product") |
content.payment.currency_id | No | string | ID of the currency (ONLY if payment_type = "currency") |
content.payment.current_amount | No | string | The amount of currecy required |
content.bundle_units[].unit_type | No | string | "item" or "currency" |
content.bundle_units[].unit_id | No | string | ID of the item or currency |
content.bundle_units[].unit_external_id | No | string | The external ID of the item or currency (pulled from the appropriate record) |
content.bundle_units[].unit_name | No | string | The name of the item or currency (pulled from the appropriate record) |
content.bundle_units[].default_amount | No | integer | The amount of the "item" or "currency" to provide the player |
content.framework_id | No | string | ID the offer framework to be used |
content.framework_schema | No | object | Valid JSON that is compatible with JSON Schema Form |
content.framework_data | No | object | Valid JSON that fits the framework_schema |
Push Notification Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.title | No | string | Title of the push notification, must be a valid localization id |
content.body | No | string | Body of the push notification, must be a valid localization id |
content.image_id | No | string | ID of a media library image |
content.framework_id | No | string | ID the push notification framework to be used |
content.framework_schema | No | object | Valid JSON that is compatible with JSON Schema Form |
content.framework_data | No | object | Valid JSON that fits the framework_schema |
Remote Config (JSON Uploads) Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.external_id | No | string | The identifier used within your systems that help identify this remote configs purpose |
content.json | Yes | object or array | Must be a valid JSON snippet, which is used verbatim in the game |
Surveys Content Fields
Field | Required | Type | Description |
---|---|---|---|
content.name | No | string | The name of the piece of content |
content.questions[].text | No | string | The text/label for the survey question |
content.questions[].type | No | string | The type of question (single_select, multi_select, rating, ranking, open_ended) |
content.questions[].media_id | No | string | ID of a media library image |
content.questions[].question_options[].value | No | string | A question option value (if type is not open_ended) |
content.questions[].question_options[].media_id | No | string | ID of a media library image |
Update Content
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:type=>"offer", :"delivery.start_at_type"=>"concrete", :"delivery.start_at_time"=>"2023-12-10T00:00:00Z", :"delivery.start_at_tz"=>"utc", :"delivery.end_at_type"=>"concrete", :"delivery.end_at_time"=>"2023-12-10T00:00:00Z", :"delivery.segment_ids"=>["405162c1-b4bf-46ef-a01a-e4ba03f9db09", "..."], :content=>{:name=>"My Offer", :title=>"Upgrade Your Hero!", :body=>"Buy this offer to upgrade your hero.", :portrait_image_id=>"b6425b08-f0e4-484a-b8bf-06c3c05abcb7", :landscape_image_id=>"90aa25bd-5406-4f44-8759-6adbab2d2fdc", :app_bundle_id=>"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {:type=>"offer", :"delivery.start_at_type"=>"concrete", :"delivery.start_at_time"=>"2023-12-10T00:00:00Z", :"delivery.start_at_tz"=>"utc", :"delivery.end_at_type"=>"concrete", :"delivery.end_at_time"=>"2023-12-10T00:00:00Z", :"delivery.segment_ids"=>["405162c1-b4bf-46ef-a01a-e4ba03f9db09", "..."], :content=>{:name=>"My Offer", :title=>"Upgrade Your Hero!", :body=>"Buy this offer to upgrade your hero.", :portrait_image_id=>"b6425b08-f0e4-484a-b8bf-06c3c05abcb7", :landscape_image_id=>"90aa25bd-5406-4f44-8759-6adbab2d2fdc", :app_bundle_id=>"e373f5ef-b6d0-449e-8bdd-8aa582599918"}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"type":"offer","delivery.start_at_type":"concrete","delivery.start_at_time":"2023-12-10T00:00:00Z","delivery.start_at_tz":"utc","delivery.end_at_type":"concrete","delivery.end_at_time":"2023-12-10T00:00:00Z","delivery.segment_ids":["405162c1-b4bf-46ef-a01a-e4ba03f9db09","..."],"content":{"name":"My Offer","title":"Upgrade Your Hero!","body":"Buy this offer to upgrade your hero.","portrait_image_id":"b6425b08-f0e4-484a-b8bf-06c3c05abcb7","landscape_image_id":"90aa25bd-5406-4f44-8759-6adbab2d2fdc","app_bundle_id":"e373f5ef-b6d0-449e-8bdd-8aa582599918"}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "37fe2508-b16a-4594-ba04-6f40e8d3189e",
"type": "offer",
"delivery": {
"start_at_type": "concrete",
"start_at_time": "2023-12-10T00:00:00Z",
"start_at_tz": "utc",
"end_at_type": "concrete",
"end_at_time": "2023-12-10T00:00:00Z",
"segment_ids": [
"405162c1-b4bf-46ef-a01a-e4ba03f9db09",
"..."
]
},
"content": {
"name": "My Offer",
"title": "Upgrade Your Hero!",
"body": "Buy this offer to upgrade your hero.",
"portrait_image_id": "b6425b08-f0e4-484a-b8bf-06c3c05abcb7",
"landscape_image_id": "90aa25bd-5406-4f44-8759-6adbab2d2fdc",
"app_bundle_id": "e373f5ef-b6d0-449e-8bdd-8aa582599918"
}
},
}
Creates a new piece of campaign content with the provided details.
HTTP Request
PUT https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
type | Yes | string (enum) | The type of content to create. (survey, poll, offer, campaign_event, message, variables) | |
delivery.start_at_type | No | string (enum) | parent | Sets the start type for the content. ("parent" or "concrete") |
delivery.start_at_time | No | datetime | Sets the start at date time for the piece of content. Must be in ISO8601 format. Must be within the campaigns start and end. | |
delivery.start_at_tz | No | string (enum) | Sets the timezone setting for the start of the content. ("utc" or "player_local") | |
delivery.end_at_type | No | string (enum) | parent | Sets the end type for the content. ("parent" or "concrete") |
delivery.end_at_time | No | datetime | Sets the end at date time for the piece of content. Must be in ISO8601 format. Must be within the campaigns start and end. | |
delivery.segment_ids | No | string[] | Array of segment ids for this campaign content. A user must be in one of these segments to receive the campaign | |
content | No | object | A dynamic object containing fields that are content-type dependent. |
Delete a Content
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the content." }
Deletes the campaign content resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Duplicate Content
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "dc243552-ff33-40e1-b2f7-bf9e58580e64",
"type": "offer",
"delivery": {
"start_at_type": "concrete",
"start_at_time": "2023-12-10T00:00:00Z",
"start_at_tz": "utc",
"end_at_type": "concrete",
"end_at_time": "2023-12-10T00:00:00Z",
"segment_ids": [
"405162c1-b4bf-46ef-a01a-e4ba03f9db09",
"..."
]
},
"content": {
"name": "My Offer (Duplicate)",
"title": "Upgrade Your Hero!",
"body": "Buy this offer to upgrade your hero.",
"portrait_image_id": "b6425b08-f0e4-484a-b8bf-06c3c05abcb7",
"landscape_image_id": "90aa25bd-5406-4f44-8759-6adbab2d2fdc",
"app_bundle_id": "e373f5ef-b6d0-449e-8bdd-8aa582599918"
}
},
}
Creates a new campaign content resource by duplicating the original campaign content resource.
HTTP Request
POST https://api.userwise.io/api/v1/campaigns/{{ campaign_id }}/content/{{ content_id }}/duplicate
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | Filter campaigns by the provided app_id. By default UserWise will return campaigns for all of your apps. |
environment_stage | Yes | None | An environment key (e.g. dev , qa , live , ...) |
enc | Yes | None | Generated request hash |
Campaign Events
Get All Campaign Event Frameworks
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_templates?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "53d8bb65-238d-4d46-9b39-b631679c1381",
"name": "My Framework",
"external_event_type": "my_event_type_identifier",
"json": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
...
]
}
Retrieves an array of all the campaign event frameworks, for your app.
HTTP Request
GET https://api.userwise.io/api/v1/campaign_event_templates
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Get Campaign Event Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "53d8bb65-238d-4d46-9b39-b631679c1381",
"name": "My Framework",
"external_event_type": "my_event_type_identifier",
"json": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
}
}
Retrieves a campaign event framework resource.
HTTP Request
GET https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create an Campaign Event Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :external_event_type=>"my_event_type_identifier", :json=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :external_event_type=>"my_event_type_identifier", :json=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","external_event_type":"my_event_type_identifier","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"My Framework","external_event_type":"my_event_type_identifier","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_templates?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","external_event_type":"my_event_type_identifier","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_templates?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","external_event_type":"my_event_type_identifier","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "53d8bb65-238d-4d46-9b39-b631679c1381",
"name": "My Framework",
"external_event_type": "my_event_type_identifier",
"json": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Creates a new campaign event framework record with the provided information.
HTTP Request
POST https://api.userwise.io/api/v1/campaign_event_templates
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | Yes | string | The display name for the framework | |
external_event_type | Yes | string | An external identifier that helps you understand the type of event framework this is. | |
json | Yes | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Update a Campaign Event Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :json=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :json=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My Framework","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","json":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "53d8bb65-238d-4d46-9b39-b631679c1381",
"name": "My Framework",
"external_event_type": "my_event_type_identifier",
"json": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Updates a campaign event framework with the new provided name
or schema
.
HTTP Request
PUT https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the framework | |
json | No | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Delete a Campaign Event Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_templates/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Deletes the campaign event framework.
HTTP Request
DELETE https://api.userwise.io/api/v1/campaign_event_templates/{{ framework_id }}
Categories
Get All Categories
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_categories?app_id={{ app_id }}&categoryable_type={{ categoryable_type }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "6cfe42f2-94c8-4bf8-9ade-e2e0a98610b6",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Weekend Events",
"categoryable_type": "scheduled_campaign",
"color": "#F0F0F0"
},
...
]
}
Retrieves a list of campaign resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1/app_categories
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | No | None | Filter categories by the provided app_id. |
categoryable_type | No | None | The type of content to receive categories for. (scheduled_campaign, triggered_campaign, or campaign_content) |
enc | Yes | None | Generated request hash |
Create a Category
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_categories?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :categoryable_type=>"scheduled_campaign", :name=>"Weekend Events", :color=>"#F0F0F0"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/app_categories?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :categoryable_type=>"scheduled_campaign", :name=>"Weekend Events", :color=>"#F0F0F0"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_categories?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","categoryable_type":"scheduled_campaign","name":"Weekend Events","color":"#F0F0F0"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_categories?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","categoryable_type":"scheduled_campaign","name":"Weekend Events","color":"#F0F0F0"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_categories?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","categoryable_type":"scheduled_campaign","name":"Weekend Events","color":"#F0F0F0"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_categories?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","categoryable_type":"scheduled_campaign","name":"Weekend Events","color":"#F0F0F0"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "6cfe42f2-94c8-4bf8-9ade-e2e0a98610b6",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Weekend Events",
"categoryable_type": "scheduled_campaign",
"color": "#F0F0F0"
},
}
Creates a new campaign with the provided details.
HTTP Request
POST https://api.userwise.io/api/v1/app_categories
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | App ID for the category | |
categoryable_type | Yes | string | Must be "scheduled_campaign" or "triggered_campaign" | |
name | Yes | string | The display name for the category | |
color | Yes | string | The color to be used as a representation of this category in the UserWise UI |
Update a Category
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"Weekend Events", :color=>"#F0F0F0"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"Weekend Events", :color=>"#F0F0F0"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"Weekend Events","color":"#F0F0F0"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"Weekend Events","color":"#F0F0F0"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"Weekend Events","color":"#F0F0F0"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"Weekend Events","color":"#F0F0F0"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "6cfe42f2-94c8-4bf8-9ade-e2e0a98610b6",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "Weekend Events",
"categoryable_type": "scheduled_campaign",
"color": "#F0F0F0"
},
}
Updates the campaign with the provided details.
HTTP Request
PUT https://api.userwise.io/api/v1/app_categories/{{ category_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | Yes | string | The display name for the category | |
color | Yes | string | The color to be used as a representation of this category in the UserWise UI |
Delete a Category
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/app_categories/{{ category_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{ "data": "Successfully deleted the app category." }
Soft-deletes the category resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/app_categories/{{ category_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Emails
Add Email Address
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:email_address=>"[email protected]"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}',
payload: {:email_address=>"[email protected]"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"email_address":"[email protected]"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"email_address":"[email protected]"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"email_address":"[email protected]"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/:external_id/email_address?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"email_address":"[email protected]"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Adds the provided email address to the player's profile.
HTTP Request
PUT https://api.userwise.io/api/v2/appusers/:external_id/email_address
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
email_address | Yes | string | The player's email address |
Remove Email Address (Incl. Opt-Out)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:email_address=>"apns"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}',
payload: {:email_address=>"apns"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/:external_id/email_address?session_id={{ session_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"email_address":"apns"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Removes the provided email address from the player's profile.
HTTP Request
DELETE https://api.userwise.io/api/v2/appusers/:external_id/email_address
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
session_id | No | None | Whether to fully opt the player out of emails forever. |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
email_address | Yes | string | apns or fcm |
Get Settings
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/emails/settings?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
Retrieves the current email settings for the authenticated app.
{
"data": [
{
"sender_domain": "example.com",
"sender_domain_verification_state": "domain_verification_success",
"sender_domain_dkim_tokens": [
"token1",
"token2"
],
"sender_email": "[email protected]",
"sender_email_verification_state": "email_verification_success",
"template": "<html><body>{{body}}</body></html>"
},
...
]
}
HTTP Request
GET https://api.userwise.io/api/v2/emails/settings
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Update Settings
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:sender_domain=>"example.com", :sender_email=>"[email protected]", :template=>"<html><body>{{body}}</body></html>"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}',
payload: {:sender_domain=>"example.com", :sender_email=>"[email protected]", :template=>"<html><body>{{body}}</body></html>"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"sender_domain":"example.com","sender_email":"[email protected]","template":"\u003chtml\u003e\u003cbody\u003e{{body}}\u003c/body\u003e\u003c/html\u003e"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"sender_domain":"example.com","sender_email":"[email protected]","template":"\u003chtml\u003e\u003cbody\u003e{{body}}\u003c/body\u003e\u003c/html\u003e"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/emails/settings?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"sender_domain":"example.com","sender_email":"[email protected]","template":"\u003chtml\u003e\u003cbody\u003e{{body}}\u003c/body\u003e\u003c/html\u003e"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/emails/settings?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"sender_domain":"example.com","sender_email":"[email protected]","template":"\u003chtml\u003e\u003cbody\u003e{{body}}\u003c/body\u003e\u003c/html\u003e"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
Updates the email setting for the authenticated app.
{
"data": [
{
"sender_domain": "example.com",
"sender_domain_verification_state": "domain_verification_success",
"sender_domain_dkim_tokens": [
"token1",
"token2"
],
"sender_email": "[email protected]",
"sender_email_verification_state": "email_verification_success",
"template": "<html><body>{{body}}</body></html>"
},
...
]
}
HTTP Request
PUT https://api.userwise.io/api/v2/emails/settings
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
sender_domain | No | string | The new domain of the email address (for DKIM signing) | |
sender_email | No | string | The new email address to use in the 'From' field | |
template | No | string | The email template to use - must include the {{body}} substitution tag |
Engagement Outcomes
Get all Engagement Outcomes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/engagement/outcomes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [{
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"name": "Message Opened 5 Times",
"key": "message_opened_5_times",
"type": "message"
}],
"meta": {
"warnings": [],
"hints": []
}
}
Retrieves all registered engagement outcomes.
HTTP Request
GET https://api.userwise.io/api/v2/engagement/outcomes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Get an Engagement Outcome
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/engagement/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"name": "Message Opened 5 Times",
"key": "message_opened_5_times",
"type": "message"
},
"meta": {
"warnings": [],
"hints": []
}
}
Retrieves an engagement outcome.
HTTP Request
GET https://api.userwise.io/api/v2/engagement/outcomes/{{ engagement_outcome_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create an Engagement Outcome
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"Message Opened 5 Times", :key=>"message_opened_5_times", :type=>"dev"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}',
payload: {:name=>"Message Opened 5 Times", :key=>"message_opened_5_times", :type=>"dev"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"Message Opened 5 Times","key":"message_opened_5_times","type":"dev"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"Message Opened 5 Times","key":"message_opened_5_times","type":"dev"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/engagement/outcomes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"Message Opened 5 Times","key":"message_opened_5_times","type":"dev"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/engagement/outcomes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"Message Opened 5 Times","key":"message_opened_5_times","type":"dev"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"name": "Message Opened 5 Times",
"key": "message_opened_5_times",
"type": "message"
},
"meta": {
"warnings": [],
"hints": []
}
}
Creates a new engagement outcome.
HTTP Request
POST https://api.userwise.io/api/v2/engagement/outcomes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | Yes | string | The display name of the engagement outcome | |
key | Yes | string | Unique key for the engagement outcome | |
type | Yes | string | The type of the engagement outcome. Must be one of: campaign_event, email, offer, message, or push_notification. |
Update an Engagement Outcome
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"Message Opened 5 Times", :key=>"message_opened_5_times"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"Message Opened 5 Times", :key=>"message_opened_5_times"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"Message Opened 5 Times","key":"message_opened_5_times"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"Message Opened 5 Times","key":"message_opened_5_times"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"Message Opened 5 Times","key":"message_opened_5_times"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/engagements/outcomes/{{ engagement_outcome_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"Message Opened 5 Times","key":"message_opened_5_times"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"name": "Message Opened 5 Times",
"key": "message_opened_5_times",
"type": "message"
},
"meta": {
"warnings": [],
"hints": []
}
}
Updates an environment with the provided data.
HTTP Request
PUT https://api.userwise.io/api/v2/engagements/outcomes/{{ engagement_outcome_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name of the engagement outcome | |
key | No | string | Unique key for the engagement outcome |
Delete an Engagement Outcomes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/engagement/outcomes/:engagement_outcome_id?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Delete an engagement outcome.
HTTP Request
DELETE https://api.userwise.io/api/v2/engagement/outcomes/:engagement_outcome_id
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Environments
Get All Environments
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/environments?app_id={{ app_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "e7fda084-bd96-415a-937b-8ee7b8636733",
"created_at": "2023-07-06T16:24:58Z",
"updated_at": "2023-07-06T16:24:58Z",
"name": "Dev",
"key": "dev",
"type": "dev",
"default": true
},
{
"id": "10565c88-6a2e-4ea7-b9fb-026f09701529",
"created_at": "2023-07-06T16:24:58Z",
"updated_at": "2023-07-06T16:24:58Z",
"name": "QA",
"key": "qa",
"type": "qa",
"default": true
},
{
"id": "180cf5c6-96e3-455c-bde5-833a96e7fe76",
"created_at": "2023-07-06T16:24:58Z",
"updated_at": "2023-07-06T16:24:58Z",
"name": "Live",
"key": "live",
"type": "live",
"default": true
}
],
"meta": {
"warnings": [],
"hints": [],
"query": {
"current_page": 1,
"current_page_record_count": 3,
"records_per_page": 10,
"total_pages": 1,
"total_records": 3
}
}
}
Retrieves environments for the provided app.
HTTP Request
GET https://api.userwise.io/api/v2/environments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | The ID of the app to load records from. |
enc | Yes | None | Generated request hash |
Get an Environment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/environments/{{ environment_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "180cf5c6-96e3-455c-bde5-833a96e7fe76",
"created_at": "2023-07-06T16:24:58Z",
"updated_at": "2023-07-06T16:24:58Z",
"name": "Live",
"key": "live",
"type": "live",
"default": true
}
}
Retrieves an environment
HTTP Request
GET https://api.userwise.io/api/v2/environments/{{ environment_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | The ID of the app to load records from. |
enc | Yes | None | Generated request hash |
Create an Environment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/environments?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"Tom's Dev Environment", :key=>"tom-dev-env", :type=>"dev"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/environments?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"Tom's Dev Environment", :key=>"tom-dev-env", :type=>"dev"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/environments?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env","type":"dev"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/environments?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env","type":"dev"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/environments?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env","type":"dev"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/environments?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env","type":"dev"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2023-07-11T19:35:23Z",
"updated_at": "2023-07-11T19:35:23Z",
"name": "Tom's Dev Env",
"key": "toms-dev-env",
"type": "dev",
"default": false
},
"meta": {
"warnings": [],
"hints": []
}
}
Creates a new environment with the provided data.
HTTP Request
POST https://api.userwise.io/api/v2/environments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | App ID for the campaign | |
name | Yes | string | The display name of the environment | |
key | Yes | string | The app-unique environment identifier that is used for API requests (e.g. environment_stage ). |
|
type | Yes | string | Must be dev , qa , live . |
Update an Environment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"Tom's Dev Environment", :key=>"tom-dev-env"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :name=>"Tom's Dev Environment", :key=>"tom-dev-env"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/environments/{{ environment_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","name":"Tom's Dev Environment","key":"tom-dev-env"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2023-07-11T19:35:23Z",
"updated_at": "2023-07-11T19:35:23Z",
"name": "Tom's Dev Env",
"key": "toms-dev-env",
"type": "dev",
"default": false
},
"meta": {
"warnings": [],
"hints": []
}
}
Updates an environment with the provided data.
HTTP Request
PUT https://api.userwise.io/api/v2/environments/{{ environment_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | App ID for the campaign | |
name | No | string | The display name of the environment | |
key | No | string | The app-unique environment identifier that is used for API requests (e.g. environment_stage ). |
Journeys
Get all Journeys
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [{
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"environment_id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"environment_type": "dev",
"environment_key": "dev",
"shared_environment_ids": [
"0dd7ae09-1fa4-4d70-a7be-4970a53f9e78"
],
"name": "My Journey",
"description": "A journey to engage users",
"steps": [
],
"edges": [
],
"entry_rules": {
"rules_predicate": "all",
"on_entry_strategy": "remove_from_specific_journeys",
"on_entry_strategy_config": {
"journey_ids": [
"16dd40cd-0328-4d4a-820d-b9b01f79c86a"
]
},
"rules": [
{
"entry_strategy": "player_segment_entry",
"entry_strategy_config": {
"segment_ids": [
"a31a4a1b-4529-4109-ab3b-cdf0a62d9757"
]
}
}
]
},
"exit_rules": {
"rules_predicate": "any",
"on_exit_strategy": "none",
"on_exit_strategy_config": {
},
"rules": [
{
"exit_strategy": "on_segment_match_or_journey_complete",
"exit_strategy_config": {
"segment_ids": [
"11dd7aae-4477-408f-a35e-4801efd1b16e"
]
}
}
]
},
"reenrollment_rules": {
"allowed": true,
"limit": 100,
"cooldown_duration": 60,
"cooldown_duration_unit": "minutes"
},
"using_override_data": false
}],
"meta": {
"warnings": [],
"hints": []
}
}
Retrieves all journeys.
HTTP Request
GET https://api.userwise.io/api/v2/journeys
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to retrieve journeys from |
enc | Yes | None | Generated request hash |
Get an Journey
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"environment_id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"environment_type": "dev",
"environment_key": "dev",
"shared_environment_ids": [
"0dd7ae09-1fa4-4d70-a7be-4970a53f9e78"
],
"name": "My Journey",
"description": "A journey to engage users",
"steps": [
],
"edges": [
],
"entry_rules": {
"rules_predicate": "all",
"on_entry_strategy": "remove_from_specific_journeys",
"on_entry_strategy_config": {
"journey_ids": [
"16dd40cd-0328-4d4a-820d-b9b01f79c86a"
]
},
"rules": [
{
"entry_strategy": "player_segment_entry",
"entry_strategy_config": {
"segment_ids": [
"a31a4a1b-4529-4109-ab3b-cdf0a62d9757"
]
}
}
]
},
"exit_rules": {
"rules_predicate": "any",
"on_exit_strategy": "none",
"on_exit_strategy_config": {
},
"rules": [
{
"exit_strategy": "on_segment_match_or_journey_complete",
"exit_strategy_config": {
"segment_ids": [
"11dd7aae-4477-408f-a35e-4801efd1b16e"
]
}
}
]
},
"reenrollment_rules": {
"allowed": true,
"limit": 100,
"cooldown_duration": 60,
"cooldown_duration_unit": "minutes"
},
"using_override_data": false
},
"meta": {
"warnings": [],
"hints": []
}
}
Retrieves an engagement outcome.
HTTP Request
GET https://api.userwise.io/api/v2/journeys/{{ journey_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to retrieve the journey from |
enc | Yes | None | Generated request hash |
Create a Journey
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:environment_id=>"", :name=>"My Journey", :description=>"This is a journey", :"entry_rules.rule_predicate"=>"all", :"entry_rules.on_entry_strategy"=>"", :"entry_rules.on_entry_strategy_config"=>"", :"entry_rules.rules.0..entry_strategy"=>"", :"entry_rules.rules.0..entry_strategy_config"=>"", :"exit_rules.rule_predicate"=>"any", :"exit_rules.on_exit_strategy"=>"", :"exit_rules.on_exit_strategy_config"=>"", :"exit_rules.rules.0..exit_strategy"=>"", :"exit_rules.rules.0..exit_strategy_config"=>"", :"reenrollment.allowed"=>"", :"reenrollment.limit"=>"", :"reenrollment.cooldown_duration"=>"", :"reenrollment.cooldown_unit"=>"", :shared_environment_ids=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/journeys?enc={{ generated_request_hash }}',
payload: {:environment_id=>"", :name=>"My Journey", :description=>"This is a journey", :"entry_rules.rule_predicate"=>"all", :"entry_rules.on_entry_strategy"=>"", :"entry_rules.on_entry_strategy_config"=>"", :"entry_rules.rules.0..entry_strategy"=>"", :"entry_rules.rules.0..entry_strategy_config"=>"", :"exit_rules.rule_predicate"=>"any", :"exit_rules.on_exit_strategy"=>"", :"exit_rules.on_exit_strategy_config"=>"", :"exit_rules.rules.0..exit_strategy"=>"", :"exit_rules.rules.0..exit_strategy_config"=>"", :"reenrollment.allowed"=>"", :"reenrollment.limit"=>"", :"reenrollment.cooldown_duration"=>"", :"reenrollment.cooldown_unit"=>"", :shared_environment_ids=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0..exit_strategy":"","exit_rules.rules.0..exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0..exit_strategy":"","exit_rules.rules.0..exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0..exit_strategy":"","exit_rules.rules.0..exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0..exit_strategy":"","exit_rules.rules.0..exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"environment_id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"environment_type": "dev",
"environment_key": "dev",
"shared_environment_ids": [
"0dd7ae09-1fa4-4d70-a7be-4970a53f9e78"
],
"name": "My Journey",
"description": "A journey to engage users",
"steps": [
],
"edges": [
],
"entry_rules": {
"rules_predicate": "all",
"on_entry_strategy": "remove_from_specific_journeys",
"on_entry_strategy_config": {
"journey_ids": [
"16dd40cd-0328-4d4a-820d-b9b01f79c86a"
]
},
"rules": [
{
"entry_strategy": "player_segment_entry",
"entry_strategy_config": {
"segment_ids": [
"a31a4a1b-4529-4109-ab3b-cdf0a62d9757"
]
}
}
]
},
"exit_rules": {
"rules_predicate": "any",
"on_exit_strategy": "none",
"on_exit_strategy_config": {
},
"rules": [
{
"exit_strategy": "on_segment_match_or_journey_complete",
"exit_strategy_config": {
"segment_ids": [
"11dd7aae-4477-408f-a35e-4801efd1b16e"
]
}
}
]
},
"reenrollment_rules": {
"allowed": true,
"limit": 100,
"cooldown_duration": 60,
"cooldown_duration_unit": "minutes"
},
"using_override_data": false
},
"meta": {
"warnings": [],
"hints": []
}
}
Creates a new Journey
HTTP Request
POST https://api.userwise.io/api/v2/journeys
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
environment_id | Yes | string | The ID of the environment that the journey belongs to | |
name | No | string | The name of the journey | |
description | No | string | The description of the journey | |
entry_rules.rule_predicate | No | string | The predicate for the entry rules: must be 'all' | |
entry_rules.on_entry_strategy | No | string | The strategy for the entry rules: must be 'none', 'remove_from_all_other_journeys', or 'remove_from_specific_journeys' | |
entry_rules.on_entry_strategy_config | No | hashmap | The configuration for the entry rule strategy: must be '{}' or '{journey_ids: []}' | |
entry_rules.rules.0..entry_strategy | No | string | The strategy for the entry rule: must be 'player_segment_entry' or 'player_action' | |
entry_rules.rules.0..entry_strategy_config | No | string | The configuration for the entry strategy: must be '{segment_ids: []}' or a valid trigger '{type: 'attribute', logic: {}}' | |
exit_rules.rule_predicate | No | string | The predicate for the exit rules: must be 'any' | |
exit_rules.on_exit_strategy | No | string | Strategy to run on exit: must be 'none' | |
exit_rules.on_exit_strategy_config | No | hashmap | The configuration for the exit rule strategy: must be '{}' | |
exit_rules.rules.0..exit_strategy | No | string | The strategy for the exit rule: must be 'on_journey_complete' or 'on_segment_match_or_journey_complete' | |
exit_rules.rules.0..exit_strategy_config | No | string | The configuration for the exit strategy: must be '{}' or '{segment_ids: []}' | |
reenrollment.allowed | No | boolean | Whether the journey allows re-enrollment | |
reenrollment.limit | No | integer | The max times a player can re-enroll in the journey | |
reenrollment.cooldown_duration | No | integer | The duration in seconds that a player must wait before re-enrolling in the journey | |
reenrollment.cooldown_unit | No | string | The unit of time for the cooldown duration: must be 'seconds', 'minutes', 'hours', 'days', 'weeks', or 'months' | |
shared_environment_ids | No | array | IDs of environments that the journey should be shared with |
Update a Journey
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:environment_id=>"", :name=>"My Journey", :description=>"This is a journey", :"entry_rules.rule_predicate"=>"all", :"entry_rules.on_entry_strategy"=>"", :"entry_rules.on_entry_strategy_config"=>"", :"entry_rules.rules.0..entry_strategy"=>"", :"entry_rules.rules.0..entry_strategy_config"=>"", :"exit_rules.rule_predicate"=>"any", :"exit_rules.on_exit_strategy"=>"", :"exit_rules.on_exit_strategy_config"=>"", :"exit_rules.rules.0.exit_strategy"=>"", :"exit_rules.rules.0.exit_strategy_config"=>"", :"reenrollment.allowed"=>"", :"reenrollment.limit"=>"", :"reenrollment.cooldown_duration"=>"", :"reenrollment.cooldown_unit"=>"", :shared_environment_ids=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}',
payload: {:environment_id=>"", :name=>"My Journey", :description=>"This is a journey", :"entry_rules.rule_predicate"=>"all", :"entry_rules.on_entry_strategy"=>"", :"entry_rules.on_entry_strategy_config"=>"", :"entry_rules.rules.0..entry_strategy"=>"", :"entry_rules.rules.0..entry_strategy_config"=>"", :"exit_rules.rule_predicate"=>"any", :"exit_rules.on_exit_strategy"=>"", :"exit_rules.on_exit_strategy_config"=>"", :"exit_rules.rules.0.exit_strategy"=>"", :"exit_rules.rules.0.exit_strategy_config"=>"", :"reenrollment.allowed"=>"", :"reenrollment.limit"=>"", :"reenrollment.cooldown_duration"=>"", :"reenrollment.cooldown_unit"=>"", :shared_environment_ids=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0.exit_strategy":"","exit_rules.rules.0.exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0.exit_strategy":"","exit_rules.rules.0.exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0.exit_strategy":"","exit_rules.rules.0.exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"environment_id":"","name":"My Journey","description":"This is a journey","entry_rules.rule_predicate":"all","entry_rules.on_entry_strategy":"","entry_rules.on_entry_strategy_config":"","entry_rules.rules.0..entry_strategy":"","entry_rules.rules.0..entry_strategy_config":"","exit_rules.rule_predicate":"any","exit_rules.on_exit_strategy":"","exit_rules.on_exit_strategy_config":"","exit_rules.rules.0.exit_strategy":"","exit_rules.rules.0.exit_strategy_config":"","reenrollment.allowed":"","reenrollment.limit":"","reenrollment.cooldown_duration":"","reenrollment.cooldown_unit":"","shared_environment_ids":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"created_at": "2024-03-05T19:35:23Z",
"updated_at": "2024-03-05T19:35:23Z",
"environment_id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"environment_type": "dev",
"environment_key": "dev",
"shared_environment_ids": [
"0dd7ae09-1fa4-4d70-a7be-4970a53f9e78"
],
"name": "My Journey",
"description": "A journey to engage users",
"steps": [
],
"edges": [
],
"entry_rules": {
"rules_predicate": "all",
"on_entry_strategy": "remove_from_specific_journeys",
"on_entry_strategy_config": {
"journey_ids": [
"16dd40cd-0328-4d4a-820d-b9b01f79c86a"
]
},
"rules": [
{
"entry_strategy": "player_segment_entry",
"entry_strategy_config": {
"segment_ids": [
"a31a4a1b-4529-4109-ab3b-cdf0a62d9757"
]
}
}
]
},
"exit_rules": {
"rules_predicate": "any",
"on_exit_strategy": "none",
"on_exit_strategy_config": {
},
"rules": [
{
"exit_strategy": "on_segment_match_or_journey_complete",
"exit_strategy_config": {
"segment_ids": [
"11dd7aae-4477-408f-a35e-4801efd1b16e"
]
}
}
]
},
"reenrollment_rules": {
"allowed": true,
"limit": 100,
"cooldown_duration": 60,
"cooldown_duration_unit": "minutes"
},
"using_override_data": false
},
"meta": {
"warnings": [],
"hints": []
}
}
Updates a Journey's entry rules, exit rules, metadata, and reenrollment settings.
HTTP Request
PUT https://api.userwise.io/api/v2/journeys/{{ journey_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
environment_id | Yes | string | The ID of the environment to update the Journey in | |
name | No | string | The name of the journey | |
description | No | string | The description of the journey | |
entry_rules.rule_predicate | No | string | The predicate for the entry rules: must be 'all' | |
entry_rules.on_entry_strategy | No | string | The strategy for the entry rules: must be 'none', 'remove_from_all_other_journeys', or 'remove_from_specific_journeys' | |
entry_rules.on_entry_strategy_config | No | hashmap | The configuration for the entry rule strategy: must be '{}' or '{journey_ids: []}' | |
entry_rules.rules.0..entry_strategy | No | string | The strategy for the entry rule: must be 'player_segment_entry' or 'player_action' | |
entry_rules.rules.0..entry_strategy_config | No | string | The configuration for the entry strategy: must be '{segment_ids: []}' or a valid trigger '{type: 'attribute', logic: {}}' | |
exit_rules.rule_predicate | No | string | The predicate for the exit rules: must be 'any' | |
exit_rules.on_exit_strategy | No | string | Strategy to run on exit: must be 'none' | |
exit_rules.on_exit_strategy_config | No | hashmap | The configuration for the exit rule strategy: must be '{}' | |
exit_rules.rules.0.exit_strategy | No | string | The strategy for the exit rule: must be 'on_journey_complete' or 'on_segment_match_or_journey_complete' | |
exit_rules.rules.0.exit_strategy_config | No | string | The configuration for the exit strategy: must be '{}' or '{segment_ids: []}' | |
reenrollment.allowed | No | boolean | Whether the journey allows re-enrollment | |
reenrollment.limit | No | integer | The max times a player can re-enroll in the journey | |
reenrollment.cooldown_duration | No | integer | The duration in seconds that a player must wait before re-enrolling in the journey | |
reenrollment.cooldown_unit | No | string | The unit of time for the cooldown duration: must be 'seconds', 'minutes', 'hours', 'days', 'weeks', or 'months' | |
shared_environment_ids | No | array | IDs of environments that the journey should be shared with |
Delete a Journeys
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Delete a Journey.
HTTP Request
DELETE https://api.userwise.io/api/v2/journeys/{{ journey_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to remove the Journey from |
enc | Yes | None | Generated request hash |
Journey Steps
Get all Steps
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [{
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"type": "message",
"position": {
"row": -1,
"column": 0
},
"config": {
"delay_type": "time_delay",
"time_delay_type": "relative",
"duration_number": 5,
"duration_unit": "minute"
},
"advancement": {
"type": "immediate",
"config": {
}
}
}],
"meta": {
"warnings": [],
"hints": []
}
}
Retrieves all steps in the journey, within the provided environment.
HTTP Request
GET https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to retrieve journeys from |
enc | Yes | None | Generated request hash |
Get a Step
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:environment_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}',
payload: {:environment_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"environment_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"type": "message",
"position": {
"row": -1,
"column": 0
},
"config": {
"delay_type": "time_delay",
"time_delay_type": "relative",
"duration_number": 5,
"duration_unit": "minute"
},
"advancement": {
"type": "immediate",
"config": {
}
}
},
"meta": {
"warnings": [],
"hints": []
}
}
Retrieve a single step's configuration in a journey, within a specific environment.
HTTP Request
GET https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Step
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:environment_id=>"", :type=>"", :config=>"", :"position.column"=>"", :"position.row"=>"", :"advancement.type"=>"", :"advancement.config"=>"", :"incoming_edges.create.from_id"=>"", :"incoming_edges.create.type_config"=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}',
payload: {:environment_id=>"", :type=>"", :config=>"", :"position.column"=>"", :"position.row"=>"", :"advancement.type"=>"", :"advancement.config"=>"", :"incoming_edges.create.from_id"=>"", :"incoming_edges.create.type_config"=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"type": "message",
"position": {
"row": -1,
"column": 0
},
"config": {
"delay_type": "time_delay",
"time_delay_type": "relative",
"duration_number": 5,
"duration_unit": "minute"
},
"advancement": {
"type": "immediate",
"config": {
}
}
},
"meta": {
"warnings": [],
"hints": []
}
}
Creates a new step (and edges) in a journey, with the provided environment.
HTTP Request
POST https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
environment_id | Yes | string | The ID of the environment to create the step in | |
type | Yes | string | The type of the step: must be 'content', 'branch', 'exit', or 'delay' | |
config | Yes | hashmap | The configuration of the step. The structure of this field depends on the type of the step. See the Journeys Step Configuration section for more information. | |
position.column | Yes | integer | The column the step should be placed in, within the journeys canvas UI | |
position.row | Yes | integer | The row the step should be placed in, within the journeys canvas UI | |
advancement.type | Yes | string | The type of advancement the step should use: must be 'immediate' or 'engagement_outcome' | |
advancement.config | Yes | hashmap | The configuration of the advancement. The structure of this field must be '{}' | |
incoming_edges.create.from_id | No | string | The ID of the step that the new step should have an incoming edge from | |
incoming_edges.create.type_config | No | string | The configuration of the incoming edge. The structure of this field depends on the type of the step the edge is coming from. See the Journeys Step Configuration section for more information. |
Update a Step
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:environment_id=>"", :type=>"", :config=>"", :"position.column"=>"", :"position.row"=>"", :"advancement.type"=>"", :"advancement.config"=>"", :"incoming_edges.create.from_id"=>"", :"incoming_edges.create.type_config"=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}',
payload: {:environment_id=>"", :type=>"", :config=>"", :"position.column"=>"", :"position.row"=>"", :"advancement.type"=>"", :"advancement.config"=>"", :"incoming_edges.create.from_id"=>"", :"incoming_edges.create.type_config"=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"environment_id":"","type":"","config":"","position.column":"","position.row":"","advancement.type":"","advancement.config":"","incoming_edges.create.from_id":"","incoming_edges.create.type_config":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "94a6665f-1372-4c39-8563-a2dd4ae6ee0a",
"type": "message",
"position": {
"row": -1,
"column": 0
},
"config": {
"delay_type": "time_delay",
"time_delay_type": "relative",
"duration_number": 5,
"duration_unit": "minute"
},
"advancement": {
"type": "immediate",
"config": {
}
}
},
"meta": {
"warnings": [],
"hints": []
}
}
Updates a Step within the specified Journey.
HTTP Request
POST https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
environment_id | Yes | string | The ID of the environment to create the step in | |
type | No | string | The type of the step: must be 'content', 'branch', 'exit', or 'delay' | |
config | No | hashmap | The configuration of the step. The structure of this field depends on the type of the step. See the Journeys Step Configuration section for more information. | |
position.column | No | integer | The column the step should be placed in, within the journeys canvas UI | |
position.row | No | integer | The row the step should be placed in, within the journeys canvas UI | |
advancement.type | No | string | The type of advancement the step should use: must be 'immediate' or 'engagement_outcome' | |
advancement.config | No | hashmap | The configuration of the advancement. The structure of this field must be '{}' | |
incoming_edges.create.from_id | No | string | The ID of the step that the new step should have an incoming edge from | |
incoming_edges.create.type_config | No | string | The configuration of the incoming edge. The structure of this field depends on the type of the step the edge is coming from. See the Journeys Step Configuration section for more information. |
Duplicate a Step
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Duplicate a step. This will create a new step with the same configuration as the original step, within the same journey and provided environment.
HTTP Request
POST https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}/duplicate
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to remove the Journey from |
enc | Yes | None | Generated request hash |
Delete a Step
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}?environment_id={{ environment_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Delete a step (and its edges) from a journey, within the provided environment.
HTTP Request
DELETE https://api.userwise.io/api/v2/journeys/{{ journey_id }}/steps/{{ step_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_id | Yes | None | The ID of the environment to remove the Step from |
enc | Yes | None | Generated request hash |
JSON Lists
Get Lists
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1//apps/{{ app_id }}/campaign_event_lists?query={{ query }}&page={{ page }}&per_page={{ per_page }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "d3c9a6e1-d263-48d5-ae7c-471a268fb7b3",
"name": "My List",
"key": "myList",
"list": [
{
"id": "1",
"name": "List Item 1"
},
{
"id": "2",
"name": "List Item 2"
},
{
"id": "3",
"name": "List Item 3"
}
]
},
...
]
}
Retrieves a list of JSON list resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter json lists; searches for key and name . |
page | No | None | Curren page. Used with pagination |
per_page | No | None | Number of records per page. Used with pagination |
enc | Yes | None | Generated request hash |
Get a List
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "d3c9a6e1-d263-48d5-ae7c-471a268fb7b3",
"name": "My List",
"key": "myList",
"list": [
{
"id": "1",
"name": "List Item 1"
},
{
"id": "2",
"name": "List Item 2"
},
{
"id": "3",
"name": "List Item 3"
}
]
},
}
Retrieves a list of JSON list resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1//apps/{{ app_id }}/campaign_event_lists/{{ json_list_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a List
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/apps/{{ app_id }}/campaign_event_lists?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "d3c9a6e1-d263-48d5-ae7c-471a268fb7b3",
"name": "My List",
"key": "myList",
"list": [
{
"id": "1",
"name": "List Item 1"
},
{
"id": "2",
"name": "List Item 2"
},
{
"id": "3",
"name": "List Item 3"
}
]
},
}
Creates a new JSON list resource, connected to the app.
HTTP Request
POST https://api.userwise.io/api/v1/apps/{{ app_id }}/campaign_event_lists
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Update a List
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My List", :key=>"myList", :list=>[{:id=>"1", :name=>"List Item 1"}, {:id=>"2", :name=>"List Item 2"}, {:id=>"3", :name=>"List Item 3"}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My List", :key=>"myList", :list=>[{:id=>"1", :name=>"List Item 1"}, {:id=>"2", :name=>"List Item 2"}, {:id=>"3", :name=>"List Item 3"}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My List","key":"myList","list":[{"id":"1","name":"List Item 1"},{"id":"2","name":"List Item 2"},{"id":"3","name":"List Item 3"}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My List","key":"myList","list":[{"id":"1","name":"List Item 1"},{"id":"2","name":"List Item 2"},{"id":"3","name":"List Item 3"}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My List","key":"myList","list":[{"id":"1","name":"List Item 1"},{"id":"2","name":"List Item 2"},{"id":"3","name":"List Item 3"}]}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My List","key":"myList","list":[{"id":"1","name":"List Item 1"},{"id":"2","name":"List Item 2"},{"id":"3","name":"List Item 3"}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "d3c9a6e1-d263-48d5-ae7c-471a268fb7b3",
"name": "My List",
"key": "myList",
"list": [
{
"id": "1",
"name": "List Item 1"
},
{
"id": "2",
"name": "List Item 2"
},
{
"id": "3",
"name": "List Item 3"
}
]
}
}
Updates the JSON list resource with the provided changes.
HTTP Request
PUT https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name of the list | |
key | No | string | The key used to reference this list in JSON templates | |
list | No | array | An array of objects containing the following schema: { "key": "string", "value": "string" } |
Delete a List
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/campaign_event_lists/{{ json_list_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200
{ "data": "Successfully deleted the JSON list." }
Deletes the JSON list resource in our system.
HTTP Request
DELETE https://api.userwise.io/api/v1/campaign_event_lists/{{ json_list_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Media Library
Find Media
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "ea583b30-9ade-4b6b-ba6e-8b3a9e87d9d7",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "new_logo.png",
"content_type": "image/png",
"byte_size": 38067,
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"variants": {
"extra_small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 50,
"max_height": 50
},
"small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 100,
"max_height": 100
},
"medium": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 250,
"max_height": 250
},
"large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 500,
"max_height": 500
},
"extra_large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 1000,
"max_height": 1000
}
}
},
...
]
}
Retrieves a list of all media records within the UserWise platform for your company.
HTTP Request
GET https://api.userwise.io/api/v1/media_library
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | App id to use when filtering results |
enc | Yes | None | Generated request hash |
Get a Specific Media Record
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "ea583b30-9ade-4b6b-ba6e-8b3a9e87d9d7",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "new_logo.png",
"content_type": "image/png",
"byte_size": 38067,
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"variants": {
"extra_small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 50,
"max_height": 50
},
"small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 100,
"max_height": 100
},
"medium": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 250,
"max_height": 250
},
"large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 500,
"max_height": 500
},
"extra_large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 1000,
"max_height": 1000
}
}
}
}
Retrieves full details of a single media library record.
HTTP Request
GET https://api.userwise.io/api/v1/media_library/{{ media_record_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Upload new Media
Request:
curl "https://api.userwise.io/api/v1/media_library?app_id={{ app_id }}&enc={{ generated_request_hash }}" \
-X POST \
-H "X-Api-Key: {{ api_key_base64_encoded }}" \
-F media=@/path/to/file.ext
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ api_key }}')
request.set_form [['media', File.new('/path/to/file.ext', 'rb')]]
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ generated_request_hash }}',
headers: { 'X-Api-Key': Base64.encode64('{{ api_key }}') },
payload: {
:multipart => true,
:media => File.new('/path/to/file.ext', 'rb')
}
)
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('X-Api-Key: ' . base64_encode('{{ api_key }}')),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('media' => '@' . realpath('/path/to/file.ext'))
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = { "X-Api-Key": base64.b64encode("{{ api_key }}") }
files = { 'media': open('/path/to/file.ext', 'rb') }
requests.post(url, headers=headers, files=files)
const fs = require('fs');
const request = require('request'); // https://www.npmjs.com/package/request
const options = {
"method": "POST",
"url": "https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ request_hash }}",
"headers": {
"X-Api-Key": Buffer.from("{{ api_key }}").toString('base64')
}
};
const req = request.post(options, (err, resp, body) => {
console.log(err, resp, body);
});
const form = req.form();
form.append('media', fs.createReadStream('/path/to/file.ext'));
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "ea583b30-9ade-4b6b-ba6e-8b3a9e87d9d7",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "new_logo.png",
"content_type": "image/png",
"byte_size": 38067,
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"variants": {
"extra_small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 50,
"max_height": 50
},
"small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 100,
"max_height": 100
},
"medium": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 250,
"max_height": 250
},
"large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 500,
"max_height": 500
},
"extra_large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 1000,
"max_height": 1000
}
}
}
}
Uploads the provided media
file and creates a new media library record.
HTTP Request
POST https://api.userwise.io/api/v1/media_library
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | App that this media belongs to. |
enc | Yes | None | Generated request hash |
Multipart File Upload Parameters
File Field Name | Required | Description |
---|---|---|
media | Yes | Field name to use when attaching your file to the multipart HTTP request |
Replace Media File
Request:
curl "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?app_id={{ app_id }}&enc={{ generated_request_hash }}" \
-X PUT \
-H "X-Api-Key: {{ api_key_base64_encoded }}" \
-F media=@/path/to/file.ext
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library/?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ api_key }}')
request.set_form [['media', File.new('/path/to/file.ext', 'rb')]]
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/media_library/{{ media_record_id }}/?app_id={{ app_id }}&enc={{ generated_request_hash }}',
headers: { 'X-Api-Key': Base64.encode64('{{ api_key }}') },
payload: {
:multipart => true,
:media => File.new('/path/to/file.ext', 'rb')
}
)
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}/?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('X-Api-Key: ' . base64_encode('{{ api_key }}')),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => array('media' => '@' . realpath('/path/to/file.ext'))
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}/?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = { "X-Api-Key": base64.b64encode("{{ api_key }}") }
files = { 'media': open('/path/to/file.ext', 'rb') }
requests.put(url, headers=headers, files=files)
const fs = require('fs');
const request = require('request'); // https://www.npmjs.com/package/request
const options = {
"method": "PUT",
"url": "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}/?app_id={{ app_id }}&enc={{ request_hash }}",
"headers": {
"X-Api-Key": Buffer.from("{{ api_key }}").toString('base64')
}
};
const req = request.post(options, (err, resp, body) => {
console.log(err, resp, body);
});
const form = req.form();
form.append('media', fs.createReadStream('/path/to/file.ext'));
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "ea583b30-9ade-4b6b-ba6e-8b3a9e87d9d7",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "new_logo.png",
"content_type": "image/png",
"byte_size": 38067,
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"variants": {
"extra_small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 50,
"max_height": 50
},
"small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 100,
"max_height": 100
},
"medium": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 250,
"max_height": 250
},
"large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 500,
"max_height": 500
},
"extra_large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 1000,
"max_height": 1000
}
}
}
}
Overrides the media file for the provided media record. Essentially, allowing the hot-replacement of any old media file while it is in active use within UserWise content.
HTTP Request
PUT https://api.userwise.io/api/v1/media_library/{{ media_record_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | App that this media belongs to. |
enc | Yes | None | Generated request hash |
Multipart File Upload Parameters
File Field Name | Required | Description |
---|---|---|
media | Yes | Field name to use when attaching your file to the multipart HTTP request |
Update Media Record
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"new_logo.png"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"new_logo.png"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"new_logo.png"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"new_logo.png"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"new_logo.png"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"new_logo.png"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "ea583b30-9ade-4b6b-ba6e-8b3a9e87d9d7",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "new_logo.png",
"content_type": "image/png",
"byte_size": 38067,
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"variants": {
"extra_small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 50,
"max_height": 50
},
"small": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 100,
"max_height": 100
},
"medium": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 250,
"max_height": 250
},
"large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 500,
"max_height": 500
},
"extra_large": {
"url": "https://app.userwise.io/media_library/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBWHc9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889dd113ee2caa3ff5f816e42203a/new_logo.png",
"max_width": 1000,
"max_height": 1000
}
}
}
}
Updates a media library record with the provided information.
HTTP Request
PUT https://api.userwise.io/api/v1/media_library/{{ media_record_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | Update the media record's name |
Delete Media Record
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/media_library/{{ media_record_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Deletes a media library record.
HTTP Request
DELETE https://api.userwise.io/api/v1/media_library/{{ media_record_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Message Types
Get Types
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1//message_types?app_id={{ app_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "79196cc0-07d2-4119-b6ed-c6a459d64ec7",
"name": "My Event Template",
"json": {
"name": {
"type": "string",
"title": "name",
"default": "Clan Games"
},
"total_points": {
"type": "integer",
"default": 75000,
"title": "Total Points"
},
"rewards": {
"type": "array",
"items": {
"type": "object",
"title": "Rewards",
"properties": {
"item": {
"type": "string",
"required": true
},
"amount": {
"type": "integer",
"required": true
}
}
}
}
},
"external_event_type": "my_event_type"
},
...
]
}
Retrieves a list of message type resources you have created within our system.
HTTP Request
GET https://api.userwise.io/api/v1//message_types
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | No | None | App ID used for filtering |
enc | Yes | None | Generated request hash |
Offers
Get All Offer Frameworks
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/offer_frameworks?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "08358f10-afcc-4dfc-a19e-e5ea9c1022a9",
"name": "My Framework",
"offer_type": "special_holiday_offer_identifier",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
...
]
}
Retrieves an array of all the offer frameworks, for your app.
HTTP Request
GET https://api.userwise.io/api/v2/offer_frameworks
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Get Offer Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "08358f10-afcc-4dfc-a19e-e5ea9c1022a9",
"name": "My Framework",
"offer_type": "special_holiday_offer_identifier",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
}
}
Retrieves a offer framework resource.
HTTP Request
GET https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create an Offer Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :offer_type=>"special_holiday_offer_identifier", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :offer_type=>"special_holiday_offer_identifier", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","offer_type":"special_holiday_offer_identifier","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"My Framework","offer_type":"special_holiday_offer_identifier","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/offer_frameworks?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","offer_type":"special_holiday_offer_identifier","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/offer_frameworks?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","offer_type":"special_holiday_offer_identifier","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "08358f10-afcc-4dfc-a19e-e5ea9c1022a9",
"name": "My Framework",
"offer_type": "special_holiday_offer_identifier",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Creates a new offer framework record with the provided information.
HTTP Request
POST https://api.userwise.io/api/v2/offer_frameworks
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | Yes | string | The display name for the framework | |
offer_type | Yes | string | An external identifier that helps you understand the type of offer framework this is. | |
schema | Yes | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Update a Offer Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/offers_framework/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "08358f10-afcc-4dfc-a19e-e5ea9c1022a9",
"name": "My Framework",
"offer_type": "special_holiday_offer_identifier",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Updates a offer framework with the new provided name
or schema
.
HTTP Request
PUT https://api.userwise.io/api/v2/offers_framework/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the framework | |
schema | No | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Delete a Offer Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/offer_frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Deletes the offer framework.
HTTP Request
DELETE https://api.userwise.io/api/v2/offer_frameworks/{{ framework_id }}
Player Attributes
Get All Attributes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/attributes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/attributes?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/attributes?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/attributes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/attributes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/attributes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"2ea6f56c-4585-4988-963b-4608cb7192ad": [
{ "name": "level", "data_type": "integer" },
{ "name": "is_whale", "data_type": "boolean" },
{ "name": "last_login", "data_type": "datetime" },
{ "name": "name", "data_type": "string" },
{ "name": "act_one_progress", "data_type": "float" }
],
"{{ app_id }}": [{}]
}
}
Retrieves a unique set of attributes broken down by the app's they've been seen in. The attribute name and data type is returned.
HTTP Request
GET https://api.userwise.io/api/v1/attributes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Assign Attributes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:attributes=>[{:name=>"player_level", :value=>120}, {:name=>"is_whale", :value=>true, :data_type=>"boolean"}], :session_id=>"64ada9c805378b000942ccde"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}',
payload: {:attributes=>[{:name=>"player_level", :value=>120}, {:name=>"is_whale", :value=>true, :data_type=>"boolean"}], :session_id=>"64ada9c805378b000942ccde"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/appuser/{{ appuser_external_id }}/attributes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Assigns the appuser the provided attribute names and value pairs. This operation acts as an upsert for attributes for the app user.
HTTP Request
POST https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/attributes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
attributes[].name | Yes | string | The attribute name to assign to the app user. |
attributes[].value | Yes | any | The attribute value to assign to the app user. |
attributes[].data_type | No | string | The attribute data type that should be used if encountering a new attribute. |
Bulk Assign Attributes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:assignment_data=>[{:id=>"player_1", :attributes=>{:player_level=>120, :is_whale=>true}}, {:id=>"player_2", :attributes=>{:player_level=>100, :is_whale=>false}}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}',
payload: {:assignment_data=>[{:id=>"player_1", :attributes=>{:player_level=>120, :is_whale=>true}}, {:id=>"player_2", :attributes=>{:player_level=>100, :is_whale=>false}}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"assignment_data":[{"id":"player_1","attributes":{"player_level":120,"is_whale":true}},{"id":"player_2","attributes":{"player_level":100,"is_whale":false}}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"assignment_data":[{"id":"player_1","attributes":{"player_level":120,"is_whale":true}},{"id":"player_2","attributes":{"player_level":100,"is_whale":false}}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"assignment_data":[{"id":"player_1","attributes":{"player_level":120,"is_whale":true}},{"id":"player_2","attributes":{"player_level":100,"is_whale":false}}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/bulk_assign_attributes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"assignment_data":[{"id":"player_1","attributes":{"player_level":120,"is_whale":true}},{"id":"player_2","attributes":{"player_level":100,"is_whale":false}}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Enables the assignment of attributes across multiple players.
HTTP Request
POST https://api.userwise.io/api/v2/appusers/bulk_assign_attributes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
assignment_data[].id | Yes | string | The player's id |
assignment_data[].attributes | Yes | any | A hash containing key=>value pairs of attributes to assign to the app user. |
Player Data
Get Player Data
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/appuser/:appuser_external_id?environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "players_id",
"last_login": "2024-01-17T18:03:43+00:00",
"traits": {
"_first_login_date": "2024-01-16T16:29:04.000Z",
"_language": "en"
},
"environment_details": {
"id": "8e3b5bb7-169c-4f4c-97c6-632573c4a4d1",
"name": "Dev",
"type": "dev",
"key": "dev",
"last_known_matching_segments": [
],
"num_sessions": 0
},
"has_email_address_registered": false,
"has_push_notification_tokens_registered": false
},
}
Completely removes all player data within the UserWise platform.
HTTP Request
GET https://api.userwise.io/api/v1/appuser/:appuser_external_id
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_stage | Yes | None | dev |
enc | Yes | None | Generated request hash |
Delete all Data
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/appuser/:appuser_external_id/data?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{ "data": "Successfully deleted all player data." }
Completely removes all player data within the UserWise platform.
HTTP Request
DELETE https://api.userwise.io/api/v1/appuser/:appuser_external_id/data
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Player Engagement Outcome
Register an Engagement Outcome
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:engagement_outcome_key=>"message_opened_5_times", :engagement_outcome_type=>"message", :journey_id=>"94a6665f-1372-4c39-8563-a2dd4ae6ee0a", :journey_step_id=>"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}',
payload: {:engagement_outcome_key=>"message_opened_5_times", :engagement_outcome_type=>"message", :journey_id=>"94a6665f-1372-4c39-8563-a2dd4ae6ee0a", :journey_step_id=>"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"engagement_outcome_key":"message_opened_5_times","engagement_outcome_type":"message","journey_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a","journey_step_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"engagement_outcome_key":"message_opened_5_times","engagement_outcome_type":"message","journey_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a","journey_step_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"engagement_outcome_key":"message_opened_5_times","engagement_outcome_type":"message","journey_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a","journey_step_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/:appuser_external_id/engagements/outcomes?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"engagement_outcome_key":"message_opened_5_times","engagement_outcome_type":"message","journey_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a","journey_step_id":"94a6665f-1372-4c39-8563-a2dd4ae6ee0a"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Registers a particular engagement outcome for the player.
HTTP Request
POST https://api.userwise.io/api/v2/appusers/:appuser_external_id/engagements/outcomes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
engagement_outcome_key | Yes | string | The key of the engagement outcome | |
engagement_outcome_type | Yes | string | The type of the engagement outcome | |
journey_id | No | string | The journey to filter the engagement outcome to | |
journey_step_id | No | string | The journey step to filter the engagement outcome to |
Player Events
Get All Events
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/events?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/events?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/events?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/events?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/events?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/events?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"baa77535-110e-4820-9cd4-6f34d7169cfd": [
{ "event_id": "achievement_level_20", "attributes": [] },
{ "event_id": "act_one_completed", "attributes": [] },
{ "event_id": "iap_purchased", "attributes": [
{ "name": "purchased_on", "data_type": "datetime" },
{ "name": "bundle_cost", "data_type": "float" }
] }
],
"{{ app_id }}": [{}]
}
}
Retrieves a unique set of all events with any attributes we've encountered, broken out by each app.
HTTP Request
GET https://api.userwise.io/api/v1/events
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Assign Events (w/ Attributes)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:events=>[{:event_id=>"achievement_level_20"}, {:event_id=>"act_one_completed", :attributes=>[{:name=>"act_one_completed_on", :value=>"2020-02-01T00:00:00Z"}]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}',
payload: {:events=>[{:event_id=>"achievement_level_20"}, {:event_id=>"act_one_completed", :attributes=>[{:name=>"act_one_completed_on", :value=>"2020-02-01T00:00:00Z"}]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/appuser/{{ appuser_external_id }}/events?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Assigns the appuser the provided event ids, along with any accompanying attributes. These attributes are tied uniquely to this event. This will not overwrite any app user attributes.
For a better understanding of how attributes work, see the Assign Attributes section of our documentation.
HTTP Request
POST https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/events
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
events[].event_id | Yes | string | The event id that should be assigned to the app user. |
events[].attributes[].name | No | string | An attribute name to assign to the app user. |
events[].attributes[].value | No | any | An attribute value to assign to the app user. |
events[].attributes[].data_type | No | string | The attribute data type that should be used if encountering a new attribute. |
Bulk Assign Events
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:assignment_data=>[{:id=>"player_1", :events=>[{:event_id=>"my_bulk_event", :attributes=>{:my_attribute=>"my_value"}}]}, {:id=>"player_2", :events=>[{:event_id=>"my_bulk_event", :attributes=>{:my_attribute=>"my_value"}}]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}',
payload: {:assignment_data=>[{:id=>"player_1", :events=>[{:event_id=>"my_bulk_event", :attributes=>{:my_attribute=>"my_value"}}]}, {:id=>"player_2", :events=>[{:event_id=>"my_bulk_event", :attributes=>{:my_attribute=>"my_value"}}]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"assignment_data":[{"id":"player_1","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]},{"id":"player_2","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"assignment_data":[{"id":"player_1","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]},{"id":"player_2","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"assignment_data":[{"id":"player_1","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]},{"id":"player_2","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/bulk_assign_events?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"assignment_data":[{"id":"player_1","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]},{"id":"player_2","events":[{"event_id":"my_bulk_event","attributes":{"my_attribute":"my_value"}}]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Enables the assignment of attributes across multiple players.
HTTP Request
POST https://api.userwise.io/api/v2/appusers/bulk_assign_events
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
assignment_data[].id | Yes | string | The player's id |
assignment_data[].events | Yes | any | An array of hashes containing the event id and attributes to assign to the player. |
assignment_data[].events[].event_id | Yes | string | The event id that should be assigned to the player. |
assignment_data[].events[].attributes | No | hash | A hash of attributes to assign to the player. |
Player Segments
Get Player Segments
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/{{ appuser_external_id }}/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [{
"id": "1d06c025-44bd-4a2a-9dd7-baad8ccddaa5",
"name": "XYZ Whale Users",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"attributes": [
{
"operator": "equal",
"name": "_platform",
"values": [
"android",
"ios"
]
},
{
"group_logical_operator": "and",
"operator": "greater_than",
"name": "player_level",
"values": [
50
]
}
],
"events": [
{
"logical_operator": "or",
"event_sets": [
{
"event_id": "played_halloween_event_2020"
},
{
"event_id": "iap_purchased",
"attributes": [
{
"name": "player_ltv",
"operator": "greater_than",
"values": [
120
]
}
]
}
]
},
{
"group_logical_operator": "and",
"logical_operator": "not",
"event_sets": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"event_id": "played_christmas_event_2020"
}
]
}
],
"audience_stats": {
"trailing_30d_active_user_count": 90000,
"trailing_7d_active_user_count": 10000
},
"player_ids_to_exclude": [
"player_id_1",
"player_id_2"
],
"player_ids_to_include": [
"player_id_3",
"player_id_4"
],
"state": "live",
"updated_at": "2024-08-16T19:26:10Z"
}]
}
Retrieves the player's current segments within the specified environment.
HTTP Request
GET https://api.userwise.io/api/v2/appusers/{{ appuser_external_id }}/segments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | The app the player exists within. |
environment_stage | Yes | None | The environment stage to filter the segments by. |
enc | Yes | None | Generated request hash |
Player Revenue Events
Revenue events allows UserWise to provide better analytics regarding one of the most important parts of your game, earning revenue.
Assign Events (w/ Attributes)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:revenue_events=>[{:transaction_id=>"b9e67424-8634-4d54-8fad-0ccc1f36a1f4", :revenue=>3.12, :product_id=>"124", :revenue_type=>"purchase"}, {:transaction_id=>"95ce3d88-bb30-4400-8b7d-e16a58cc810e", :revenue=>-0.34, :product_id=>"222", :revenue_type=>"refunded", :attributes=>[{:name=>"level", :value=>"43"}]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}',
payload: {:revenue_events=>[{:transaction_id=>"b9e67424-8634-4d54-8fad-0ccc1f36a1f4", :revenue=>3.12, :product_id=>"124", :revenue_type=>"purchase"}, {:transaction_id=>"95ce3d88-bb30-4400-8b7d-e16a58cc810e", :revenue=>-0.34, :product_id=>"222", :revenue_type=>"refunded", :attributes=>[{:name=>"level", :value=>"43"}]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"revenue_events":[{"transaction_id":"b9e67424-8634-4d54-8fad-0ccc1f36a1f4","revenue":3.12,"product_id":"124","revenue_type":"purchase"},{"transaction_id":"95ce3d88-bb30-4400-8b7d-e16a58cc810e","revenue":-0.34,"product_id":"222","revenue_type":"refunded","attributes":[{"name":"level","value":"43"}]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"revenue_events":[{"transaction_id":"b9e67424-8634-4d54-8fad-0ccc1f36a1f4","revenue":3.12,"product_id":"124","revenue_type":"purchase"},{"transaction_id":"95ce3d88-bb30-4400-8b7d-e16a58cc810e","revenue":-0.34,"product_id":"222","revenue_type":"refunded","attributes":[{"name":"level","value":"43"}]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"revenue_events":[{"transaction_id":"b9e67424-8634-4d54-8fad-0ccc1f36a1f4","revenue":3.12,"product_id":"124","revenue_type":"purchase"},{"transaction_id":"95ce3d88-bb30-4400-8b7d-e16a58cc810e","revenue":-0.34,"product_id":"222","revenue_type":"refunded","attributes":[{"name":"level","value":"43"}]}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/appuser/{{ appuser_external_id }}/revenue_events?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"revenue_events":[{"transaction_id":"b9e67424-8634-4d54-8fad-0ccc1f36a1f4","revenue":3.12,"product_id":"124","revenue_type":"purchase"},{"transaction_id":"95ce3d88-bb30-4400-8b7d-e16a58cc810e","revenue":-0.34,"product_id":"222","revenue_type":"refunded","attributes":[{"name":"level","value":"43"}]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Assigns the appuser the provided revenue events, along with any accompanying attributes. These attributes are tied uniquely to this event. This will not overwrite any app user attributes.
For a better understanding of how attributes work, see the Assign Attributes section of our documentation.
HTTP Request
POST https://api.userwise.io/api/v1/appuser/{{ appuser_external_id }}/revenue_events
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
revenue_events[].revenue | Yes | float | How much revenue was involved in this revenue event. |
revenue_events[].transaction_id | No | string | Your unique transaction id for this event; should be unique. This field is optional yet if you provide it we'll attempt to update the event if we've seen it before. If you use a single transaction_id for a purchase and then refund you would send in 0 for revenue to reverse it. If you have different transaction_ids you would send in in the refund as a negative number. |
revenue_events[].product_id | No | string | This field is for you have skus you wish to better track in analytics. |
revenue_events[].revenue_type | No | string | Allows you specify a self-defined type of revenue. For instance purchase or refund. |
revenue_events[].attributes[].name | No | string | An attribute name to assign to the app user. |
revenue_events[].attributes[].value | No | any | An attribute value to assign to the app user. |
revenue_events[].attributes[].data_type | No | string | The attribute data type that should be used if encountering a new attribute. |
Push Notifications
Add Device Token
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:device_token=>"1234567890abcdef", :notification_platform=>"apns"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}',
payload: {:device_token=>"1234567890abcdef", :notification_platform=>"apns"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"device_token":"1234567890abcdef","notification_platform":"apns"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"device_token":"1234567890abcdef","notification_platform":"apns"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"device_token":"1234567890abcdef","notification_platform":"apns"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/:external_id/push_notifications/device_tokens/register?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"device_token":"1234567890abcdef","notification_platform":"apns"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Register a device token for push notifications.
HTTP Request
POST https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/register
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
device_token | Yes | string | APNS or FCM device token | |
notification_platform | Yes | string | apns or fcm |
Remove Device Token
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:device_token=>"1234567890abcdef"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}',
payload: {:device_token=>"1234567890abcdef"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"device_token":"1234567890abcdef"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"device_token":"1234567890abcdef"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"device_token":"1234567890abcdef"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"device_token":"1234567890abcdef"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Removes the provided device token from the player.
HTTP Request
POST https://api.userwise.io/api/v2/appusers/:external_id/push_notifications/device_tokens/deregister
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
device_token | Yes | string | APNS or FCM device token |
Get All PN Frameworks
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/push_notifications/frameworks?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "4d02afed-b6de-413b-b0e9-81eb524f05d9",
"name": "My Framework",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
...
]
}
Retrieves an array of all the push notification frameworks, for your app.
HTTP Request
GET https://api.userwise.io/api/v2/push_notifications/frameworks
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Get PN Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "4d02afed-b6de-413b-b0e9-81eb524f05d9",
"name": "My Framework",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
}
}
Retrieves a push notification framework resource.
HTTP Request
GET https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a PN Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/push_notifications/framework?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v2/push_notifications/framework?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/push_notifications/framework?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/push_notifications/framework?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/push_notifications/framework?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/push_notifications/framework?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "4d02afed-b6de-413b-b0e9-81eb524f05d9",
"name": "My Framework",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Creates a new push notification framework record with the provided information.
HTTP Request
POST https://api.userwise.io/api/v2/push_notifications/framework
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the framework | |
schema | Yes | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Update a PN Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My Framework", :schema=>{:type=>"object", :properties=>{:name=>{:type=>"string", :title=>"Valentine's Day Framework", :default=>"Holiday"}}}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/push_notifications/framework/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Framework","schema":{"type":"object","properties":{"name":{"type":"string","title":"Valentine's Day Framework","default":"Holiday"}}}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "4d02afed-b6de-413b-b0e9-81eb524f05d9",
"name": "My Framework",
"state": "active",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Valentine's Day Framework",
"default": "Holiday"
}
}
}
},
}
Updates a push notification framework with the new provided name
or schema
.
HTTP Request
PUT https://api.userwise.io/api/v2/push_notifications/framework/{{ framework_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the framework | |
schema | No | object | A valid JSON Form schema (https://jsonforms.io/ & https://support.userwise.io/hc/en-us/articles/360057842252-JSON-Templating) |
Delete a PN Framework
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2push_notifications/frameworks/{{ framework_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Deletes the push notification framework.
HTTP Request
DELETE https://api.userwise.io/api/v2push_notifications/frameworks/{{ framework_id }}
Segments
Get all Segments
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/segments?app_id={{ app_id }}&environment_stage={{ environment_stage }}&query={{ query }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [{
"id": "1d06c025-44bd-4a2a-9dd7-baad8ccddaa5",
"name": "XYZ Whale Users",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"attributes": [
{
"operator": "equal",
"name": "_platform",
"values": [
"android",
"ios"
]
},
{
"group_logical_operator": "and",
"operator": "greater_than",
"name": "player_level",
"values": [
50
]
}
],
"events": [
{
"logical_operator": "or",
"event_sets": [
{
"event_id": "played_halloween_event_2020"
},
{
"event_id": "iap_purchased",
"attributes": [
{
"name": "player_ltv",
"operator": "greater_than",
"values": [
120
]
}
]
}
]
},
{
"group_logical_operator": "and",
"logical_operator": "not",
"event_sets": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"event_id": "played_christmas_event_2020"
}
]
}
],
"audience_stats": {
"trailing_30d_active_user_count": 90000,
"trailing_7d_active_user_count": 10000
},
"player_ids_to_exclude": [
"player_id_1",
"player_id_2"
],
"player_ids_to_include": [
"player_id_3",
"player_id_4"
],
"state": "live",
"updated_at": "2024-08-16T19:26:10Z"
}]
}
Retrieves all segments in our system. The segment data returned includes name, app_id, targeting data, and various other stats regarding the users that match this segment.
HTTP Request
GET https://api.userwise.io/api/v1/segments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
app_id | Yes | None | The app to filter segments by. |
environment_stage | Yes | None | The environment key to filter the segments by. |
query | No | None | Filter segments by names matching the query string provided. The search is performed as a fuzzy search. |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
page_size | No | None | How many results to return, per page. Default: 10 |
page | No | None | Which page of results should be returned. (1 thru n). Default: 1 |
enc | Yes | None | Generated request hash |
Get a Segment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "1d06c025-44bd-4a2a-9dd7-baad8ccddaa5",
"name": "XYZ Whale Users",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"attributes": [
{
"operator": "equal",
"name": "_platform",
"values": [
"android",
"ios"
]
},
{
"group_logical_operator": "and",
"operator": "greater_than",
"name": "player_level",
"values": [
50
]
}
],
"events": [
{
"logical_operator": "or",
"event_sets": [
{
"event_id": "played_halloween_event_2020"
},
{
"event_id": "iap_purchased",
"attributes": [
{
"name": "player_ltv",
"operator": "greater_than",
"values": [
120
]
}
]
}
]
},
{
"group_logical_operator": "and",
"logical_operator": "not",
"event_sets": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"event_id": "played_christmas_event_2020"
}
]
}
],
"audience_stats": {
"trailing_30d_active_user_count": 90000,
"trailing_7d_active_user_count": 10000
},
"player_ids_to_exclude": [
"player_id_1",
"player_id_2"
],
"player_ids_to_include": [
"player_id_3",
"player_id_4"
],
"state": "live",
"updated_at": "2024-08-16T19:26:10Z"
}
}
Retrieves a single segment resource from our system. The segment data returned includes name, app_id, targeting data, and various other stats regarding the users that match this segment.
HTTP Request
GET https://api.userwise.io/api/v1/segments/{{ segment_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Segment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :environment_stage=>"dev", :name=>"XYZ Whale Users", :events=>[{:logical_operator=>"or", :event_sets=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[120]}]}]}, {:group_logical_operator=>"and", :logical_operator=>"not", :event_sets=>[{:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :event_id=>"played_christmas_event_2020"}]}], :attributes=>[{:operator=>"equal", :name=>"_platform", :values=>["android", "ios"]}, {:group_logical_operator=>"and", :operator=>"greater_than", :name=>"player_level", :values=>[50]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}',
payload: {:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :environment_stage=>"dev", :name=>"XYZ Whale Users", :events=>[{:logical_operator=>"or", :event_sets=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[120]}]}]}, {:group_logical_operator=>"and", :logical_operator=>"not", :event_sets=>[{:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :event_id=>"played_christmas_event_2020"}]}], :attributes=>[{:operator=>"equal", :name=>"_platform", :values=>["android", "ios"]}, {:group_logical_operator=>"and", :operator=>"greater_than", :name=>"player_level", :values=>[50]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","environment_stage":"dev","name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","environment_stage":"dev","name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","environment_stage":"dev","name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/segments?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","environment_stage":"dev","name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"id": "1d06c025-44bd-4a2a-9dd7-baad8ccddaa5",
"name": "XYZ Whale Users",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"attributes": [
{
"operator": "equal",
"name": "_platform",
"values": [
"android",
"ios"
]
},
{
"group_logical_operator": "and",
"operator": "greater_than",
"name": "player_level",
"values": [
50
]
}
],
"events": [
{
"logical_operator": "or",
"event_sets": [
{
"event_id": "played_halloween_event_2020"
},
{
"event_id": "iap_purchased",
"attributes": [
{
"name": "player_ltv",
"operator": "greater_than",
"values": [
120
]
}
]
}
]
},
{
"group_logical_operator": "and",
"logical_operator": "not",
"event_sets": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"event_id": "played_christmas_event_2020"
}
]
}
],
"audience_stats": {
"trailing_30d_active_user_count": 90000,
"trailing_7d_active_user_count": 10000
},
"player_ids_to_exclude": [
"player_id_1",
"player_id_2"
],
"player_ids_to_include": [
"player_id_3",
"player_id_4"
],
"state": "live",
"updated_at": "2024-08-16T19:26:10Z"
},
"meta": {
"warnings": [],
"hints": []
}
}
Creates a new segment with the provided targeting information.
HTTP Request
POST https://api.userwise.io/api/v1/segments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | The app to create the segment in. | |
environment_stage | Yes | string | The environment key that this segment is created in (dev only). | |
name | No | string | The display name for the segment | |
events | No | hash[] | Array of hash maps containing groups of event targeting logic. Checkout the guides section Targeting Events for an in-depth guide on how to properly target based on events and event attributes. | |
attributes | No | hash[] | Array of hash maps containing groups of attribute targeting logic. Checkout the guides section Targeting Attributes for an in-depth guide on how to properly target based on events and event attributes. |
Update a Segment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"XYZ Whale Users", :events=>[{:logical_operator=>"or", :event_sets=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[120]}]}]}, {:group_logical_operator=>"and", :logical_operator=>"not", :event_sets=>[{:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :event_id=>"played_christmas_event_2020"}]}], :attributes=>[{:operator=>"equal", :name=>"_platform", :values=>["android", "ios"]}, {:group_logical_operator=>"and", :operator=>"greater_than", :name=>"player_level", :values=>[50]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}',
payload: {:name=>"XYZ Whale Users", :events=>[{:logical_operator=>"or", :event_sets=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[120]}]}]}, {:group_logical_operator=>"and", :logical_operator=>"not", :event_sets=>[{:app_id=>"ba59bd72-3111-4cbf-83c9-72b3198fa814", :event_id=>"played_christmas_event_2020"}]}], :attributes=>[{:operator=>"equal", :name=>"_platform", :values=>["android", "ios"]}, {:group_logical_operator=>"and", :operator=>"greater_than", :name=>"player_level", :values=>[50]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/segments?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/segments?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"XYZ Whale Users","events":[{"logical_operator":"or","event_sets":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[120]}]}]},{"group_logical_operator":"and","logical_operator":"not","event_sets":[{"app_id":"ba59bd72-3111-4cbf-83c9-72b3198fa814","event_id":"played_christmas_event_2020"}]}],"attributes":[{"operator":"equal","name":"_platform","values":["android","ios"]},{"group_logical_operator":"and","operator":"greater_than","name":"player_level","values":[50]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"id": "1d06c025-44bd-4a2a-9dd7-baad8ccddaa5",
"name": "XYZ Whale Users",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"attributes": [
{
"operator": "equal",
"name": "_platform",
"values": [
"android",
"ios"
]
},
{
"group_logical_operator": "and",
"operator": "greater_than",
"name": "player_level",
"values": [
50
]
}
],
"events": [
{
"logical_operator": "or",
"event_sets": [
{
"event_id": "played_halloween_event_2020"
},
{
"event_id": "iap_purchased",
"attributes": [
{
"name": "player_ltv",
"operator": "greater_than",
"values": [
120
]
}
]
}
]
},
{
"group_logical_operator": "and",
"logical_operator": "not",
"event_sets": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"event_id": "played_christmas_event_2020"
}
]
}
],
"audience_stats": {
"trailing_30d_active_user_count": 90000,
"trailing_7d_active_user_count": 10000
},
"player_ids_to_exclude": [
"player_id_1",
"player_id_2"
],
"player_ids_to_include": [
"player_id_3",
"player_id_4"
],
"state": "live",
"updated_at": "2024-08-16T19:26:10Z"
},
}
Updates an existing segment resource in our system with the provided targeting data.
HTTP Request
PUT https://api.userwise.io/api/v1/segments
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the segment | |
events | No | hash[] | Array of hash maps containing groups of event targeting logic. Checkout the guides section Targeting Events for an in-depth guide on how to properly target based on events and event attributes. | |
attributes | No | hash[] | Array of hash maps containing groups of attribute targeting logic. Checkout the guides section Targeting Attributes for an in-depth guide on how to properly target based on events and event attributes. |
Delete a Segment
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/segments/{{ segment_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{ "data": "Successfully deleted Segment." }
Deletes a segment from the UserWise system.
HTTP Request
DELETE https://api.userwise.io/api/v1/segments/{{ segment_id }}
Survey Results
Aggregated Results
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:events=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[100]}]}], :attributes=>[{:name=>"player_level", :values=>[45], :operator=>"greater_than"}, {:name=>"game_progress", :values=>[80, 100], :operator=>"between"}, {:name=>"raw_inventory_str", :values=>["greatsword_from_beyond", "void_touched_dragon_egg"], :operator=>"equal"}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}',
payload: {:events=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[100]}]}], :attributes=>[{:name=>"player_level", :values=>[45], :operator=>"greater_than"}, {:name=>"game_progress", :values=>[80, 100], :operator=>"between"}, {:name=>"raw_inventory_str", :values=>["greatsword_from_beyond", "void_touched_dragon_egg"], :operator=>"equal"}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/surveys/{{ survey_id }}/questionnaire_results?page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"questions": [
{
"id": "5e6185bdd45bef7776a0036e",
"text": "How did you like our halloween and valentines day events this year?",
"total_unique_answers_count": 3,
"count": 716,
"type": "single_select",
"options": [
{
"text": "I don't remember.",
"count": 350,
"per": 48.88
},
{
"text": "They were okay.",
"count": 220,
"per": 30.73
},
{
"text": "I loved them!",
"count": 146,
"per": 20.39
}
]
},
{
"id": "6ae313bdd45bef8f3020384a",
"text": "Our christmas 2020 event just finished. Did you have any thoughts on how our holiday events could be improved?",
"total_unique_answers_count": 350,
"count": 716,
"type": "open_ended",
"options": [
{
"text": "More free items!",
"count": 157,
"per": 21.93
},
{
"text": "Reward us for your mistakes!",
"count": 119,
"per": 16.62
},
{
"text": "There should be more content",
"count": 98,
"per": 13.69
},
{
"text": "We need holiday specific heros",
"count": 42,
"per": 5.87
},
{
"text": "It was too busy for me.",
"count": 35,
"per": 4.89
}
]
},
{
"id": "6ae313bdd45bef8f3020384a",
"text": "Which of the following are your favorite features of UserWise Hero Wars?",
"total_unique_answers_count": 3,
"count": 716,
"type": "multi_select",
"options": [
{
"text": "Hero Collection",
"count": 359,
"per": 50.14
},
{
"text": "PvP Battle Mode",
"count": 521,
"per": 72.77
},
{
"text": "The Story Progression",
"count": 249,
"per": 34.78
}
]
}
],
"meta": {
"events": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "played_halloween_event_2020",
"count": 716,
"per": 100
},
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "played_christmas_event_2019",
"count": 320,
"per": 44.69
}
],
"attributes": [
{
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"name": "player_level",
"data_type": "integer",
"count": 716,
"per": 100,
"values": [
{
"value": 10,
"count": 100,
"per": 13.96
}
]
}
]
}
},
}
Returns survey results broken out by questions and options.
Question data returned includes id, labels, unique answer counts (which are the unique options available that have answers), count (total question answers), and question type. Options for each question are returned, each containing the answer text, count, and percent of total count for the question.
HTTP Request
POST https://api.userwise.io/api/v1/surveys/{{ survey_id }}/questionnaire_results
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
page | No | 1 | affects open_ended questions only The page number to find results for, used in conjunction with page_size. |
page_size | No | 5 | affects open_ended questions only The number of options to return for the question. Used in conjunction with page to get the proper window of options and their stats. |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
events | No | hash[] | Array of targeting event hashes. Each hash should contain an app_id , and event_id key. An internal event attributes key is optional and targets that event's attributes. |
|
attributes | No | hash[] | Array of targeting attribute hashes. Each hash should contain a name , values , operator and app_id keys. |
Aggregated Question Results
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:events=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[100]}]}], :attributes=>[{:name=>"player_level", :values=>[45], :operator=>"greater_than"}, {:name=>"game_progress", :values=>[80, 100], :operator=>"between"}, {:name=>"raw_inventory_str", :values=>["greatsword_from_beyond", "void_touched_dragon_egg"], :operator=>"equal"}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}',
payload: {:events=>[{:event_id=>"played_halloween_event_2020"}, {:event_id=>"iap_purchased", :attributes=>[{:name=>"player_ltv", :operator=>"greater_than", :values=>[100]}]}], :attributes=>[{:name=>"player_level", :values=>[45], :operator=>"greater_than"}, {:name=>"game_progress", :values=>[80, 100], :operator=>"between"}, {:name=>"raw_inventory_str", :values=>["greatsword_from_beyond", "void_touched_dragon_egg"], :operator=>"equal"}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/surveys/{{ survey_id }}/answer_statistics?question_id={{ question_id }}&page={{ page }}&page_size={{ page_size }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"events":[{"event_id":"played_halloween_event_2020"},{"event_id":"iap_purchased","attributes":[{"name":"player_ltv","operator":"greater_than","values":[100]}]}],"attributes":[{"name":"player_level","values":[45],"operator":"greater_than"},{"name":"game_progress","values":[80,100],"operator":"between"},{"name":"raw_inventory_str","values":["greatsword_from_beyond","void_touched_dragon_egg"],"operator":"equal"}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"text": "More free items!",
"count": 157,
"per": 21.93
},
{
"text": "Reward us for your mistakes!",
"count": 119,
"per": 16.62
},
{
"text": "There should be more content",
"count": 98,
"per": 13.69
},
{
"text": "We need holiday specific heros",
"count": 42,
"per": 5.87
},
{
"text": "It was too busy for me.",
"count": 35,
"per": 4.89
}
]
}
Returns paginated results for the specified survey + question.
This endpoint returns answer specific results that mirror those returned from Aggregated Results. This endpoint is meant to be used in conjunction with the Aggregated Results endpoint, to help you paginate through the answers, or to retrieve any question's answers data only.
HTTP Request
POST https://api.userwise.io/api/v1/surveys/{{ survey_id }}/answer_statistics
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
question_id | Yes | None | The question id to retrieve results for |
page | No | 1 | open_ended questions only The page number to find results for, used in conjunction with page_size. |
page_size | No | 5 | open_ended questions only The number of options to return for the question. Used in conjunction with page to get the proper window of options and their stats. |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
events | No | hash[] | Array of targeting event hashes. Each hash should contain an app_id , and event_id key. An internal event attributes key is optional and targets that event's attributes. |
|
attributes | No | hash[] | Array of targeting attribute hashes. Each hash should contain a name , values , operator and app_id keys. |
Raw Responses
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/surveys/{{ survey_id }}/raw_responses?results_type={{ results_type }}&start_after_response_id={{ start_after_response_id }}&limit={{ limit }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"id": "300ed734-a4af-463c-8b8d-174098364b15",
"state": "success",
"start_at": "2020-03-17T14:33:06+00:00",
"end_at": "2020-03-17T14:34:14+00:00",
"app_id": "ba59bd72-3111-4cbf-83c9-72b3198fa814",
"appuser_id": "17ea08f2-e9b8-48c1-9792-5ad91ccfedaf",
"survey_id": "227e626d-dfa7-4128-bb14-a553cf4cd941",
"appuser_events": [
{
"event_id": "hit_level_80",
"attributes": {
"name": "player_level",
"Value": 80
}
}
],
"appuser_attributes": [
{
"name": "player_level",
"value": 81
}
],
"answers": [
{
"values": [
"Single select answer"
],
"question_id": "24eb49bd-bc38-4591-882e-06d99e212b6c"
},
{
"values": [
"Multi",
"select",
"answers"
],
"question_id": "f87b06c4-4530-42c9-87d3-a8fd62855d38"
},
{
"values": [
"Open ended question answer that can have any response"
],
"question_id": "9c327f6e-6aa6-4f7b-851a-dc94ce935c71"
}
]
},
...
]
}
Returns raw response data for the survey. Each record returned directly corresponds to an app users' completion of your survey.
Information returned here allows your team to work with the raw response and appuser data.
HTTP Request
GET https://api.userwise.io/api/v1/surveys/{{ survey_id }}/raw_responses
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
results_type | No | complete | Define which results you'd like to return. Allowed values:
|
start_after_response_id | No | None | The response id of the last response you have recorded in your system. You can use this to properly select the start position for the request. |
limit | No | 100 | The max number of responses to return in this request. Max allowed is currently set at 10,000. |
enc | Yes | None | Generated request hash |
Templates
Get All Templates
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/templates?query={{ query }}&app_id={{ app_id }}&content_type={{ content_type }}&sort_by={{ sort_by }}&sort_direction={{ sort_direction }}&page_size={{ page_size }}&page={{ page }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": [
{
"app_id": "860e721c-d29d-4213-bc56-fe55f35585c3",
"name": "My Template",
"content_type": "campaign_event",
"data": {
"template_json": {
"name": {
"type": "string",
"title": "Father's Day Framework",
"default": "Holiday"
},
"event_challenge": {
"type": "object",
"title": "Holiday Event",
"properties": {
"amount_required": {
"type": "integer",
"required": true
}
}
}
},
"json": {
"name": "Holiday",
"event_challenge": {
"amount_required": 123
}
},
"external_id": "my-campaign-event-external-identifier"
}
},
...
]
}
Retrieves a list of template resources created.
HTTP Request
GET https://api.userwise.io/api/v1/templates
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
query | No | None | Filter surveys by names matching the query string provided. This is a fuzzy search. |
app_id | Yes | None | Filter surveys by the provided app_id. By default UserWise will return surveys for all of your apps. |
content_type | No | None | offer |
sort_by | No | None | The field to sort by. |
sort_direction | No | None | Direction to order the sorted results by. (asc or desc) |
page_size | No | None | How many results to return, per page. Default: 10 |
page | No | None | Which page of results should be returned. (1 thru n). Default: 1 |
enc | Yes | None | Generated request hash |
Get Template
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"app_id": "860e721c-d29d-4213-bc56-fe55f35585c3",
"name": "My Template",
"content_type": "campaign_event",
"data": {
"template_json": {
"name": {
"type": "string",
"title": "Father's Day Framework",
"default": "Holiday"
},
"event_challenge": {
"type": "object",
"title": "Holiday Event",
"properties": {
"amount_required": {
"type": "integer",
"required": true
}
}
}
},
"json": {
"name": "Holiday",
"event_challenge": {
"amount_required": 123
}
},
"external_id": "my-campaign-event-external-identifier"
}
}
}
Retrieves a template resource.
HTTP Request
GET https://api.userwise.io/api/v1/templates/{{ template_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
Create a Template
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/templates?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:app_id=>"860e721c-d29d-4213-bc56-fe55f35585c3", :name=>"My Template", :content_type=>"campaign_event", :data=>{:template_json=>{:name=>{:type=>"string", :title=>"Father's Day Framework", :default=>"Holiday"}, :event_challenge=>{:type=>"object", :title=>"Holiday Event", :properties=>{:amount_required=>{:type=>"integer", :required=>true}}}}, :json=>{:name=>"Holiday", :event_challenge=>{:amount_required=>123}}, :external_id=>"my-campaign-event-external-identifier"}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/v1/templates?enc={{ generated_request_hash }}',
payload: {:app_id=>"860e721c-d29d-4213-bc56-fe55f35585c3", :name=>"My Template", :content_type=>"campaign_event", :data=>{:template_json=>{:name=>{:type=>"string", :title=>"Father's Day Framework", :default=>"Holiday"}, :event_challenge=>{:type=>"object", :title=>"Holiday Event", :properties=>{:amount_required=>{:type=>"integer", :required=>true}}}}, :json=>{:name=>"Holiday", :event_challenge=>{:amount_required=>123}}, :external_id=>"my-campaign-event-external-identifier"}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/templates?enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"app_id":"860e721c-d29d-4213-bc56-fe55f35585c3","name":"My Template","content_type":"campaign_event","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/templates?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"app_id":"860e721c-d29d-4213-bc56-fe55f35585c3","name":"My Template","content_type":"campaign_event","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/templates?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"app_id":"860e721c-d29d-4213-bc56-fe55f35585c3","name":"My Template","content_type":"campaign_event","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/templates?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"app_id":"860e721c-d29d-4213-bc56-fe55f35585c3","name":"My Template","content_type":"campaign_event","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
{
"data": {
"app_id": "860e721c-d29d-4213-bc56-fe55f35585c3",
"name": "My Template",
"content_type": "campaign_event",
"data": {
"template_json": {
"name": {
"type": "string",
"title": "Father's Day Framework",
"default": "Holiday"
},
"event_challenge": {
"type": "object",
"title": "Holiday Event",
"properties": {
"amount_required": {
"type": "integer",
"required": true
}
}
}
},
"json": {
"name": "Holiday",
"event_challenge": {
"amount_required": 123
}
},
"external_id": "my-campaign-event-external-identifier"
}
},
}
Creates a new template record with the provided information.
HTTP Request
POST https://api.userwise.io/api/v1/templates
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
app_id | Yes | string | The app to create the template in. | |
name | No | string | The display name for the template | |
content_type | Yes | string | One of: campaign_event , email , message , offer , push_notification , remote_config , or survey |
|
data | Yes | object | The template's data. This is a JSON object with keys and values that are specific to the template's content type. |
Update a Template
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:name=>"My Template", :data=>{:template_json=>{:name=>{:type=>"string", :title=>"Father's Day Framework", :default=>"Holiday"}, :event_challenge=>{:type=>"object", :title=>"Holiday Event", :properties=>{:amount_required=>{:type=>"integer", :required=>true}}}}, :json=>{:name=>"Holiday", :event_challenge=>{:amount_required=>123}}, :external_id=>"my-campaign-event-external-identifier"}}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}',
payload: {:name=>"My Template", :data=>{:template_json=>{:name=>{:type=>"string", :title=>"Father's Day Framework", :default=>"Holiday"}, :event_challenge=>{:type=>"object", :title=>"Holiday Event", :properties=>{:amount_required=>{:type=>"integer", :required=>true}}}}, :json=>{:name=>"Holiday", :event_challenge=>{:amount_required=>123}}, :external_id=>"my-campaign-event-external-identifier"}},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"name":"My Template","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"name":"My Template","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"name":"My Template","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"name":"My Template","data":{"template_json":{"name":{"type":"string","title":"Father's Day Framework","default":"Holiday"},"event_challenge":{"type":"object","title":"Holiday Event","properties":{"amount_required":{"type":"integer","required":true}}}},"json":{"name":"Holiday","event_challenge":{"amount_required":123}},"external_id":"my-campaign-event-external-identifier"}};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"data": {
"app_id": "860e721c-d29d-4213-bc56-fe55f35585c3",
"name": "My Template",
"content_type": "campaign_event",
"data": {
"template_json": {
"name": {
"type": "string",
"title": "Father's Day Framework",
"default": "Holiday"
},
"event_challenge": {
"type": "object",
"title": "Holiday Event",
"properties": {
"amount_required": {
"type": "integer",
"required": true
}
}
}
},
"json": {
"name": "Holiday",
"event_challenge": {
"amount_required": 123
}
},
"external_id": "my-campaign-event-external-identifier"
}
},
}
Updates a template with the new provided name
or data
.
HTTP Request
PUT https://api.userwise.io/api/v1/templates/{{ template_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
name | No | string | The display name for the template | |
data | No | object | The template's data. This is a JSON object with keys and values that are specific to the template's content type. |
Delete a Template
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v1/templates/{{ template_id }}?enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{ "data": "Successfully deleted template." }
Deletes the template.
HTTP Request
DELETE https://api.userwise.io/api/v1/templates/{{ template_id }}
Versioning + Releases
Delete a Release
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :delete,
url: 'https://api.userwise.io/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}"
-X DELETE
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.delete(url, headers=headers)
const https = require('https');
const options = {
"method": "DELETE",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/v2/releases/{{ releasable_id }}?environment_stage={{ environment_stage }}&override_only={{ override_only }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP 204 No Content
Deletes all of a releasable's releases within the given environment. If override_only = true
, only override data will be removed.
Override data is applied to a release when a new release is generated. Providing override_only = true
will resync to the latest changes.
HTTP Request
DELETE https://api.userwise.io/api/v2/releases/{{ releasable_id }}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
environment_stage | Yes | None | The environment's key, to which this operation should be performed under. |
override_only | Yes | None | If true, this operation will only remove override data from the release. |
enc | Yes | None | Generated request hash |
Errors & Warnings
Request Hints
If your request is invalid, fails some security check, or another error occurs we will attempt to provide hints
to help you fix the root cause. The hints
can be found within the meta
key at the root of the response JSON.
Example Data: { "meta": { "hints": ["This is an example of a hint."] } }
Request Warnings (Soft Errors)
All API request responses contain a meta
key at the root of the response JSON. Within the meta
key lies a warnings
key which has a value of an array of strings. These strings can be beneficial in debugging why a request was successful, but perhaps not all expectations were met. We recommend alerting your team automatically when any warnings are returned.
Example Data: { "meta": { "warnings": ["This is a warning"] } }
Request Errors
Errors, unlike warnings, mean that a request failed to complete. Errors can be found at the root of the response JSON, under the errors
key. This key is only present if error(s) were hit while we processed your request.
Example Data: { "errors": ["Error message", "Another error message"] }
HTTP Status Codes & Reasons
Error Code | Meaning | Description |
---|---|---|
200 | Ok | Your request was successful. |
201 | Created | Your create request was successful, the resource was created. |
400 | Bad Request | Your request is invalid. Data provided is improperly formatted, or invalid. |
401 | Unauthorized | Your API key is invalid. |
403 | Forbidden | The security request hash provided is invalid, or the request is not in the whitelisted IP addresses. |
404 | Not Found | The specified resource could not be found. |
405 | Method Not Allowed | You tried to access a resource with an invalid HTTP method. |
422 | Unprocessable Entity | Your request was in a valid format, but there was a context or data issue. |
429 | Too Many Requests | Your request was rejected due to too many requests. |
500 | Internal Server Error | We had a problem with our server. Try again later. |
503 | Service Unavailable | We're temporarily offline for maintenance. Please try again later. |
Webhooks
Webhook Endpoints
Webhook endpoints allow you to dynamically define API endpoints that will receive "pushed" data from the UserWise platform. The request data for all webhook events are uniformly defined, therefore a single endpoint can theoretically ingest any (or all) webhook events.
Webhook endpoints are comprised of three primary configurables:
- Webhook endpoint URL
- Hash function, used when generating the signature for the
UserWise-Signature
HTTP header - Any number of subscribable webhook events
Finally, your webhook endpoints can be managed by navigating to your app's webhook settings page.
Webhook Request Anatomy
Example Webhook HTTP Request
POST /userwise_events HTTP/1.1
Host: mygame.mypublisher.com
Content-Type: application/json
Userwise-Signature: 5d0cf6bfeca88e853cd4330cffaaed87febb5038b3c4835681f8f34d8966dc27
User-Agent: userwise-webhooks/1.0
{
"webhook_event_name": "player_session_creation",
"webhook_event_time": "2022-02-23T00:00:00Z",
"webhook_event_app_id": "6ea91937-f588-4622-ba32-1ee4a8354c19",
"webhook_event_payload": {
"appuser_app_external_id": "<your provided player id>",
"appuser_app_sesion_id": "6238d8a2a8b28c0d3a952140",
"appuser_app_session_segment_ids": ["0bc37953-b2d4-4296-a9d4-a3439024a30d", ...]
}
}
As we previously touched on in the Webhook Endpoints section above, all webhook event requests follow a uniformly defined structure. We've outlined the information we provide on every request below:
HTTP Method
All webhook event requests are sent as a HTTP POST
method request.
HTTP Headers
All webhook event requests provide the following HTTP headers:
Content-Type: application/json
Userwise-Signature: <request verification hash>
User-Agent: userwise-webhooks/{version_number}
The Userwise-Signature
HTTP header follows the same hashing as described in Request Hashing (Required). This hash provides you with the means to verify each request to your servers.
Request Body
All webhook event requests will provide a JSON-encoded request body with the following information:
webhook_event_name
- The name of the webhook eventwebhook_event_time
- ISO8601 encoded datetime of the eventwebhook_event_app_id
- The id of the app which is emitting the eventwebhook_event_payload
- Webhook event-specific payload data
Request Retry Mechanism
UserWise webhook event requests that fail to be acknowledged successfully will result in an automatic retry mechanism. Webhook event requests follow pseudo-randomized exponential-backoff retry mechanism, that stops after 6 failed attempts (initial + 5 retry attempts).
The current formula for retrying follows: (retry_count ** 4) + 15 + (rand(30) * (retry_count + 1))
.
- Attempt 1:
0s
backoff - Attempt 2:
18s thru 76s
backoff - Attempt 3:
34s thru 121s
backoff - Attempt 4:
100s thru 216s
backoff - Attempt 5:
276s thru 421s
backoff - Attempt 6:
646s thru 820s
backoff
We will look at the response requirements your endpoint must abide in the next section.
Webhook Event Payloads
As previously noted, the webhoook_event_payload
data is variably dependent upon the webhook_event_name
. To the right you can find more information on the data we provide for each event.
campaign_state_change
{
"campaign_id": "<id of the campaign>",
"campaign_previous_state": "draft|paused|running|completed",
"campaign_current_state": "draft|paused|running|completed"
}
player_session_creation
{
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>",
"appuser_app_session_segment_ids": "<segments of the player at the time of session creation>"
}
player_campaign_trigger
{
"campaign_id": "<id of the campaign>",
"campaign_impression_id": "<id of the impression>",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_message_impression_creation
{
"message_id": "<id of the message>",
"message_impression_id": "<id of the impression>",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_message_impression_state_change
{
"message_id": "<id of the message>",
"message_impression_id": "<id of the impression>",
"message_impression_previous_state": "received|viewed",
"message_impression_current_state": "viewed",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_offer_impression_creation
{
"offer_id": "<id of the offer>",
"offer_impression_id": "<id of the impression>",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_offer_impression_state_change
{
"offer_id": "<id of the offer>",
"offer_impression_id": "<id of the impression>",
"offer_impression_previous_state": "initialized|viewed|dismissed|accepted|purchase_failed|purchased",
"offer_impression_current_state": "viewed|dismissed|accepted|purchase_failed|purchased",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_survey_response_creation
{
"survey_id": "<id of the survey>",
"survey_response_id": "<id of the response>",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_survey_response_state_change
{
"survey_id": "<id of the survey>",
"survey_response_id": "<id of the response>",
"survey_response_current_state": "attempted|survey_invite_presented|survey_invite_denied|survey_invite_accepted|entered|success|term_url_security|abandoned",
"appuser_app_external_id": "<your id for the player>",
"appuser_app_session_id": "<id of the session>"
}
player_journey_entered
{
"journey_id": "<id of the journey>",
"odyssey_id": "<id of the player's odyssey>",
"appuser_app_external_id": "<your id for the player>"
}
player_journey_step_advanced
{
"journey_id": "<id of the journey>",
"odyssey_id": "<id of the player's odyssey>",
"appuser_app_external_id": "<your id for the player>"
}
player_journey_exited
{
"journey_id": "<id of the journey>",
"odyssey_id": "<id of the player's odyssey>",
"odyssey_exit_state": "completed_due_to_exit_node|completed_due_to_segment_entry|completed_due_to_steps_exhausted"
"appuser_app_external_id": "<your id for the player>"
}
push_notification_delivery_override
{
"push_notification_id": "<id of the push notification>",
"environment_id": "<id of the environment>",
"appuser_app_external_ids": ["<your id for the player>"],
"push_notification_title": "<title of the push notification>",
"push_notification_body": "<body of the push notification>",
"push_notification_image_id": "<id of the image for the push notification>",
"push_notification_framework_data": {}
}
Webhook Response Requirements
In order to ensure that duplicate requests are not sent, your system MUST properly acknowledge all requests.
HTTP Status Code
Webhook endpoints MUST always return a valid 200-ranged success response.
Player/Session API
Player/Session API Introduction
While the original purpose of the v1 SDK API was to provide access to help power the UserWise SDK, we have now opened these API endpoints to public access.
The endpoints described below will aid in managing a custom integration with the UserWise platform; for the client, server, or both.
Player Sessions
Start a Session
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}?')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:session_id=>"64ada9c805378b000942ccde", :language=>"en", :country=>"us", :timezone=>"America/New_York", :environment_stage=>"live"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}?',
payload: {:session_id=>"64ada9c805378b000942ccde", :language=>"en", :country=>"us", :timezone=>"America/New_York", :environment_stage=>"live"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}?"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}?",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}?"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}?",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"session_id":"64ada9c805378b000942ccde","language":"en","country":"us","timezone":"America/New_York","environment_stage":"live"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"was_initialized": true,
"survey_refresh_interval_seconds": 60,
"session_id": "64ada9c805378b000942ccde"
}
Starts a new player session.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
session_id | No | string | The session to restart. If not provided, a new session will be created. | |
language | No | string | ISO 639-1 language codes | |
country | No | string | ISO 3166-1 country codes | |
timezone | No | string | Timezone name | |
environment_stage | Yes | string | qa |
Get Session Data
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}?",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"id": "64ada9c805378b000942ccde",
"segment_ids": [
"17732bc4-dc6a-42ce-95a7-adaffcfa3708",
"5a8d333c-bd49-4456-a683-39462dbcfa70",
"1ae1b6c0-bbc3-497d-b499-44ad3963bb7c",
"c79c5ef4-326f-44d2-8cd8-17b8b6d98eef"
],
"logged_in_on": "2023-07-11T19:13:12+00:00",
"environment_id": "10565c88-6a2e-4ea7-b9fb-026f09701529",
"environment_key": "live",
"environment_type": "live",
"region_transitions": [],
"attributes": [
{
"name": "_language",
"value": "en"
}
]
}
Retrieve data related to the session.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}
Refresh Session Segments
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments?",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"session_id": "6239e850a8b28cc82e711b46"
}
Forcefully reprocess the segments for the provided session.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/sessions/{{ session_id }}/refresh_segments
Session Player Attributes
Assign Attributes
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:attributes=>[{:name=>"player_level", :value=>120}, {:name=>"is_whale", :value=>true, :data_type=>"boolean"}], :session_id=>"64ada9c805378b000942ccde"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}',
payload: {:attributes=>[{:name=>"player_level", :value=>120}, {:name=>"is_whale", :value=>true, :data_type=>"boolean"}], :session_id=>"64ada9c805378b000942ccde"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"attributes":[{"name":"player_level","value":120},{"name":"is_whale","value":true,"data_type":"boolean"}],"session_id":"64ada9c805378b000942ccde"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Assigns the appuser the provided attribute names and value pairs. This operation acts as an upsert for attributes for the app user.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/attributes
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
attributes[].name | Yes | string | The attribute name to assign to the app user. |
attributes[].value | Yes | any | The attribute value to assign to the app user. |
attributes[].data_type | No | string | The attribute data type that should be used if encountering a new attribute. |
Session Player Events
Assign Events (w/ Attributes)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:events=>[{:event_id=>"achievement_level_20"}, {:event_id=>"act_one_completed", :attributes=>[{:name=>"act_one_completed_on", :value=>"2020-02-01T00:00:00Z"}]}]}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}',
payload: {:events=>[{:event_id=>"achievement_level_20"}, {:event_id=>"act_one_completed", :attributes=>[{:name=>"act_one_completed_on", :value=>"2020-02-01T00:00:00Z"}]}]},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ appuser_external_id }}/events?session_id={{ session_id }}&enc={{ generated_request_hash }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"events":[{"event_id":"achievement_level_20"},{"event_id":"act_one_completed","attributes":[{"name":"act_one_completed_on","value":"2020-02-01T00:00:00Z"}]}]};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Assigns the appuser the provided event ids, along with any accompanying attributes. These attributes are tied uniquely to this event. This will not overwrite any app user attributes.
For a better understanding of how attributes work, see the Assign Attributes section of our documentation.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ appuser_external_id }}/events
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
enc | Yes | None | Generated request hash |
JSON Request Body Fields
Field | Required | Type | Description |
---|---|---|---|
events[].event_id | Yes | string | The event id that should be assigned to the app user. |
events[].attributes[].name | No | string | An attribute name to assign to the app user. |
events[].attributes[].value | No | any | An attribute value to assign to the app user. |
events[].attributes[].data_type | No | string | The attribute data type that should be used if encountering a new attribute. |
Triggered Campaigns
Get Running Triggered Campaigns
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"campaigns": [
{
"id": "9b1ad4b0-019a-458d-b040-175c95eef555",
"name": "Campaign Name",
"events": [],
"messages": [],
"offers": [],
"surveys": [],
"remote_configs": [],
"trigger": {
"type": "attribute_trigger",
"logic": {
"attribute_name": "coins",
"operator": "equal",
"values": [100],
"data_type": "integer"
}
},
"campaign_impression_id": "0485ad4d-f091-4c91-8681-f41833fa0dfe"
}
]
}
Retrieves running triggerable campaigns that the player has available.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/triggerable_campaigns
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Scheduled Campaigns
Get Events (Active/Upcoming)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/campaign_events?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"active": [
{
"id": "93bb9138-1084-4132-853e-15a94c843850",
"name": "Campaign Event's Internal Name",
"start_at": "2022-03-14T01:00:00+00:00",
"start_at_tz": "utc",
"end_at": "2022-03-30T01:00:00+00:00",
"end_at_tz": "utc",
"campaign_event_template_id": "23816faa-52e9-4add-817c-9b7c07a9cb0f",
"campaign_event_framework_id": "146c1f9b-8d2a-452b-861b-97b8d5d323f0",
"external_id": "my_event_external_id",
"external_event_type": "my_event_type",
"data": {}
}
],
"upcoming": [ ... ]
}
Retrieves active and upcoming campaign events
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/campaign_events
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Get Offers (Active/Upcoming)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/offers?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"active": [
{
"id": "c2f02223-07d5-4914-97c7-8a4acbf11faa",
"name": "Offer's Internal Name",
"start_at": "2022-03-14T01:00:00+00:00",
"start_at_tz": "utc",
"end_at": "2022-03-30T01:00:00+00:00",
"end_at_tz": "utc",
"title": "My Localized Title",
"body": "My Localized Body",
"portrait_image_id": "3d97829f-971e-4b14-b700-9c3732d6766c",
"landscape_image_id": "a3ac39bf-f059-4436-a9bf-a31412efbd08",
"currencies": {},
"items": {},
"payment_data": {
"payment_type": "iap",
"iap_data": {
"ios_product_id": "my-app-store-product-id",
"android_product_id": "my-play-store-product-id",
"cost": 1.99
}
}
}
],
"upcoming": [ ... ]
}
Retrieves active and upcoming scheduled offers.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offers
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Get Messages (Active/Upcoming)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/messages?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"active": [
{
"id": "4f93eb31-48c1-4297-b2e7-6dcfb769d52a",
"name": "Message's Internal Name",
"start_at": "2022-03-14T01:00:00+00:00",
"start_at_tz": "utc",
"end_at": "2022-03-30T01:00:00+00:00",
"end_at_tz": "utc",
"title": "My Localized Message Title",
"body": "My Localized Message Body",
"portrait_image_id": "d58bc31f-b60f-4f03-be97-a112733a99f7",
"landscape_image_id": "9492f92f-251e-49cd-81f0-b112f9964d01",
"message_type": "default",
"additional_fields": {}
}
],
"upcoming": [ ... ]
}
Retrieves active and upcoming scheduled messages.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/messages
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Get JSON Uploads (Active/Upcoming)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/remote_configs?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"active": [
{
"id": "e2ea9ee7-0432-4dcd-bf96-9259e7741fa8",
"name": "Remote Config's Internal Name",
"start_at": "2022-03-14T01:00:00+00:00",
"start_at_tz": "utc",
"end_at": "2022-03-30T01:00:00+00:00",
"end_at_tz": "utc",
"external_id": "<identifier of the in-game event - your id>",
"json": { }
}
],
"upcoming": [ ... ]
}
Retrieves active and upcoming scheduled remote configurations.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/remote_configs
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Get Surveys (Active/Upcoming)
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/get_surveys?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"active": [
{
"id": "8488155f-38c5-4316-9eee-1371ad27567d",
"name": "Survey's Internal Name",
"start_at": "2022-03-14T01:00:00+00:00",
"start_at_tz": "utc",
"end_at": "2022-03-30T01:00:00+00:00",
"end_at_tz": "utc",
"questions_count": 1
}
],
"upcoming": [ ... ]
}
Retrieves active and upcoming scheduled surveys.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/get_surveys
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
Surveys Entry
Survey Response ID
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:survey_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}',
payload: {:survey_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"survey_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"survey_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"survey_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"survey_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"survey_response_id": "4947c38e-b4c8-4abe-b56e-2fd5c33b5729"
}
Retrieves the survey response id for the player-survey.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
survey_id | Yes | ID of the survey |
Survey Entry URL Generation
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:survey_response_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}',
payload: {:survey_response_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"survey_response_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"survey_response_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"survey_response_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"survey_response_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"survey_url": "https://app.userwise.io/take_survey/18819879-9f8b-46c9-81ff-2b2fc98accf5?lang=en&enc=..."
}
Retrieves the survey response id for the player-survey.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/surveys/get_response_id
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
survey_response_id | Yes | ID of the survey response record |
Offer Impressions
Initialize Offer Impression
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:offer_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}',
payload: {:offer_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"offer_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"offer_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"offer_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"offer_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"offer_impression": {
"id": "884fe7ef-64f0-4bce-bfcf-aada4318c503",
"state": "intialized",
"offer": {
"id": "bec464f6-f36f-4000-b879-6b6c16880d58"
}
}
}
Initialize an offer impression record
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/initialize
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
offer_id | Yes | ID of the offer |
Update Offer Impression State
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:offer_impression_id=>"", :state=>"viewed"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}',
payload: {:offer_impression_id=>"", :state=>"viewed"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"offer_impression_id":"","state":"viewed"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"offer_impression_id":"","state":"viewed"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"offer_impression_id":"","state":"viewed"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"offer_impression_id":"","state":"viewed"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{
"message": "Successfully updated offer impresion's state"
}
Updates an offer impression record's state
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/offer_impressions/update_state
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
offer_impression_id | Yes | ID of the offer impression | ||
state | Yes | viewed |
Message Impressions
Initialize Message Impression
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:message_id=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}',
payload: {:message_id=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"message_id":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"message_id":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"message_id":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"message_id":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{}
Initialize an message impression record
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/initialize
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
message_id | Yes | ID of the message |
Update Message Impression State
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:message_id=>"", :state=>""}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}',
payload: {:message_id=>"", :state=>""},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"message_id":"","state":""}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"message_id":"","state":""}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"message_id":"","state":""}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"message_id":"","state":""};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
{}
Updates an message impression record's state
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/message_impressions/update_state
Query Params
Parameter | Required | Default | Description |
---|---|---|---|
session_id | Yes | None | Player's Session ID |
JSON Body
Field | Required | Type | Default | Description |
---|---|---|---|---|
message_id | Yes | ID of the message | ||
state | Yes | Must be 'viewed' at this time |
Push Notifications
Receiving a Push Notification
Push Notifications are sent to your app via a supported push service. The push service will send a notification to your app, where you must implement receiving notifications through a native integration (like for APNs), or through a library (e.g. Firebase for GCM/FCM, or even APNs).
The notification payload will be accompanied by the following UserWise contextual data:
origin
->userwise
image_id
-> image attached to the push notification (if any)push_notification_id
-> the push notification idimpression_id
-> the player's notification impression id
Register a Device Token
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:notification_platform=>"apns", :device_token=>"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}',
payload: {:notification_platform=>"apns", :device_token=>"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"notification_platform":"apns","device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"notification_platform":"apns","device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"notification_platform":"apns","device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"notification_platform":"apns","device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 201 Created
Registers the provided push server (notification_platform) & device token for the player.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/register
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
notification_platform | Yes | string | The notification platform (apns or fcm) | |
device_token | Yes | string | The device token |
Unregister a Device Token
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:device_token=>"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :post,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}',
payload: {:device_token=>"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}"
-X POST
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"}
requests.post(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "POST",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"device_token":"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 204 No Content
Removes the provided device token from the player's registered device tokens.
HTTP Request
POST https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/device_tokens/deregister
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
device_token | Yes | string | The device token |
Get Push Notification Data
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 Ok
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Dashboard-side Push Notification Name",
"title": "Push Notification Title",
"body": "Push Notification Body",
"image_id": "123e4567-e89b-12d3-a456-426614174000",
"framework_data": {}
}
Retrieves the provided push notification's data.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/{{ push_notification_id }}
Get Impression Data
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri)
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :get,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}',
payload: {},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}"
-X GET
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
requests.get(url, headers=headers)
const https = require('https');
const options = {
"method": "GET",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 Ok
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"device_token": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"start_at": "2022-01-01T00:00:00.000Z",
"state": "sent",
"push_notification_id": "123e4567-e89b-12d3-a456-426614174000"
}
Retrieves the provided push notification impression's data.
HTTP Request
GET https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}
Update Impression State
Request:
# Using net/http
require 'net/http'
require 'json'
require 'base64'
uri = URI('https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Put.new(uri, initheader: {'Content-Type' => 'application/json'})
request['X-Api-Key'] = Base64.encode64('{{ your_app_api_key }}')
request.body = {:state=>"delivered | viewed"}.to_json
http.request(request)
# Using the 'rest-client' gem
require 'rest-client'
require 'base64'
RestClient::Request.execute(
method: :put,
url: 'https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}',
payload: {:state=>"delivered | viewed"},
content_type: 'application/json',
headers: {
'X-Api-Key': Base64.encode64('{{ your_app_api_key }}')
}
)
curl "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}"
-X PUT
-H "X-Api-Key: {{ your_app_api_key_base64_encoded }}"
-H "Content-Type: application/json"
--data '{"state":"delivered | viewed"}'
<?php
/** Using cURL **/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-Api-Key: ' . base64_encode('{{ your_app_api_key }}')
),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => '{"state":"delivered | viewed"}'
));
$response = curl_exec($curl);
curl_close($curl);
import requests
url = "https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}"
headers = {
"Content-Type": "application/json",
"X-Api-Key": base64.b64encode("{{ your_app_api_key }}")
}
body = {"state":"delivered | viewed"}
requests.put(url, headers=headers, data=body)
const https = require('https');
const options = {
"method": "PUT",
"hostname": "api.userwise.io",
"port": 443,
"path": "/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}?session_id={{ session_id }}",
"headers": {
"Content-Type": "application/json",
"X-Api-Key": Buffer.from("{{ your_app_api_key }}").toString('base64')
}
};
const json = {"state":"delivered | viewed"};
const params = JSON.stringify(json);
const request = https.request(options, (response) => {
let chunks = [];
response.on("data", (chunk) => {
chunks.push(chunk);
});
});
request.write(params);
request.end();
Successful Response:
HTTP Status 200 OK
Updates the provided push notification impression's state.
HTTP Request
PUT https://api.userwise.io/api/sdk/v1/appusers/{{ player_id }}/push_notifications/impressions/{{ impression_id }}
JSON Request Body Fields
Field | Required | Type | Default | Description |
---|---|---|---|---|
state | Yes | string | The new state of the impression ('delivered' |
Unity SDK
Getting Started
Installing the SDK
The installation guide for the Unity SDK is kept up to date, and can be found within the example app's README.
Using the SDK
Getting An Instance
Use of the UserWise SDK should be done through the provided singleton instance, which can be accessed through theUserWise.INSTANCE
property.
How To Integrate The UserWise Flow
We've attempted to make integrating with the UserWise platform as easy as possible. The flow is generally very event-driven and dependent on the UserWise SDK's underlying logic.
To start, you must initialize the UserWise SDK with an API Key, and a unique user-identifying id for the player. See the Unity Init Methods section for each initialization method we provide.
Once you've successfully initialized the player, you should make a call to the Start
method.
From here the UserWise SDK will initialize the player's session and collect various non-identifying bits of information for you to use for player targeting.
UserWise
Methods
Initialize With API & User ID
public void Initialize(String apiKey, String externalAppUserId);
Initializes the SDK with an api key and an player id. Both values MUST be set either through the use of this init method, or the individual init methods described below.
Set Debug Mode
DebugMode = true;
Sets the debug mode, enabling/disabling verbose logging.
Start/Resume SDK
public void Start();
Starts or resumes the UserWise SDK.
Stop/Pause SDK
public void Stop();
Pauses the UserWise SDK.
Session Initialized?
public Boolean IsSessionInitialized();
Returns a boolean indicating if the SDK is attached to a session.
Refresh Content
public void RefreshContent();
Pings the UserWise servers to refresh a player's session segments, as well as retrieve up-to-date content.
Assign Event (w/ optional attributes)
public void AssignEvent(PlayerEvent playerEvent, Action<bool> callback);
Appends the event to the player's events, storing any provided attributes along with it. Events are repeatable and can contain unique attributes. Attributes should be provided in a key=>value manner, using a JSONObject
.
Set Attributes
public void SetAttributes(List<PlayerAttribute> attributes, Action<bool> callback);
Updates the player's attributes, setting any provided attribute values. Attributes should be provided in a key=>value manner, using a JSONObject
.
Transition Region
public void TransitionToRegion(Region region, Action<bool> callback);
Updates the player's session to include the region transition definition provided (e.g. Main Menu -> Store
transition).
EventsModule
Events
OnLoaded
public event EventHandler
Emitted when events have been loaded from the UserWise API.
OnActive
public event EventHandler
Emitted for an active event. All active events are emitted after load has completed.
OnInactive
public event EventHandler
Emitted for an active event.
MessagesModule
Events
OnLoaded
public event EventHandler
Emitted when messages have been loaded from the UserWise API.
OnActive
public event EventHandler
Emitted for an active message.
OnInactive
public event EventHandler
Emitted for an inactive message.
OffersModule
Events
OnLoaded
public event EventHandler
Emitted when offers have been loaded from the UserWise API.
OnActive
public event EventHandler
Emitted for an available offer, when triggered to do so. Usually afer load, or manually through EmitNextActive()
or accessing ActiveOffers
directly.
OnInactive
public event EventHandler
Emitted when an offer becomes unavailable.
OnOfferImpressionInitializationFailed
public event EventHandler
Emitted when an offer impression initialization attempt has failed.
OnOfferImpressionInitialized
public event EventHandler
Emitted on offer impression initialization attempt was successful.
RemoteConfigsModule
Events
OnLoaded
public event EventHandler
Emitted when remote configurations have been loaded from the UserWise API.
OnActive
public event EventHandler
Emitted for an active remote configuration.
OnInactive
public event EventHandler
Emitted for an inactive remote configuration.
SurveysModule
Events
OnLoaded
public event EventHandler
Emitted when surveys have been loaded from the UserWise SDK.
OnActive
public event EventHandler
Emitted when a survey has become available.
OnInactive
public event EventHandler
Emitted when a survey has become unavailable.
OnSurveyInviteInitialized
public event EventHandler
Emitted when an invite has been successfully initialized, or if an error occurred.
OnSurveyEntered
public event EventHandler
Emitted when the survey is starting to be entered. OnSurveyEnterFailed
can still be emitted while the survey finishes loading.
OnSurveyClosed
public event EventHandler
Emitted when the UserWise SDK view is closing. This does not necessarily indicate that the survey was not completed, just that control is being returned to your app.
OnSurveyCompleted
public event EventHandler
Emitted when the app user has successfully completed a survey provided to them.
OnSurveyEnterFailed
public event EventHandler
Emitted when the UserWise SDK has encountered one of various potential reasons for a survey entrance failure. This, along with OnSurveyClosed
should be used as indicators of control being returned to your app.
PushNotificationsModule
Enabling a Push Service
Prior to sending a notification for a supported push service (APNs & FCM, currently), you must navigate to the https://app.userwise.io/app_settings/frameworks/push_notifications page and provide valid credentials for the service you wish to use.
Client-Side Integration
The reworked UserWise Push Notifications module now does not manage the actual receiving of push notifications, but instead just facilitates a means of delivery. This means that you can use any push notification library or integration you'd like, as long as it supports the push service you are planning to use (e.g. APNs or FCM).
The notification payload will be accompanied by the following UserWise contextual data:
origin
->userwise
image_id
-> image attached to the push notification (if any)push_notification_id
-> the push notification idimpression_id
-> the player's notification impression id
You can use the data to perform any actions you'd like, including retrieving the image and custom framework data attached to your push notification.