curl --request POST \
--url https://{host}/bonus/v1/accounts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"externalId": "ACC-100234",
"isActive": true,
"isAllowedToSpend": true,
"accountType": "Default"
}
'import requests
url = "https://{host}/bonus/v1/accounts"
payload = {
"externalId": "ACC-100234",
"isActive": True,
"isAllowedToSpend": True,
"accountType": "Default"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
externalId: 'ACC-100234',
isActive: true,
isAllowedToSpend: true,
accountType: 'Default'
})
};
fetch('https://{host}/bonus/v1/accounts', 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://{host}/bonus/v1/accounts",
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([
'externalId' => 'ACC-100234',
'isActive' => true,
'isAllowedToSpend' => true,
'accountType' => 'Default'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://{host}/bonus/v1/accounts"
payload := strings.NewReader("{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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://{host}/bonus/v1/accounts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v1/accounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}"
response = http.request(request)
puts response.read_body{
"accountId": 48213
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Create an account
Your backend calls this to open a bonus account that is identified by an id of your own, the externalId, and
that no customer is linked to yet. To open the account of one customer, call
POST /v1/members/{memberId}/accounts instead.
The account gets the account type named in accountType; leave it out where your environment has a single
account type. Keep the accountId from the response: the calls that link customers to the account, update it
and add bonus to it take that id, and reading the account by externalId does not return it.
The call is not idempotent. A second call with the same externalId is refused with AccountAlreadyExists, so
after a failure read the account with GET /v1/accounts/{externalId} before trying again.
curl --request POST \
--url https://{host}/bonus/v1/accounts \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"externalId": "ACC-100234",
"isActive": true,
"isAllowedToSpend": true,
"accountType": "Default"
}
'import requests
url = "https://{host}/bonus/v1/accounts"
payload = {
"externalId": "ACC-100234",
"isActive": True,
"isAllowedToSpend": True,
"accountType": "Default"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
externalId: 'ACC-100234',
isActive: true,
isAllowedToSpend: true,
accountType: 'Default'
})
};
fetch('https://{host}/bonus/v1/accounts', 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://{host}/bonus/v1/accounts",
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([
'externalId' => 'ACC-100234',
'isActive' => true,
'isAllowedToSpend' => true,
'accountType' => 'Default'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://{host}/bonus/v1/accounts"
payload := strings.NewReader("{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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://{host}/bonus/v1/accounts")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/bonus/v1/accounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"externalId\": \"ACC-100234\",\n \"isActive\": true,\n \"isAllowedToSpend\": true,\n \"accountType\": \"Default\"\n}"
response = http.request(request)
puts response.read_body{
"accountId": 48213
}{
"name": "<string>",
"message": "<string>",
"details": null
}{
"name": "<string>",
"message": "<string>",
"details": null
}Authorizations
Body
The account to create.
An account to create under an id of your own.