settings-v0
Add a draft milestone rule
Adds a draft rule with its first version. A draft gives nothing until it is published. Every variant, plan and product must belong to the company. A first_order rule gives one unit of each item once per order (grant_per order, quantity 1, no fallbacks). Needs the milestone_items feature to work for the company.
POST
/
api
/
subscription_pro
/
milestone_rules
Add a draft milestone rule
curl --request POST \
--url https://api.fluid.app/api/subscription_pro/milestone_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Welcome bottle",
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"variant_id": 9012
}
]
}
'import requests
url = "https://api.fluid.app/api/subscription_pro/milestone_rules"
payload = {
"name": "Welcome bottle",
"trigger_type": "first_order",
"grant_per": "order",
"items": [{ "variant_id": 9012 }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Welcome bottle',
trigger_type: 'first_order',
grant_per: 'order',
items: [{variant_id: 9012}]
})
};
fetch('https://api.fluid.app/api/subscription_pro/milestone_rules', 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.fluid.app/api/subscription_pro/milestone_rules",
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([
'name' => 'Welcome bottle',
'trigger_type' => 'first_order',
'grant_per' => 'order',
'items' => [
[
'variant_id' => 9012
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.fluid.app/api/subscription_pro/milestone_rules"
payload := strings.NewReader("{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fluid.app/api/subscription_pro/milestone_rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/subscription_pro/milestone_rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"milestone_rule": {
"id": 123,
"name": "<string>",
"status": "draft",
"starts_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"current_version": {
"version": 2,
"trigger_type": "first_order",
"trigger_value": 123,
"scope": "all",
"scope_ids": [
123
],
"grant_per": "subscription",
"items": [
{
"item_key": "<string>",
"variant_id": 123,
"quantity": 50,
"fallback_variant_ids": [
123
]
}
],
"out_of_stock_policy": "substitute_then_defer",
"volume_policy": "zero",
"visibility": "announced",
"max_grants_per_subscription": 2,
"created_at": "2023-11-07T05:31:56Z"
}
},
"status": 200,
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}Authorizations
Bearer token authentication
Body
application/json
Maximum string length:
255A rule keeps its trigger type for life.
Available options:
first_order, nth_order, every_nth_order, anniversary Available options:
subscription, order Required array length:
1 - 20 elementsShow child attributes
Show child attributes
When the rule starts. Null or left out for at once.
When the rule ends. Null or left out for never.
N. Leave it out for first_order. anniversary defaults to 12 months.
Available options:
all, plans, products, variants Plans, products or variants of the company. Empty for all.
Available options:
substitute_then_defer, substitute_then_skip, skip Available options:
zero, catalog Available options:
announced, surprise Required range:
x >= 1⌘I
Add a draft milestone rule
curl --request POST \
--url https://api.fluid.app/api/subscription_pro/milestone_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Welcome bottle",
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"variant_id": 9012
}
]
}
'import requests
url = "https://api.fluid.app/api/subscription_pro/milestone_rules"
payload = {
"name": "Welcome bottle",
"trigger_type": "first_order",
"grant_per": "order",
"items": [{ "variant_id": 9012 }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Welcome bottle',
trigger_type: 'first_order',
grant_per: 'order',
items: [{variant_id: 9012}]
})
};
fetch('https://api.fluid.app/api/subscription_pro/milestone_rules', 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.fluid.app/api/subscription_pro/milestone_rules",
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([
'name' => 'Welcome bottle',
'trigger_type' => 'first_order',
'grant_per' => 'order',
'items' => [
[
'variant_id' => 9012
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.fluid.app/api/subscription_pro/milestone_rules"
payload := strings.NewReader("{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.fluid.app/api/subscription_pro/milestone_rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/subscription_pro/milestone_rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Welcome bottle\",\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"variant_id\": 9012\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"milestone_rule": {
"id": 123,
"name": "<string>",
"status": "draft",
"starts_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"current_version": {
"version": 2,
"trigger_type": "first_order",
"trigger_value": 123,
"scope": "all",
"scope_ids": [
123
],
"grant_per": "subscription",
"items": [
{
"item_key": "<string>",
"variant_id": 123,
"quantity": 50,
"fallback_variant_ids": [
123
]
}
],
"out_of_stock_policy": "substitute_then_defer",
"volume_policy": "zero",
"visibility": "announced",
"max_grants_per_subscription": 2,
"created_at": "2023-11-07T05:31:56Z"
}
},
"status": 200,
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"error": "<string>",
"error_message": "<string>",
"errors": "<string>",
"meta": {
"request_id": "<string>",
"timestamp": "2023-11-07T05:31:56Z"
}
}