Add a one time charge
curl --request POST \
--url https://api.metronome.com/v1/customers/{customer_id}/addCharge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"charge_id": "5ae4b726-1ebe-439c-9190-9831760ba195",
"price": 250,
"quantity": 1,
"description": "One time charge",
"invoice_start_timestamp": "2024-01-01T00:00:00Z",
"customer_plan_id": "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015"
}
'import requests
url = "https://api.metronome.com/v1/customers/{customer_id}/addCharge"
payload = {
"charge_id": "5ae4b726-1ebe-439c-9190-9831760ba195",
"price": 250,
"quantity": 1,
"description": "One time charge",
"invoice_start_timestamp": "2024-01-01T00:00:00Z",
"customer_plan_id": "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015"
}
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({
charge_id: '5ae4b726-1ebe-439c-9190-9831760ba195',
price: 250,
quantity: 1,
description: 'One time charge',
invoice_start_timestamp: '2024-01-01T00:00:00Z',
customer_plan_id: 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015'
})
};
fetch('https://api.metronome.com/v1/customers/{customer_id}/addCharge', 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}/addCharge",
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([
'charge_id' => '5ae4b726-1ebe-439c-9190-9831760ba195',
'price' => 250,
'quantity' => 1,
'description' => 'One time charge',
'invoice_start_timestamp' => '2024-01-01T00:00:00Z',
'customer_plan_id' => 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015'
]),
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}/addCharge"
payload := strings.NewReader("{\n \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\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}/addCharge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/customers/{customer_id}/addCharge")
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 \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\n}"
response = http.request(request)
puts response.read_body{}Customers
Add a one time charge
Add a one time charge to the specified invoice. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.
POST
/
customers
/
{customer_id}
/
addCharge
Add a one time charge
curl --request POST \
--url https://api.metronome.com/v1/customers/{customer_id}/addCharge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"charge_id": "5ae4b726-1ebe-439c-9190-9831760ba195",
"price": 250,
"quantity": 1,
"description": "One time charge",
"invoice_start_timestamp": "2024-01-01T00:00:00Z",
"customer_plan_id": "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015"
}
'import requests
url = "https://api.metronome.com/v1/customers/{customer_id}/addCharge"
payload = {
"charge_id": "5ae4b726-1ebe-439c-9190-9831760ba195",
"price": 250,
"quantity": 1,
"description": "One time charge",
"invoice_start_timestamp": "2024-01-01T00:00:00Z",
"customer_plan_id": "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015"
}
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({
charge_id: '5ae4b726-1ebe-439c-9190-9831760ba195',
price: 250,
quantity: 1,
description: 'One time charge',
invoice_start_timestamp: '2024-01-01T00:00:00Z',
customer_plan_id: 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015'
})
};
fetch('https://api.metronome.com/v1/customers/{customer_id}/addCharge', 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}/addCharge",
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([
'charge_id' => '5ae4b726-1ebe-439c-9190-9831760ba195',
'price' => 250,
'quantity' => 1,
'description' => 'One time charge',
'invoice_start_timestamp' => '2024-01-01T00:00:00Z',
'customer_plan_id' => 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015'
]),
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}/addCharge"
payload := strings.NewReader("{\n \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\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}/addCharge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/customers/{customer_id}/addCharge")
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 \"charge_id\": \"5ae4b726-1ebe-439c-9190-9831760ba195\",\n \"price\": 250,\n \"quantity\": 1,\n \"description\": \"One time charge\",\n \"invoice_start_timestamp\": \"2024-01-01T00:00:00Z\",\n \"customer_plan_id\": \"a23b3cf4-47fb-4c3f-bb3d-9e64f7704015\"\n}"
response = http.request(request)
puts response.read_body{}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
One time charge creation request
The Metronome ID of the charge to add to the invoice. Note that the charge must be on a product that is not on the current plan, and the product must have only fixed charges.
The price of the charge. This price will match the currency on the invoice, e.g. USD cents.
The Metronome ID of the customer plan to add the charge to.
The start_timestamp of the invoice to add the charge to.
Response
200 - application/json
Success
The response is of type object.
⌘I