API Reference

Developers Guide

Endpoints, parameters and response codes for the Benten platform. Building with .NET? The Benten SDK handles all of this for you.

Using .NET? Install the Benten SDK with dotnet add package Benten.SDK. It handles tokens, WebSocket connections and response parsing for every request below. Use this page if you're integrating from another language or want to see the protocol the SDK uses.

Get an Access Token (JWT)

Exchange your API key for a JSON Web Token (JWT). Every other request on this page needs this token. Create API keys on the developer dashboard: sign in, choose Create API key and copy the key (it starts with bnt_sk_). Keep API keys on your server; never put them in a mobile app or web page.

The token expires after one hour. Get a new one before it expires; the Benten SDK does this for you. A revoked API key can't be exchanged for new tokens, so it stops working within an hour.

Request

POSThttps://api.bententechnologies.com/v2/auth/token
Parameter
ParametersTypeDescription
ApiKeyStringYour API key (bnt_sk_…)
TimeoutintOptional. Token lifetime in seconds, between 60 and 3600. Default 3600 (one hour).
Request Example
{
  "ApiKey": "bnt_sk_Q2x1ZGUtaXMtYS1nb29kLWtleS1nZW5lcmF0b3I"
}
Responses
HTTP Status CodeBenten Status CodeDescription
400BSC4075API key is required.
401BSC4076API key is invalid or has been revoked.
401BSC4032This account is no longer active. Please contact Benten support to reactivate account.
401BSC4048Application User missing critical security key. Please contact Benten support.
500N/AInternal Server Error
200N/ASuccess - token returned
Response Example
{
 "Token":"eyJhbGciOiJodHRwOi8vd3d3LnczLm6yZy8yMDAx.....I1NiIsInR5cCI6IkpXVCJ9.eyJo
dHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOlsiQmVudGVuRGV2ZWxvcGV
yIiwiVGVzdFJvbGUiXS.....zLCJpc3MiOiJiZW50ZW50ZWNobm9sb2dpZXMuY29tIiwiYXVkIjoiZGV2ZWxvcGVycyJ
9.8PTxmrjowOjWaFYIpik...VfwVRJxqrrkUsjo",
 "ExpiresIn": 3600
}

Register Online Account

API to register User’s online account with Benten. This request requires a valid JWT. Once the account has been created successfully, Benten will inform the client’s device of the newly created account.

Request

POSThttps://api.bententechnologies.com/v2/clients/onlineaccount/create
Headers
HeaderValue
AuthorizationBearer {JWT TOKEN}
Parameter
ParametersTypeDescription
FirstNameStringUser's First Name
LastNameStringUser's Last Name
UserNameStringUsername
DescriptionStringAny text
DevicePhoneNumberStringUser's Phone Number registered with Benten
DeviceCountryStringUser's Country associated with the Phone Number
Request Example
{
   "FirstName": “Alfie”,
   "LastName": "Noakes",
   "Username": "alfie.noakes@benten.com", 
   "Description": "Personal email",
   "DevicePhoneNumber": "6501111111",
   “DeviceCountry”: ”United States”
}
Responses
HTTP Status CodeBenten Status CodeDescription
400N/ARequired parameter(s) missing
400BSC4052Bearer Token Missing!
404BSC4049Invalid Token - Missing Client id
400BSC4019Invalid Token
404BSC4020No registered user found for given Client Id
401BSC4021Client Account Inactive. Please contact Benten support
404BSC4022No registered device found for given phone number
400BSC4023Account already exists for given phone number
400BSC4024Failed to create Online Account for given username and merchant site
500N/AInternal Server Error
200N/ASuccess - Online Account saved successfully
Response Example
{
  "Response": “Success”
}

Register Credit Card Info

API to register user’s credit card info with Benten. This request requires a valid JWT. Once the credit card info has been created successfully, Benten server will inform the client’s device of the newly created Credit Card info. A credit card can only be configured against one single phone number. Credit card number is salted and hashed before it is saved in the database.

Request

