Skip to main content
POST
/
v1
/
contracts
/
create
Create a contract
curl --request POST \
  --url https://api.metronome.com/v1/contracts/create \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",
  "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
  "starting_at": "2020-01-01T00:00:00.000Z",
  "billing_provider_configuration": {
    "billing_provider": "stripe",
    "delivery_method": "direct_to_billing_provider"
  }
}
'
import requests

url = "https://api.metronome.com/v1/contracts/create"

payload = {
"customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",
"rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
"starting_at": "2020-01-01T00:00:00.000Z",
"billing_provider_configuration": {
"billing_provider": "stripe",
"delivery_method": "direct_to_billing_provider"
}
}
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({
customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
starting_at: '2020-01-01T00:00:00.000Z',
billing_provider_configuration: {billing_provider: 'stripe', delivery_method: 'direct_to_billing_provider'}
})
};

fetch('https://api.metronome.com/v1/contracts/create', 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/contracts/create",
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([
'customer_id' => '13117714-3f05-48e5-a6e9-a66093f13b4d',
'rate_card_id' => 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
'starting_at' => '2020-01-01T00:00:00.000Z',
'billing_provider_configuration' => [
'billing_provider' => 'stripe',
'delivery_method' => 'direct_to_billing_provider'
]
]),
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/contracts/create"

payload := strings.NewReader("{\n \"customer_id\": \"13117714-3f05-48e5-a6e9-a66093f13b4d\",\n \"rate_card_id\": \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"starting_at\": \"2020-01-01T00:00:00.000Z\",\n \"billing_provider_configuration\": {\n \"billing_provider\": \"stripe\",\n \"delivery_method\": \"direct_to_billing_provider\"\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.metronome.com/v1/contracts/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"13117714-3f05-48e5-a6e9-a66093f13b4d\",\n \"rate_card_id\": \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"starting_at\": \"2020-01-01T00:00:00.000Z\",\n \"billing_provider_configuration\": {\n \"billing_provider\": \"stripe\",\n \"delivery_method\": \"direct_to_billing_provider\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.metronome.com/v1/contracts/create")

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 \"customer_id\": \"13117714-3f05-48e5-a6e9-a66093f13b4d\",\n \"rate_card_id\": \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"starting_at\": \"2020-01-01T00:00:00.000Z\",\n \"billing_provider_configuration\": {\n \"billing_provider\": \"stripe\",\n \"delivery_method\": \"direct_to_billing_provider\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
    "contract": {
      "id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
      "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",
      "starting_at": "2020-01-01T00:00:00.000Z",
      "commits": [],
      "credits": [],
      "overrides": [],
      "scheduled_charges": [],
      "transitions": [],
      "subscriptions": [],
      "recurring_commits": [],
      "recurring_credits": [],
      "created_at": "2020-01-01T00:00:00.000Z",
      "created_by": "system",
      "usage_statement_schedule": {
        "frequency": "MONTHLY",
        "billing_anchor_date": "2020-01-01T00:00:00.000Z"
      },
      "usage_filter": []
    }
  }
}
{
"message": "<string>"
}
{
"message": "<string>"
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Create a new contract

customer_id
string<uuid>
required
starting_at
string<date-time>
required

inclusive contract start time

package_id
string<uuid>

If provided, provisions a customer on a package instead of creating a traditional contract. When specified, only customer_id, starting_at, package_id, uniqueness_key, transition, and custom_fields are allowed.

package_alias
string

Selects the package linked to the specified alias as of the contract's start date. Mutually exclusive with package_id.

name
string
uniqueness_key
string

Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.

Required string length: 1 - 128
net_payment_terms_days
number
rate_card_id
string<uuid>
rate_card_alias
string

Selects the rate card linked to the specified alias as of the contract's start date.

ending_before
string<date-time>

exclusive contract end time

commits
object[]
credits
object[]
recurring_commits
object[]
recurring_credits
object[]
multiplier_override_prioritization
enum<string>

Defaults to LOWEST_MULTIPLIER, which applies the greatest discount to list prices automatically. EXPLICIT prioritization requires specifying priorities for each multiplier; the one with the lowest priority value will be prioritized first. If tiered overrides are used, prioritization must be explicit.

Available options:
LOWEST_MULTIPLIER,
lowest_multiplier,
EXPLICIT,
explicit
overrides
object[]
scheduled_charges
object[]
scheduled_charges_on_usage_invoices
enum<string>

Determines which scheduled and commit charges to consolidate onto the Contract's usage invoice. The charge's timestamp must match the usage invoice's ending_before date for consolidation to occur. This field cannot be modified after a Contract has been created. If this field is omitted, charges will appear on a separate invoice from usage charges.

Available options:
ALL
transition
object
usage_filter
object
usage_statement_schedule
object
custom_fields
object

Custom fields to be added eg. { "key1": "value1", "key2": "value2" }

billing_provider_configuration
object

The billing provider configuration associated with a contract. Provide either an ID or the provider and delivery method.

spend_threshold_configuration
object
prepaid_balance_threshold_configuration
object
subscriptions
object[]

Optional list of subscriptions to add to the contract.

hierarchy_configuration
object

Response

Success

data
object
required