Skip to main content
POST
/
customers
/
{customer_id}
/
plans
/
add
Add a plan to a customer
curl --request POST \
  --url https://api.metronome.com/v1/customers/{customer_id}/plans/add \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "plan_id": "d2c06dae-9549-4d7d-bc04-b78dd3d241b8",
  "starting_on": "2021-02-01T00:00:00Z",
  "ending_before": "2022-02-01T00:00:00Z"
}
'
import requests

url = "https://api.metronome.com/v1/customers/{customer_id}/plans/add"

payload = {
"plan_id": "d2c06dae-9549-4d7d-bc04-b78dd3d241b8",
"starting_on": "2021-02-01T00:00:00Z",
"ending_before": "2022-02-01T00:00:00Z"
}
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({
plan_id: 'd2c06dae-9549-4d7d-bc04-b78dd3d241b8',
starting_on: '2021-02-01T00:00:00Z',
ending_before: '2022-02-01T00:00:00Z'
})
};

fetch('https://api.metronome.com/v1/customers/{customer_id}/plans/add', 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.metronome.com/v1/customers/{customer_id}/plans/add",
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([
'plan_id' => 'd2c06dae-9549-4d7d-bc04-b78dd3d241b8',
'starting_on' => '2021-02-01T00:00:00Z',
'ending_before' => '2022-02-01T00:00:00Z'
]),
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.metronome.com/v1/customers/{customer_id}/plans/add"

payload := strings.NewReader("{\n \"plan_id\": \"d2c06dae-9549-4d7d-bc04-b78dd3d241b8\",\n \"starting_on\": \"2021-02-01T00:00:00Z\",\n \"ending_before\": \"2022-02-01T00:00:00Z\"\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.metronome.com/v1/customers/{customer_id}/plans/add")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_id\": \"d2c06dae-9549-4d7d-bc04-b78dd3d241b8\",\n \"starting_on\": \"2021-02-01T00:00:00Z\",\n \"ending_before\": \"2022-02-01T00:00:00Z\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.metronome.com/v1/customers/{customer_id}/plans/add")

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 \"plan_id\": \"d2c06dae-9549-4d7d-bc04-b78dd3d241b8\",\n \"starting_on\": \"2021-02-01T00:00:00Z\",\n \"ending_before\": \"2022-02-01T00:00:00Z\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "8b24d3dc-6db5-432d-9416-8439b3fbf242"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

customer_id
string<uuid>
required

Body

application/json

The customer ID, plan ID, and date range for the plan to be applied

plan_id
string<uuid>
required
starting_on
string<date-time>
required

RFC 3339 timestamp for when the plan becomes active for this customer. Must be at 0:00 UTC (midnight).

ending_before
string<date-time>

RFC 3339 timestamp for when the plan ends (exclusive) for this customer. Must be at 0:00 UTC (midnight).

net_payment_terms_days
number

Number of days after issuance of invoice after which the invoice is due (e.g. Net 30).

price_adjustments
object[]

A list of price adjustments can be applied on top of the pricing in the plans. See the price adjustments documentation for details.

trial_spec
object

A custom trial can be set for the customer's plan. See the trial configuration documentation for details.

overage_rate_adjustments
object[]

An optional list of overage rates that override the rates of the original plan configuration. These new rates will apply to all pricing ramps.

Response

200 - application/json

Success

data
object
required