POSThttps://api.bententechnologies.com/v2/clients/creditcard/create
Headers
HeaderValue
AuthorizationBearer {JWT token}
Parameter
ParametersTypeDescription
FirstNameStringUser's First Name
LastNameStringUser's Last Name
CardNumberStringCC Number
ZipCodeStringZip Code associated with CC
DescriptionStringAny text
DevicePhoneNumberStringUser’s Phone Number registered with Benten
DeviceCountryStringUser’s Country associated with the phone number
Request Example
{
    "FirstName": "Alfie",
    "LastName": "Noakes",
    "CardNumber": "1111222233334445", 
    "ZipCode": "12345", 
    "Description": "Personal Visa Card",
    "DevicePhoneNumber": "6501111111",
    “DeviceCountry”: “United States”
}
Responses
HTTP Status CodeBenten Status CodeDescription
400N/ARequired parameter(s) missing
400BSC4051Credit Card specified is not supported. Please contact Benten support
400BSC4052Bearer Token Missing!
400BSC4049Invalid Token - Missing Client id
400BSC4019Invalid Token
404BSC4020No registered user found for given Client Id
401BSC4021Client Account Inactive. Please contact Benten support.
400BSC4026Card Number/Zipcode already exists!
404BSC4022No registered device found for the given country and phone number.
400BSC4027Failed to create CC for the given Card Number and Zipcode
500N/AInternal Server Error
200N/ASuccess - CC Info saved successfully
Response Example
{
  "Response": “Success”
}

Register IoT Device Info

API to register User’s IoT device with Benten. This request requires a valid JWT. Once the IoT has been created successfully, Benten server will inform the client’s device of the newly created IoT device.

Request

POSThttps://api.bententechnologies.com/v2/clients/iot/create
Headers
HeaderValue
AuthorizationBearer {JWT TOKEN}
Parameter
ParametersTypeDescription
NameStringName to identify the IoT device
MacAddressStringMAC address of the IoT device
DescriptionStringAny text
DevicePhoneNumberStringUser’s Phone Number registered with Benten
DeviceCountryStringUser’s Country associated with the phone number
Request Example
{
  "Name": “LRT”,
  "MacAddress": "97-E6-F8-66-BE-75",
  "Description": "Living Room Thermostat",
  "DevicePhoneNumber": "6501111111",
  “DeviceCountry”: ”United States”
}
Responses
HTTP Status CodeBenten Status CodeDescription
400N/ARequired parameter(s) missing
400BSC4052Bearer Token Missing!
400BSC4049Invalid Token - Missing Client id
400BSC4019Invalid Token
404BSC4020No registered user found for given Client Id
401BSC4021Client Account Inactive. Please contact Benten support.
404BSC4022No registered device found for the given country and phone number.
400BSC4029IoT Device already associated with the given country and phone number!
400BSC4030Failed to create IoT for Name/MacAddress
500N/AInternal Server Error
200N/ASuccess - IoT Device saved successfully
Response Example
{
  "Response": “Success”
}

Get Registered Online Accounts

API to get a list of registered usernames associated with a given country and phone number. User can select one of the registered username to login.

Request

POSThttps://api.bententechnologies.com/v2/clients/onlineaccount/info
Headers
HeaderValue
AuthorizationBearer {JWT TOKEN}
Parameter
ParametersTypeDescription
PhoneNumberStringPhone number associated with the device
CountryStringCountry associated with the phone number
Request Example
{
  "PhoneNumber" : "6501111111", 
  "Country" : “United States”
}
Responses
HTTP Status CodeBenten Status CodeDescription
400N/ARequired parameter(s) missing
400BSC4052Bearer Token Missing!
400BSC4049Invalid Token - Missing Client Id
400BSC4019Invalid token
404BSC4020No registered user found for given Client Id
401BSC4021Client Account Inactive. Please contact Benten support
404BSC4022No registered device found for the given country and phone number
500N/AInternal Server Error
200N/ASuccess - Returns a list of usernames
Response Example
{
  "Usernames": ["user2@yahoo.com","alfie.noakes@benten.com"]
}

Login Request

