curl --request POST \
--url https://api.valyx.com/billing/contract \
--header 'Content-Type: application/json' \
--header 'X-Valyx-Signature: <x-valyx-signature>' \
--data '
{
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": {
"unit": "MONTH",
"value": 12
},
"billingFrequency": {
"unit": "MONTH",
"value": 1
},
"isPreusage": false
}
'import requests
url = "https://api.valyx.com/billing/contract"
payload = {
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": {
"unit": "MONTH",
"value": 12
},
"billingFrequency": {
"unit": "MONTH",
"value": 1
},
"isPreusage": False
}
headers = {
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cust_45678',
contractNumber: 'CONTRACT-2025-001',
contractTitle: 'Premium Subscription Plan',
contractPeriod: {unit: 'MONTH', value: 12},
billingFrequency: {unit: 'MONTH', value: 1},
isPreusage: false
})
};
fetch('https://api.valyx.com/billing/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cust_45678',
contractNumber: 'CONTRACT-2025-001',
contractTitle: 'Premium Subscription Plan',
contractPeriod: {unit: 'MONTH', value: 12},
billingFrequency: {unit: 'MONTH', value: 1},
isPreusage: false
})
};
fetch('https://api.valyx.com/billing/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.valyx.com/billing/contract"
payload := strings.NewReader("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Valyx-Signature", "<x-valyx-signature>")
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.valyx.com/billing/contract")
.header("X-Valyx-Signature", "<x-valyx-signature>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valyx.com/billing/contract",
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([
'customerId' => 'cust_45678',
'contractNumber' => 'CONTRACT-2025-001',
'contractTitle' => 'Premium Subscription Plan',
'contractPeriod' => [
'unit' => 'MONTH',
'value' => 12
],
'billingFrequency' => [
'unit' => 'MONTH',
'value' => 1
],
'isPreusage' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Valyx-Signature: <x-valyx-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.valyx.com/billing/contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Valyx-Signature"] = '<x-valyx-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": [
"unit": "MONTH",
"value": 12
],
"billingFrequency": [
"unit": "MONTH",
"value": 1
],
"isPreusage": false
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.valyx.com/billing/contract")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
val request = Request.Builder()
.url("https://api.valyx.com/billing/contract")
.post(body)
.addHeader("X-Valyx-Signature", "<x-valyx-signature>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()using RestSharp;
var options = new RestClientOptions("https://api.valyx.com/billing/contract");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Valyx-Signature", "<x-valyx-signature>");
request.AddJsonBody("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
false{
"error": "<string>",
"message": "<string>",
"data": {
"totalDocs": 123,
"docs": [
{
"id": {},
"customerId": {},
"contractNumber": {},
"contractTitle": {},
"contractPeriod": {},
"renewalPeriod": {},
"noteContract": {},
"billingFrequency": {},
"usageBillingCycle": {},
"estimateCycle": {},
"billingTime": {},
"startDate": {},
"virtualStartDate": {},
"endDate": {},
"nextBillingDate": {},
"billingDiscounts": {},
"isPreusage": {},
"billingReportLimit": {},
"contractLimit": {},
"creditTermId": {},
"poNumber": {},
"placeOfSupply": {},
"billingAddress": {},
"shippingAddress": {},
"totalInvoicedAmount": {},
"noteInvoice": {},
"terms": {},
"advanceConfig": {},
"invoiceSplitConfig": {},
"gstin": {},
"companyGstin": {},
"currency": {},
"currencyId": {},
"companyId": {},
"createdBy": {},
"updatedBy": {},
"status": {},
"autoRenew": {}
}
],
"hasNext": true,
"hasPrev": true,
"pageNumber": 123,
"pageSize": 123,
"totalPages": 123,
"prevPageNumber": 123,
"nextPageNumber": 123
}
}Create Contracts
curl --request POST \
--url https://api.valyx.com/billing/contract \
--header 'Content-Type: application/json' \
--header 'X-Valyx-Signature: <x-valyx-signature>' \
--data '
{
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": {
"unit": "MONTH",
"value": 12
},
"billingFrequency": {
"unit": "MONTH",
"value": 1
},
"isPreusage": false
}
'import requests
url = "https://api.valyx.com/billing/contract"
payload = {
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": {
"unit": "MONTH",
"value": 12
},
"billingFrequency": {
"unit": "MONTH",
"value": 1
},
"isPreusage": False
}
headers = {
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cust_45678',
contractNumber: 'CONTRACT-2025-001',
contractTitle: 'Premium Subscription Plan',
contractPeriod: {unit: 'MONTH', value: 12},
billingFrequency: {unit: 'MONTH', value: 1},
isPreusage: false
})
};
fetch('https://api.valyx.com/billing/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {'X-Valyx-Signature': '<x-valyx-signature>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customerId: 'cust_45678',
contractNumber: 'CONTRACT-2025-001',
contractTitle: 'Premium Subscription Plan',
contractPeriod: {unit: 'MONTH', value: 12},
billingFrequency: {unit: 'MONTH', value: 1},
isPreusage: false
})
};
fetch('https://api.valyx.com/billing/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.valyx.com/billing/contract"
payload := strings.NewReader("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Valyx-Signature", "<x-valyx-signature>")
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.valyx.com/billing/contract")
.header("X-Valyx-Signature", "<x-valyx-signature>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valyx.com/billing/contract",
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([
'customerId' => 'cust_45678',
'contractNumber' => 'CONTRACT-2025-001',
'contractTitle' => 'Premium Subscription Plan',
'contractPeriod' => [
'unit' => 'MONTH',
'value' => 12
],
'billingFrequency' => [
'unit' => 'MONTH',
'value' => 1
],
'isPreusage' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Valyx-Signature: <x-valyx-signature>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.valyx.com/billing/contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Valyx-Signature"] = '<x-valyx-signature>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}"
response = http.request(request)
puts response.read_bodyimport Foundation
let parameters = [
"customerId": "cust_45678",
"contractNumber": "CONTRACT-2025-001",
"contractTitle": "Premium Subscription Plan",
"contractPeriod": [
"unit": "MONTH",
"value": 12
],
"billingFrequency": [
"unit": "MONTH",
"value": 1
],
"isPreusage": false
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.valyx.com/billing/contract")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"X-Valyx-Signature": "<x-valyx-signature>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}")
val request = Request.Builder()
.url("https://api.valyx.com/billing/contract")
.post(body)
.addHeader("X-Valyx-Signature", "<x-valyx-signature>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()using RestSharp;
var options = new RestClientOptions("https://api.valyx.com/billing/contract");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Valyx-Signature", "<x-valyx-signature>");
request.AddJsonBody("{\n \"customerId\": \"cust_45678\",\n \"contractNumber\": \"CONTRACT-2025-001\",\n \"contractTitle\": \"Premium Subscription Plan\",\n \"contractPeriod\": {\n \"unit\": \"MONTH\",\n \"value\": 12\n },\n \"billingFrequency\": {\n \"unit\": \"MONTH\",\n \"value\": 1\n },\n \"isPreusage\": false\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
false{
"error": "<string>",
"message": "<string>",
"data": {
"totalDocs": 123,
"docs": [
{
"id": {},
"customerId": {},
"contractNumber": {},
"contractTitle": {},
"contractPeriod": {},
"renewalPeriod": {},
"noteContract": {},
"billingFrequency": {},
"usageBillingCycle": {},
"estimateCycle": {},
"billingTime": {},
"startDate": {},
"virtualStartDate": {},
"endDate": {},
"nextBillingDate": {},
"billingDiscounts": {},
"isPreusage": {},
"billingReportLimit": {},
"contractLimit": {},
"creditTermId": {},
"poNumber": {},
"placeOfSupply": {},
"billingAddress": {},
"shippingAddress": {},
"totalInvoicedAmount": {},
"noteInvoice": {},
"terms": {},
"advanceConfig": {},
"invoiceSplitConfig": {},
"gstin": {},
"companyGstin": {},
"currency": {},
"currencyId": {},
"companyId": {},
"createdBy": {},
"updatedBy": {},
"status": {},
"autoRenew": {}
}
],
"hasNext": true,
"hasPrev": true,
"pageNumber": 123,
"pageSize": 123,
"totalPages": 123,
"prevPageNumber": 123,
"nextPageNumber": 123
}
}Headers
Auth key to authenticate the request
Body
The unique identifier of the customer associated with this contract
"cust_45678"
A unique reference number for this contract
"CONTRACT-2025-001"
The title or name of the contract
"Premium Subscription Plan"
The total duration of the contract, specifying the time unit and value
Show child attributes
Show child attributes
How often billing should occur for this contract
Show child attributes
Show child attributes
Indicates if billing should happen at the start of the period (pre-usage)
The date when the contract becomes effective
"2025-01-01"
A calculated start date for billing purposes, used if billing time is set to beginning of period
"2025-01-01"
Identifier for the credit term associated with this contract
"CT-30-DAYS"
Purchase order number, if applicable
"PO-98765"
Optional note to be included in the invoice
"Please pay within 30 days"
Terms and conditions associated with this contract
"Net 30 payment terms apply"
Optional note to be displayed on the contract
"This contract is for the premium subscription plan"
List of discounts applicable during billing
Show child attributes
Show child attributes
Determines when billing is calculated: either at the beginning of the period or based on subscription start date
BEGINNING_OF_PERIOD, SUBSCRIPTION_DATE "BEGINNING_OF_PERIOD"
Limits applied to the billing report for this contract
Show child attributes
Show child attributes
Optional limit on total contract value or usage
Show child attributes
Show child attributes
Configuration for advance billing or usage adjustments
Show child attributes
Show child attributes
If true, the contract will automatically renew at the end of its period
The duration for which the contract should be renewed automatically
Show child attributes
Show child attributes