Create a token to initialize the Benji Connect SDK
curl --request POST \
--url https://api-staging.withbenji.com/auth/connect \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"partnership_id": "<string>",
"mode": 123,
"display_name": "<string>",
"user_external_id": "<string>",
"custom_attributes": {
"actions": [
{
"mode": 123,
"amount": 123,
"allows_editing": true
}
]
}
}
'import requests
url = "https://api-staging.withbenji.com/auth/connect"
payload = {
"partnership_id": "<string>",
"mode": 123,
"display_name": "<string>",
"user_external_id": "<string>",
"custom_attributes": { "actions": [
{
"mode": 123,
"amount": 123,
"allows_editing": True
}
] }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
partnership_id: '<string>',
mode: 123,
display_name: '<string>',
user_external_id: '<string>',
custom_attributes: {actions: [{mode: 123, amount: 123, allows_editing: true}]}
})
};
fetch('https://api-staging.withbenji.com/auth/connect', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-staging.withbenji.com/auth/connect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'partnership_id' => '<string>',
'mode' => 123,
'display_name' => '<string>',
'user_external_id' => '<string>',
'custom_attributes' => [
'actions' => [
[
'mode' => 123,
'amount' => 123,
'allows_editing' => true
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-staging.withbenji.com/auth/connect"
payload := strings.NewReader("{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-staging.withbenji.com/auth/connect")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.withbenji.com/auth/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"token": "0c371a1c-aa81-11ef-b28c-0a58a9feac02",
"connect_url": "https://connect.withbenji.com/khkgfoud76td"
}
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Getting Started
Create a token to initialize the Benji Connect SDK
Create a token to initialize an instance of the Benji Connect SDK or Benji Hosted Connect.
POST
/
auth
/
connect
Create a token to initialize the Benji Connect SDK
curl --request POST \
--url https://api-staging.withbenji.com/auth/connect \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"partnership_id": "<string>",
"mode": 123,
"display_name": "<string>",
"user_external_id": "<string>",
"custom_attributes": {
"actions": [
{
"mode": 123,
"amount": 123,
"allows_editing": true
}
]
}
}
'import requests
url = "https://api-staging.withbenji.com/auth/connect"
payload = {
"partnership_id": "<string>",
"mode": 123,
"display_name": "<string>",
"user_external_id": "<string>",
"custom_attributes": { "actions": [
{
"mode": 123,
"amount": 123,
"allows_editing": True
}
] }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
partnership_id: '<string>',
mode: 123,
display_name: '<string>',
user_external_id: '<string>',
custom_attributes: {actions: [{mode: 123, amount: 123, allows_editing: true}]}
})
};
fetch('https://api-staging.withbenji.com/auth/connect', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-staging.withbenji.com/auth/connect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'partnership_id' => '<string>',
'mode' => 123,
'display_name' => '<string>',
'user_external_id' => '<string>',
'custom_attributes' => [
'actions' => [
[
'mode' => 123,
'amount' => 123,
'allows_editing' => true
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-staging.withbenji.com/auth/connect"
payload := strings.NewReader("{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-staging.withbenji.com/auth/connect")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.withbenji.com/auth/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"partnership_id\": \"<string>\",\n \"mode\": 123,\n \"display_name\": \"<string>\",\n \"user_external_id\": \"<string>\",\n \"custom_attributes\": {\n \"actions\": [\n {\n \"mode\": 123,\n \"amount\": 123,\n \"allows_editing\": true\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"token": "0c371a1c-aa81-11ef-b28c-0a58a9feac02",
"connect_url": "https://connect.withbenji.com/khkgfoud76td"
}
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
The
x-api-key header value to be used on this API is your partner API
key, which can be generated through the Developer page
in Pilot.The Connect Token API resolves merchant and partner from
partnership_id.Request body
string
required
The unique identifier of the partnership on the Benji Platform.
number
required
The connection mode for the SDK (Connect = 1, Transfer = 3, and Redeem = 4).
See Connect modes.
string
Display name shown in the Connect UI. If omitted, the name configured for the
partnership on the platform is used.
string
A unique identifier for the user in your system. When set, the flow can skip
the authentication step for your user.
object
Example requests
Minimal request (Connect mode)
Minimal request (Connect mode)
{
"partnership_id": 49,
"mode": 1,
"display_name": "Reward Cookies"
}
With user_external_id
With user_external_id
{
"partnership_id": 49,
"mode": 1,
"display_name": "Reward Cookies",
"user_external_id": "user-1234"
}
Transfer mode (mode 3) with custom_attributes
Transfer mode (mode 3) with custom_attributes
{
"partnership_id": 49,
"mode": 3,
"display_name": "Reward Cookies",
"custom_attributes": {
"actions": [
{
"mode": 3,
"amount": 1000,
"allows_editing": true
}
]
}
}
Redeem mode (mode 4)
Redeem mode (mode 4)
{
"partnership_id": 49,
"mode": 4,
"display_name": "Reward Cookies"
}
Return values
string
required
The connect token to pass when initializing the Benji Connect
SDK or as
connect_token on the Benji Hosted
Connect URL.string
Base URL for Benji Hosted Connect for this partnership. Append
?connect_token=<token> (and optional query parameters) to send users into Benji Hosted Connect. May be empty if Benji Hosted Connect URLs are not enabled for your account.{
"code": "ok",
"data": {
"token": "0c371a1c-aa81-11ef-b28c-0a58a9feac02",
"connect_url": "https://connect.withbenji.com/khkgfoud76td"
}
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Was this page helpful?
⌘I