API to allow user to log into their online account using a phone number and a username. This request requires a valid JWT. Benten server will send a message to BentenApp on the user’s associated iOS/Android device requesting permission to continue with the login process. The response will either be Allow or Deny.

Request

Websocketwss://api.bententechnologies.com/v2/clients/loginrequest/phonenumber/

After the Socket Open request is received, server will wait for 10 seconds to receive from Client the following json message:

Parameters
ElementValue
RequestTypeLoginRequest
JWTJWT Token
CountryCountry name associated with the phone number
PhoneNumberPhone number of the device to be used to process login request
RequestIdOptional value. Unique ID for this request, e.g. a new GUID. Use a fresh value for every request and never reuse one. Server will assign one, if this value is not provided
UserNameOptional value. Username of the online account to which access is being requested

Request IDs: send a new RequestId (for example a new GUID) with every request. The server uses it to route the user's answer back to your connection, so a fixed or reused value can mix up replies between requests. The Benten SDK does this for you.

LoginRequest Without Username
{
   "RequestType": "LoginRequest",
   "JWT”: “eyJhbGciOiJ …. VfwVRJxqrrkUsjo”,
   “Country”: “United States”,
   “PhoneNumber”: ”6501111111”
}
LoginRequest With Username
{
   "RequestType": "LoginRequest",
   "JWT”: “eyJhbGciOiJ …. VfwVRJxqrrkUsjo”,
   “Country”: “United States”,
   “PhoneNumber”: ”6501111111”,
   “Username”: “alfie.noakes@benten.com” 
}

Server will forward this login request to the registered device for the given phone number. Once server receives user’s response of either Allow or Deny, the server will send the response back the client. If the user does not respond within 60 seconds, the server will send NoResponse string back to the Client.

Response Parameters

ElementValue
_id / RequestIdYour request's RequestId, echoed back: as _id in Allow/Deny responses, as RequestId in NoResponse and error responses
PhoneNumberPhone number of the device responding
CountryCountry of the phone number
ResponseAllow/Deny/NoResponse/BentenStatusCode/Error Text
RequestTypeValue will be same as in request JSON. Available only for error response.
UsernameValue will be same as in request JSON. Available only for error response.
Response Example (Notification from server to client)
{
   "RequestId": "5bdd322d-688d-4261-b47d-c6e5f9f3b907",
   "Country": "United States",
   "PhoneNumber": "6501111111",
   "Response": "NoResponse"
}

Please NOTE: Any response other than Allow/Deny/NoResponse should be considered as error response. It is client’s responsibility to handle such errors accordingly. Besides the response above, Client may receive the following error response, depending on the situation. Response will contain the actual error message or a Benten error status code, where available. For example:

Response Example (Error)
{
   "RequestId": "8e8ec2e3-afb5-4b25-b118-e6134e687830",
   "Username": "alfie.naokes@benten.com",
   "Country": "United States",
   "PhoneNumber": "6501111111",
   "RequestType": "LoginRequest",
   "Response": "BSC4019"
}

Please NOTE: The Username is optional value for the request. The error response will contain the actual username to which the request was forwarded.

Following error messages can be sent by the server to the Client on the Websocket:

Message received is not a WebSocket request
BSC4049 - Invalid Token - Missing Client Id
BSC4019 - Invalid Token
One or more required field/s is missing!
BSC4020 - No registered user found for given Client Id
BSC4021 - Client Account Inactive. Please contact Benten support
BSC4022 - No registered device found for the given country and phone number
BSC4056 - Device associated with the given country and phone number is not active. Please activate your Device first
BSC4057 - No login account associated with the client found for device with the given country and phone number
BSC4058 - Client not authorized to request Login permission for device associated with the given country and phone number
BSC4059 - System currently unavailable. Please contact Benten support if this error persists
BSC4073 - Invalid request. The request message could not be read
BSC4074 - Request message is too large

Get Registered Credit Cards

API to get a list of registered credit cards for a given phone number. User can use one of these registered credit cards during checkout.

Request

