curl --request POST \
--url https://api.salesbricks.com/api/v2/subscriptions \
--header 'Content-Type: application/json' \
--header 'X-SALESBRICKS-KEY: <api-key>' \
--data '
{
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": false
}
]
}
],
"point_of_contact_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signatory_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"discount_coupons": [
"<string>"
],
"phases": [
{
"phase_position": 1,
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": false
}
]
}
],
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_terms": 499,
"discount_coupons": [
"<string>"
]
}
],
"auto_renews": true,
"accounts_payable_emails": [
"jsmith@example.com"
],
"payment_terms": 499,
"renewal_contract_period": 2,
"renewal_uplifted_rate": "<string>",
"metadata": "<unknown>",
"custom_order_form_html": "<string>",
"accepted_payment_methods_config": {
"paywall_credit_card": true,
"paywall_check": true,
"paywall_ach": true,
"paywall_wire": true,
"checkout_credit_card": true,
"checkout_ach": true,
"checkout_order_form": true,
"minimum_order_form_tcv": 0,
"paywall_force_autopay": false
},
"legal_entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.salesbricks.com/api/v2/subscriptions"
payload = {
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": False
}
]
}
],
"point_of_contact_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signatory_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"discount_coupons": ["<string>"],
"phases": [
{
"phase_position": 1,
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": False
}
]
}
],
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_terms": 499,
"discount_coupons": ["<string>"]
}
],
"auto_renews": True,
"accounts_payable_emails": ["jsmith@example.com"],
"payment_terms": 499,
"renewal_contract_period": 2,
"renewal_uplifted_rate": "<string>",
"metadata": "<unknown>",
"custom_order_form_html": "<string>",
"accepted_payment_methods_config": {
"paywall_credit_card": True,
"paywall_check": True,
"paywall_ach": True,
"paywall_wire": True,
"checkout_credit_card": True,
"checkout_ach": True,
"checkout_order_form": True,
"minimum_order_form_tcv": 0,
"paywall_force_autopay": False
},
"legal_entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"X-SALESBRICKS-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SALESBRICKS-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
starts_at: '2023-12-25',
contract_length: 2,
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
bricks: [
{
brick_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
quantity: 123,
discount: [{rate: '<string>', amount: 123, renews: false}]
}
],
point_of_contact_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
signatory_user_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
currency: 'USD',
discount_coupons: ['<string>'],
phases: [
{
phase_position: 1,
bricks: [
{
brick_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
quantity: 123,
discount: [{rate: '<string>', amount: 123, renews: false}]
}
],
starts_at: '2023-12-25',
contract_length: 2,
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
payment_terms: 499,
discount_coupons: ['<string>']
}
],
auto_renews: true,
accounts_payable_emails: ['jsmith@example.com'],
payment_terms: 499,
renewal_contract_period: 2,
renewal_uplifted_rate: '<string>',
metadata: '<unknown>',
custom_order_form_html: '<string>',
accepted_payment_methods_config: {
paywall_credit_card: true,
paywall_check: true,
paywall_ach: true,
paywall_wire: true,
checkout_credit_card: true,
checkout_ach: true,
checkout_order_form: true,
minimum_order_form_tcv: 0,
paywall_force_autopay: false
},
legal_entity_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.salesbricks.com/api/v2/subscriptions', 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.salesbricks.com/api/v2/subscriptions",
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([
'starts_at' => '2023-12-25',
'contract_length' => 2,
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'bricks' => [
[
'brick_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 123,
'discount' => [
[
'rate' => '<string>',
'amount' => 123,
'renews' => false
]
]
]
],
'point_of_contact_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'signatory_user_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'currency' => 'USD',
'discount_coupons' => [
'<string>'
],
'phases' => [
[
'phase_position' => 1,
'bricks' => [
[
'brick_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 123,
'discount' => [
[
'rate' => '<string>',
'amount' => 123,
'renews' => false
]
]
]
],
'starts_at' => '2023-12-25',
'contract_length' => 2,
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'payment_terms' => 499,
'discount_coupons' => [
'<string>'
]
]
],
'auto_renews' => true,
'accounts_payable_emails' => [
'jsmith@example.com'
],
'payment_terms' => 499,
'renewal_contract_period' => 2,
'renewal_uplifted_rate' => '<string>',
'metadata' => '<unknown>',
'custom_order_form_html' => '<string>',
'accepted_payment_methods_config' => [
'paywall_credit_card' => true,
'paywall_check' => true,
'paywall_ach' => true,
'paywall_wire' => true,
'checkout_credit_card' => true,
'checkout_ach' => true,
'checkout_order_form' => true,
'minimum_order_form_tcv' => 0,
'paywall_force_autopay' => false
],
'legal_entity_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SALESBRICKS-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.salesbricks.com/api/v2/subscriptions"
payload := strings.NewReader("{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SALESBRICKS-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.salesbricks.com/api/v2/subscriptions")
.header("X-SALESBRICKS-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesbricks.com/api/v2/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SALESBRICKS-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "ERR_BAD_REQUEST",
"message": "Bad request — the input payload is malformed, missing required fields, or contains invalid data."
}
}{
"error": {
"code": "ERR_NOT_FOUND",
"message": "Not found — the resource you are looking for does not exist."
}
}Create a subscription
Creates a new subscription for a customer.
curl --request POST \
--url https://api.salesbricks.com/api/v2/subscriptions \
--header 'Content-Type: application/json' \
--header 'X-SALESBRICKS-KEY: <api-key>' \
--data '
{
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": false
}
]
}
],
"point_of_contact_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signatory_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"discount_coupons": [
"<string>"
],
"phases": [
{
"phase_position": 1,
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": false
}
]
}
],
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_terms": 499,
"discount_coupons": [
"<string>"
]
}
],
"auto_renews": true,
"accounts_payable_emails": [
"jsmith@example.com"
],
"payment_terms": 499,
"renewal_contract_period": 2,
"renewal_uplifted_rate": "<string>",
"metadata": "<unknown>",
"custom_order_form_html": "<string>",
"accepted_payment_methods_config": {
"paywall_credit_card": true,
"paywall_check": true,
"paywall_ach": true,
"paywall_wire": true,
"checkout_credit_card": true,
"checkout_ach": true,
"checkout_order_form": true,
"minimum_order_form_tcv": 0,
"paywall_force_autopay": false
},
"legal_entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.salesbricks.com/api/v2/subscriptions"
payload = {
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": False
}
]
}
],
"point_of_contact_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signatory_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"currency": "USD",
"discount_coupons": ["<string>"],
"phases": [
{
"phase_position": 1,
"bricks": [
{
"brick_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 123,
"discount": [
{
"rate": "<string>",
"amount": 123,
"renews": False
}
]
}
],
"starts_at": "2023-12-25",
"contract_length": 2,
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_terms": 499,
"discount_coupons": ["<string>"]
}
],
"auto_renews": True,
"accounts_payable_emails": ["jsmith@example.com"],
"payment_terms": 499,
"renewal_contract_period": 2,
"renewal_uplifted_rate": "<string>",
"metadata": "<unknown>",
"custom_order_form_html": "<string>",
"accepted_payment_methods_config": {
"paywall_credit_card": True,
"paywall_check": True,
"paywall_ach": True,
"paywall_wire": True,
"checkout_credit_card": True,
"checkout_ach": True,
"checkout_order_form": True,
"minimum_order_form_tcv": 0,
"paywall_force_autopay": False
},
"legal_entity_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"X-SALESBRICKS-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SALESBRICKS-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
starts_at: '2023-12-25',
contract_length: 2,
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
bricks: [
{
brick_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
quantity: 123,
discount: [{rate: '<string>', amount: 123, renews: false}]
}
],
point_of_contact_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
signatory_user_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
currency: 'USD',
discount_coupons: ['<string>'],
phases: [
{
phase_position: 1,
bricks: [
{
brick_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
quantity: 123,
discount: [{rate: '<string>', amount: 123, renews: false}]
}
],
starts_at: '2023-12-25',
contract_length: 2,
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
payment_terms: 499,
discount_coupons: ['<string>']
}
],
auto_renews: true,
accounts_payable_emails: ['jsmith@example.com'],
payment_terms: 499,
renewal_contract_period: 2,
renewal_uplifted_rate: '<string>',
metadata: '<unknown>',
custom_order_form_html: '<string>',
accepted_payment_methods_config: {
paywall_credit_card: true,
paywall_check: true,
paywall_ach: true,
paywall_wire: true,
checkout_credit_card: true,
checkout_ach: true,
checkout_order_form: true,
minimum_order_form_tcv: 0,
paywall_force_autopay: false
},
legal_entity_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.salesbricks.com/api/v2/subscriptions', 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.salesbricks.com/api/v2/subscriptions",
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([
'starts_at' => '2023-12-25',
'contract_length' => 2,
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'bricks' => [
[
'brick_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 123,
'discount' => [
[
'rate' => '<string>',
'amount' => 123,
'renews' => false
]
]
]
],
'point_of_contact_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'signatory_user_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'currency' => 'USD',
'discount_coupons' => [
'<string>'
],
'phases' => [
[
'phase_position' => 1,
'bricks' => [
[
'brick_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 123,
'discount' => [
[
'rate' => '<string>',
'amount' => 123,
'renews' => false
]
]
]
],
'starts_at' => '2023-12-25',
'contract_length' => 2,
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'payment_terms' => 499,
'discount_coupons' => [
'<string>'
]
]
],
'auto_renews' => true,
'accounts_payable_emails' => [
'jsmith@example.com'
],
'payment_terms' => 499,
'renewal_contract_period' => 2,
'renewal_uplifted_rate' => '<string>',
'metadata' => '<unknown>',
'custom_order_form_html' => '<string>',
'accepted_payment_methods_config' => [
'paywall_credit_card' => true,
'paywall_check' => true,
'paywall_ach' => true,
'paywall_wire' => true,
'checkout_credit_card' => true,
'checkout_ach' => true,
'checkout_order_form' => true,
'minimum_order_form_tcv' => 0,
'paywall_force_autopay' => false
],
'legal_entity_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SALESBRICKS-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.salesbricks.com/api/v2/subscriptions"
payload := strings.NewReader("{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SALESBRICKS-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.salesbricks.com/api/v2/subscriptions")
.header("X-SALESBRICKS-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesbricks.com/api/v2/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SALESBRICKS-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"point_of_contact_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"signatory_user_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"currency\": \"USD\",\n \"discount_coupons\": [\n \"<string>\"\n ],\n \"phases\": [\n {\n \"phase_position\": 1,\n \"bricks\": [\n {\n \"brick_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 123,\n \"discount\": [\n {\n \"rate\": \"<string>\",\n \"amount\": 123,\n \"renews\": false\n }\n ]\n }\n ],\n \"starts_at\": \"2023-12-25\",\n \"contract_length\": 2,\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_terms\": 499,\n \"discount_coupons\": [\n \"<string>\"\n ]\n }\n ],\n \"auto_renews\": true,\n \"accounts_payable_emails\": [\n \"jsmith@example.com\"\n ],\n \"payment_terms\": 499,\n \"renewal_contract_period\": 2,\n \"renewal_uplifted_rate\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"custom_order_form_html\": \"<string>\",\n \"accepted_payment_methods_config\": {\n \"paywall_credit_card\": true,\n \"paywall_check\": true,\n \"paywall_ach\": true,\n \"paywall_wire\": true,\n \"checkout_credit_card\": true,\n \"checkout_ach\": true,\n \"checkout_order_form\": true,\n \"minimum_order_form_tcv\": 0,\n \"paywall_force_autopay\": false\n },\n \"legal_entity_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "ERR_BAD_REQUEST",
"message": "Bad request — the input payload is malformed, missing required fields, or contains invalid data."
}
}{
"error": {
"code": "ERR_NOT_FOUND",
"message": "Not found — the resource you are looking for does not exist."
}
}Authorizations
API key for authentication
Body
- SubscriptionInputSinglePhase
- SubscriptionInputMultiPhasePerPhasePlans
- SubscriptionInputMultiPhase
Subscription update input serializer that comes from previously posted subscription estimate.
This payload has two forms — see anyOf:
- Single-phase — omit
phases; the order-levelstarts_at,contract_length,billing_frequencyandbricksdefine the one phase and are required. - Multi-phase — send
phases; the phases own the timeline, billing frequency and bricks, and the order-level equivalents become optional (omitted, they are derived from the phases).
The fields are declared optional because OpenAPI 3.0 cannot make one field's required depend on another. Sending neither form is a 400.
Every phase needs a plan, so the multi-phase form splits in two: send an order-level plan_id (the plan for any phase that names none), or give every phase its own plan_id. A multi-phase payload naming no plan at all is a 400.
The start date of the subscription. Required unless phases is provided, in which case phase 0's start date is used.
The length of the contract in months. Required unless phases is provided, in which case it is the sum of the phase lengths.
x >= 1The billing frequency. Required unless phases is provided, in which case each phase declares its own billing_frequency.
MONTHLY- MonthlyQUARTERLY- QuarterlySEMI_ANNUALLY- Semi-annuallyANNUALLY- AnnuallyALL_UPFRONT- All upfront
MONTHLY, QUARTERLY, SEMI_ANNUALLY, ANNUALLY, ALL_UPFRONT The ID of the plan. Required unless every phase declares its own plan_id — it is the plan for any phase that does not.
The bricks included in the subscription. Required unless phases is provided, in which case every brick comes from the phases.
Show child attributes
Show child attributes
The ID of the point of contact (Person) object
The ID of the signatory user (Person) object
The ID of the customer
Optional currency to be used for the subscription. Defaults to USD.
USD- United States DollarEUR- EurosGBP- Great British PoundAUD- Australian DollarCAD- Canadian DollarINR- Indian Rupee
USD, EUR, GBP, AUD, CAD, INR Discount coupon codes to apply to the subscription. Currently only supports one discount coupon - only the first one in the list will be applied.
Optional list of phases for multi-phase orders. When provided, ALL phases come from this array (first element = phase 0, second = phase 1, etc.) and starts_at, contract_length, billing_frequency and bricks become optional — omit them and they are derived from the phases. plan_id is still required, and every brick in every phase must belong to it. When absent, the order-level fields define a single phase.
Show child attributes
Show child attributes
Whether the subscription auto-renews. Defaults to true.
List of email addresses for accounts payable contacts
The number of days from an invoice being generated that the buyer is expected to pay in
0 <= x <= 999The contract period for renewals in months. If null, inherits from initial contract period.
x >= 1The percentage rate to uplift renewal pricing. If null, no uplift is applied.
^-?\d{0,3}(?:\.\d{0,2})?$The medium by which the order is agreed.
ORDER_FORM- Order formSTRIPE- Stripe
ORDER_FORM, STRIPE Optional metadata to add to the subscription. Sending an empty map will delete all keys. Keys prefixed with _ are private and will be ignored.
The custom order form html to use with <html><body>...</body></html> formatting
Configuration for accepted payment methods during checkout and paywall
Show child attributes
Show child attributes
When the first invoice should be charged. If not provided, defaults to seller's first_charge_date setting, or CHECKOUT_DATE if seller has no setting.
CONTRACT_START_DATE- Contract Start DateCHECKOUT_DATE- Checkout Date
CONTRACT_START_DATE, CHECKOUT_DATE Optional ID of the legal entity that issues this subscription. Falls back to the seller's default legal entity when omitted.
Response
Common subscription response serializer that includes the ID of the subscription from the result of a subscription related operation.
ID of the subscription