settings-v0
Publish a milestone rule
Makes the rule active. With no configuration it publishes the version in force. With one (trigger_type, grant_per and items at least) it writes the next immutable version first; send an item’s item_key back to keep it as the same item. The trigger type cannot change. An archived rule cannot be published. Needs the milestone_items feature to work for the company.
POST
/
api
/
subscription_pro
/
milestone_rules
/
{id}
/
publish
Publish a milestone rule
curl --request POST \
--url https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"item_key": "3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b",
"variant_id": 9013
}
],
"volume_policy": "zero"
}
'import requests
url = "https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish"
payload = {
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"item_key": "3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b",
"variant_id": 9013
}
],
"volume_policy": "zero"
}
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({
trigger_type: 'first_order',
grant_per: 'order',
items: [{item_key: '3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b', variant_id: 9013}],
volume_policy: 'zero'
})
};
fetch('https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish', 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/{id}/publish",
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([
'trigger_type' => 'first_order',
'grant_per' => 'order',
'items' => [
[
'item_key' => '3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b',
'variant_id' => 9013
]
],
'volume_policy' => 'zero'
]),
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/{id}/publish"
payload := strings.NewReader("{\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\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/{id}/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish")
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 \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\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"
}
}{
"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
Path Parameters
The milestone rule id.
Body
application/json
A rule keeps its trigger type for life.
Available options:
first_order, nth_order, every_nth_order, anniversary 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:
subscription, order Required array length:
1 - 20 elementsShow child attributes
Show child attributes
Available options:
substitute_then_defer, substitute_then_skip, skip Available options:
zero, catalog Available options:
announced, surprise Required range:
x >= 1⌘I
Publish a milestone rule
curl --request POST \
--url https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"item_key": "3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b",
"variant_id": 9013
}
],
"volume_policy": "zero"
}
'import requests
url = "https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish"
payload = {
"trigger_type": "first_order",
"grant_per": "order",
"items": [
{
"item_key": "3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b",
"variant_id": 9013
}
],
"volume_policy": "zero"
}
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({
trigger_type: 'first_order',
grant_per: 'order',
items: [{item_key: '3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b', variant_id: 9013}],
volume_policy: 'zero'
})
};
fetch('https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish', 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/{id}/publish",
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([
'trigger_type' => 'first_order',
'grant_per' => 'order',
'items' => [
[
'item_key' => '3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b',
'variant_id' => 9013
]
],
'volume_policy' => 'zero'
]),
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/{id}/publish"
payload := strings.NewReader("{\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\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/{id}/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fluid.app/api/subscription_pro/milestone_rules/{id}/publish")
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 \"trigger_type\": \"first_order\",\n \"grant_per\": \"order\",\n \"items\": [\n {\n \"item_key\": \"3f1c2a9e-5b7d-4e8f-9a1b-2c3d4e5f6a7b\",\n \"variant_id\": 9013\n }\n ],\n \"volume_policy\": \"zero\"\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"
}
}{
"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"
}
}