POSThttps://api.bententechnologies.com/v2/clients/creditcard/info
Headers
HeaderValue
AuthorizationBearer {JWT token}
Parameter
ParametersTypeDescription
PhoneNumberStringPhone number associated with the device
CountryStringCountry associated with the device
Request Example
{    
  "PhoneNumber" : "6501111111", 
  "Country" : “United States”
}
Responses
HTTP Status CodeBenten Status CodeDescription
400N/ARequired parameter/s missing
400BSC4052Bearer Token Missing!
400BSC4049Invalid Token - Missing Client Id
400BSC4019Invalid Token
404BSC4020No registered user found for given Client Id
401BSC4021Client Account Inactive. Please contact Benten support
404BSC4022No registered device found for the given country and phone number
500N/AInternal Server Error
200N/ASuccess - Returned Credit Card info
Response Example
{
    "CreditCards": [
        {
            "Number": "Ending in 0001",
            "CreditCardId": "600bd697a1428c5c2a512383"
        },
        {
            "Number": "Ending in 0002",
            "CreditCardId": "600bd6a2a1428c5c2a512386"
        }
    ]
}

Credit Card Transaction Approval

API to allow user to either approve or reject a credit card transaction. This request requires a valid JWT. Benten will send a message to BentenApp on the user’s associated iOS/Android device requesting permission to continue with the credit card transaction. The response will either be Allow or Deny.

Request

WebSocketwss://api.bententechnologies.com/v2/clients/creditcard/transaction

After the Socket Open request is received, server will wait for 10 seconds to receive from Client the following json message:

Parameters
ElementValue
JWTJWT token
CreditCardIdBenten Id of the associated Credit Card
AmountTransaction Amount
RetailerRetailer associated with this transaction
RequestIdOptional value. Unique ID for this request, e.g. a new GUID. Use a fresh value for every request and never reuse one. Server will assign one, if this value is not provided
Request Example (Credit Card Transaction)
{
   "RequestId": "3f2b8c1e-9d4a-4e7b-a1c5-6b0f2d8e7a91",
   "RequestType": "CCTransaction",
   “JWT”: “eyJhbGciOiJ …. VfwVRJxqrrkUsjo”,
   “CreditCardId”: “xyz”,
   “Amount”: “$777.99”,
   “Retailer”: “www.homedepot.com”
}

Server will forward this Credit Card transaction request to the registered device for this credit card. Once server receives user’s response of either Allow or Deny, the server will send the response back the client.

Response Parameters

ElementValue
_id / RequestIdYour request's RequestId, echoed back: as _id in Allow/Deny responses, as RequestId in NoResponse and error responses
PhoneNumberPhone number of the device responding. Available only for non-error response.
CountryCountry of the phone number. Available only for non-error response.
ResponseAllow/Deny/NoResponse/BentenStatusCode/Error Text
RequestTypeValue will be same as in request JSON. Available only for error response.
CreditCardIdValue will be same as in request JSON. Available only for error response.
AmountValue will be same as in request JSON. Available only for error response.
RetailerValue will be same as in request JSON. Available only for error response.
Response Example (Notification from server to client)
{
   "_id": "1aa78b2b-4652-492c-b5f4-847e1904c508",
   "Response": "Allow",
   "PhoneNumber": "6501111111",
   "Country": "United States"
}

Please NOTE: Any response other than Allow/Deny/NoResponse should be considered as error response. It is client’s responsibility to handle such errors accordingly. Besides the response above, Client may receive the following error response, depending on the situation. Response will contain the actual error message. For example:

Response Example (Error)
{
   "RequestId": "1aa51a00-1aa6-4a79-9d67-6a798de716d4",
   "CreditCardId": "6118b36af32980fc86a7929e",
   "Amount": "$649.99",
   "Retailer": "www.homedepot.com",
   "RequestType": "CCTransaction",
   "Response": "BSC4021"
}

Following error messages can be sent by the server to the Client:

