Subscription Pro
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 or customer (grant_per order or customer, 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
],
"pricing": "gift"
}
],
"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"
}
}Body
application/json
⌘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
],
"pricing": "gift"
}
],
"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"
}
}