Message received is not a WebSocket request
BSC4049 - Invalid Token - Missing Client id
BSC4019 - Invalid Token
One or more required field/s is missing!
BSC4020 - No registered user found for given Client Id
BSC4021 - Client Account Inactive. Please contact Benten support
BSC4060 - Invalid Benten Credit Card Id
BSC4061 - Unauthorized Credit Card transaction request!
BSC4056 - Device associated with the given country and phone number is not active. Please activate your Device first
BSC4059 - System currently unavailable. Please contact Benten support if this error persists
BSC4073 - Invalid request. The request message could not be read
BSC4074 - Request message is too large

IoT Setting Change Request

API to allow user to either approve or reject an IoT Setting change transaction. This request requires a valid JWT. Benten will send a message to BentenApp on the user’s associated iOS/Android devices requesting permission to continue with the IoT Setting change transaction. User can respond using any one of his or her registered devices. The response will either be Allow or Deny.

Request

WebSocketwss://api.bententechnologies.com/v2/clients/iotsetting/update/

After the Socket Open request is received, server will wait for 10 seconds to receive from Client the following json message:

Parameters
ElementValue
RequestTypeIoTSettingChange
JWTJWT token
NameName of the IoT device
MacAddressMac Address of the IoT device
SettingChangeSetting change that needs to be applied to the Iot Device
RequestIdOptional value. Unique ID for this request, e.g. a new GUID. Use a fresh value for every request and never reuse one. Server will assign one, if this value is not provided
Request Example (IoT Change Temp request)
{
   "RequestType": "IoTSettingChange",
   “JWT”: “eyJhbGciOiJ …. VfwVRJxqrrkUsjo”,
   “Name”: “Living Room Thermostat”,
   “MacAddress”: “12345”,
   “SettingChange”: “Change default temp from 72 to 68?”
}

Server will forward this IoT Setting change request to the registered devices for this IoT device. Once server receives user’s response of either Allow or Deny, the server will send the response back the client. 

Response Parameters

ElementValue
_id / RequestIdYour request's RequestId, echoed back: as _id in Allow/Deny responses, as RequestId in NoResponse and error responses
PhoneNumberPhone number of the device responding. Available only for non-error response
CountryCountry of the phone number. Available only for non-error response
ResponseAllow/Deny/NoResponse/BentenStatusCode/Error Text
RequestTypeValue will be same as in request JSON. Available only for error response.
NameValue will be same as in request JSON. Available only for error response.
MacAddressValue will be same as in request JSON. Available only for error response.
SettingChangeValue will be same as in request JSON. Available only for error response.
Response Example (Notification from server to client)
{
   "_id": "552b6c85-71de-468e-b5b0-4b5497688d75",
   “PhoneNumber”: “6501111111”,
   “Country”: “United States”,
   “Response”: “Allow”
}

Please NOTE: Any response other than Allow/Deny/NoResponse should be considered as error response. It is client’s responsibility to handle such errors accordingly. Besides the response above, Client may receive the following error response, depending on the situation. Response will contain the actual error message. For example:

Response Example (Error)
{
   "RequestId": "552b6c85-71de-468e-b5b0-4b5497688d75",
   "Name": "LRT",
   "MacAddress": "AA-AA-AA-AA-AA-07",
   "RequestType": "IoTSettingChange",
   "SettingChange": "Change temp from 72 to 68",
   "Response": "BSC4019"
}

Following error messages can be sent by the server to the Client:

Message received is not a WebSocket request!
BSC4049 - Invalid Token - Missing Client id
BSC4019 - Invalid Token
One or more required field/s is missing!
BSC4020 - No registered user found for given Client Id
BSC4021 - Client Account Inactive. Please contact Benten support
BSC4062 - No IoT device found for the given Name and MacAddress
BSC4063 - Unauthorized IoT Setting Change request!
BSC4064 - No devices configured for the given IoT device
BSC4059 - System currently unavailable. Please contact Benten support if this error persists
BSC4073 - Invalid request. The request message could not be read
BSC4074 - Request message is too large

Generic Notification

API to allow user to either approve or reject a Generic Notification request. This request requires a valid JWT. Benten will send a message to the user’s associated iOS/Android device requesting user to respond. The response will either be Allow or Deny.

The user only needs the Benten App installed and activated on their phone; they don’t need an account registered with you first. To protect users from floods of prompts, one developer account can send at most 30 generic notifications to the same phone in any 10 minutes. More are refused with BSC4079.

Request

WebSocketwss://api.bententechnologies.com/v2/clients/generic/notification/

After the Socket Open request is received, server will wait for 10 seconds to receive from Client the following json message:

Parameters
ElementValue
JWTJWT Token
RequestTypeGenericNotification
NotificationSubTypeTitle to be displayed for the notification
CountryCountry associated with the Device Phone Number
PhoneNumberPhone number associated with the Device where the notification is to be delivered
Line1PlaceholderText to be used as a placeholder for Line1
Line1Any text that should be displayed on the first line of the Notification
Line2PlaceholderText to be used as a placeholder for Line2
Line2Any text that should be displayed on the second line of the Notification
Line3PlaceholderText to be used as a placeholder for Line3
Line3Any text that should be displayed on the third line of the Notification
RequestIdOptional value. Unique ID for this request, e.g. a new GUID. Use a fresh value for every request and never reuse one. Server will assign one, if this value is not provided
Request Example
{
   "jwt":"xxxxx", 
   "RequestType": "Generic Request", 
   "Country": "United States",
   "PhoneNumber": "6501111111",
   "NotificationSubType":"Medical Data Req",
   "Line1Placeholder": "Doctor",
   "Line1":"Bilbo Baggins",
   "Line2Placeholder": "Patient",
   "Line2":"Alfie Noakes",
   "Line3Placeholder": "Desc",
   "Line3":"Request to review Test data"
}

Server will forward this Generic Notification request to the device for given country and phone number. Once server receives user’s response of either Allow or Deny, the server will send the response back the client.

Response Parameters

ElementValue
_id / RequestIdYour request's RequestId, echoed back: as _id in Allow/Deny responses, as RequestId in NoResponse and error responses
CountryCountry of the phone number.
PhoneNumberPhone number of the device responding.
ResponseAllow/Deny/NoResponse/BentenStatusCode/Error Text
RequestTypeValue will be same as in request JSON. Available only for error response.
NotificationSubTypeValue will be same as in request JSON. Available only for error response.
Line1Value will be same as in request JSON. Available only for error response.
Line2Value will be same as in request JSON. Available only for error response.
Line3Value will be same as in request JSON. Available only for error response.
Response Example (Notification from server to client)
{
   “_id”: “552b6c85-71de-468e-b5b0-4b5497688d75”,
   “Country”: “United States”,
   “PhoneNumber”: “6501111111”,
   “Response”: “Allow”
}

Please NOTE: Any response other than Allow or Deny should be considered as error response. It is client’s responsibility to handle such errors accordingly. Besides the response above, Client may receive the following error response, depending on the situation. Response will contain the actual error message or Benten status code, if available. For example:

Response Example (Error)
{
   “RequestId”: “552b6c85-71de-468e-b5b0-4b5497688d75”,
   “RequestType”: “GenericNotification”,
   “NotificationSubType”: “Medical Data Request”,
   “Country”: “United States”,
   “PhoneNumber”: “6501111111”,
   "Line1Placeholder": "Doctor",
   “Line1”: “Alfie Noakes”,
   "Line2Placeholder": "Patient",
   “Line2”: “Bilbo Baggins”,
   "Line3Placeholder": "Desc",
   “Line3”: “Review latest test results”
   “Response”: “BSC4019”
}

Following error messages can be sent by the server to the Client:

Message received is not a WebSocket request!
BSC4049 - Invalid Token – Missing Client Id
BSC4019 - Invalid Token
One or more fields is a required field
BSC4020 - No registered user found for given Client Id
BSC4021 - Client Account Inactive. Please contact Benten support
BSC4022 - No registered device found for the given country and phone number.
BSC4056 - Device associated with the given country and phone number is not active. Please activate your Device first.
BSC4079 - Too many notifications sent to this phone. Try again in a few minutes.
BSC4059 - System currently unavailable. Please contact Benten support if this error persists
BSC4073 - Invalid request. The request message could not be read
BSC4074 - Request message is too large