curl --request POST \
--url https://api.paygentic.io/v0/contracts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"currency": "<string>",
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"lines": [
{
"itemId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"billingCadence": "<string>",
"billableMetricId": "<string>",
"quantity": "3",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 0,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"outsideScopeLabel": "<string>"
}
],
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>"
}
'import requests
url = "https://api.paygentic.io/v0/contracts"
payload = {
"customerId": "<string>",
"currency": "<string>",
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"autoCharge": True,
"bankTransferOnly": True,
"autoApprove": {
"contract": True,
"invoices": True
},
"lines": [
{
"itemId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"billingCadence": "<string>",
"billableMetricId": "<string>",
"quantity": "3",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 0,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"outsideScopeLabel": "<string>"
}
],
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>"
}
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({
customerId: '<string>',
currency: '<string>',
name: '<string>',
contractStart: '2023-11-07T05:31:56Z',
contractEnd: '2023-11-07T05:31:56Z',
autoCharge: true,
bankTransferOnly: true,
autoApprove: {contract: true, invoices: true},
lines: [
{
itemId: '<string>',
price: {model: '<string>', properties: {}},
billingCadence: '<string>',
billableMetricId: '<string>',
quantity: '3',
billDate: '2023-11-07T05:31:56Z',
startDate: '2023-11-07T05:31:56Z',
endDate: '2023-11-07T05:31:56Z',
billingAnchor: '2023-11-07T05:31:56Z',
invoiceOffsetDays: 0,
featureId: '<string>',
entitlementTemplate: {},
invoiceDisplayName: '<string>',
description: '<string>',
invoiceDisplayGroup: '<string>',
outsideScopeLabel: '<string>'
}
],
billingAnchor: '2023-11-07T05:31:56Z',
billingStartsAt: '2023-11-07T05:31:56Z',
upliftPercent: '<string>',
note: '<string>'
})
};
fetch('https://api.paygentic.io/v0/contracts', 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.paygentic.io/v0/contracts",
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' => '<string>',
'currency' => '<string>',
'name' => '<string>',
'contractStart' => '2023-11-07T05:31:56Z',
'contractEnd' => '2023-11-07T05:31:56Z',
'autoCharge' => true,
'bankTransferOnly' => true,
'autoApprove' => [
'contract' => true,
'invoices' => true
],
'lines' => [
[
'itemId' => '<string>',
'price' => [
'model' => '<string>',
'properties' => [
]
],
'billingCadence' => '<string>',
'billableMetricId' => '<string>',
'quantity' => '3',
'billDate' => '2023-11-07T05:31:56Z',
'startDate' => '2023-11-07T05:31:56Z',
'endDate' => '2023-11-07T05:31:56Z',
'billingAnchor' => '2023-11-07T05:31:56Z',
'invoiceOffsetDays' => 0,
'featureId' => '<string>',
'entitlementTemplate' => [
],
'invoiceDisplayName' => '<string>',
'description' => '<string>',
'invoiceDisplayGroup' => '<string>',
'outsideScopeLabel' => '<string>'
]
],
'billingAnchor' => '2023-11-07T05:31:56Z',
'billingStartsAt' => '2023-11-07T05:31:56Z',
'upliftPercent' => '<string>',
'note' => '<string>'
]),
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.paygentic.io/v0/contracts"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\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.paygentic.io/v0/contracts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/contracts")
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 \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "contract",
"merchantId": "<string>",
"customerId": "<string>",
"currency": "<string>",
"status": "draft",
"createdAt": "2023-11-07T05:31:56Z",
"externalReference": {
"provider": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>",
"pendingChange": {
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>"
},
"decidedAt": "2023-11-07T05:31:56Z",
"decidedByPrincipalId": "<string>",
"rejectReason": "<string>",
"rejectText": "<string>",
"validation": [
{
"scope": "contract",
"code": "<string>",
"message": "<string>",
"lineId": "<string>",
"field": "<string>",
"allowedDates": [
"2023-11-07T05:31:56Z"
]
}
],
"conflicts": [
{
"code": "ITEM_ON_OTHER_LIVE_CONTRACT",
"lineId": "<string>",
"otherContractId": "<string>",
"otherLineId": "<string>",
"message": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>"
}
]
}{
"id": "<string>",
"object": "contract",
"merchantId": "<string>",
"customerId": "<string>",
"currency": "<string>",
"status": "draft",
"createdAt": "2023-11-07T05:31:56Z",
"externalReference": {
"provider": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>",
"pendingChange": {
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>"
},
"decidedAt": "2023-11-07T05:31:56Z",
"decidedByPrincipalId": "<string>",
"rejectReason": "<string>",
"rejectText": "<string>",
"validation": [
{
"scope": "contract",
"code": "<string>",
"message": "<string>",
"lineId": "<string>",
"field": "<string>",
"allowedDates": [
"2023-11-07T05:31:56Z"
]
}
],
"conflicts": [
{
"code": "ITEM_ON_OTHER_LIVE_CONTRACT",
"lineId": "<string>",
"otherContractId": "<string>",
"otherLineId": "<string>",
"message": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>"
}
]
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"error": "conflict",
"message": "The record already has a contract for another customer",
"code": "CONTRACT_REFERENCE_CUSTOMER_MISMATCH"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Create
Creates a contract as a draft for a customer of your merchant. Nothing is billed until the contract is approved. Both autoApprove values are required, with no default. A customer, item, billable metric or plan version of another merchant answers 404, and nothing is written.
With an externalReference, a create finds the contract that record already has. When there is one, the response is that contract, with status 200, and nothing is created. Sends of one record are handled one at a time. When two sends arrive together and the second waits too long for the first, it answers 409 TRANSIENT_CONTENTION: that is not a completed send, so send it again. A new contract answers 201.
With autoApprove.contract: true, the create needs the contracts:approve permission and answers 403 without it. A valid contract is then approved in the same request. When it is not valid, the contract stays a draft and validation lists the errors.
curl --request POST \
--url https://api.paygentic.io/v0/contracts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"currency": "<string>",
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"lines": [
{
"itemId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"billingCadence": "<string>",
"billableMetricId": "<string>",
"quantity": "3",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 0,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"outsideScopeLabel": "<string>"
}
],
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>"
}
'import requests
url = "https://api.paygentic.io/v0/contracts"
payload = {
"customerId": "<string>",
"currency": "<string>",
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"autoCharge": True,
"bankTransferOnly": True,
"autoApprove": {
"contract": True,
"invoices": True
},
"lines": [
{
"itemId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"billingCadence": "<string>",
"billableMetricId": "<string>",
"quantity": "3",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 0,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"outsideScopeLabel": "<string>"
}
],
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>"
}
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({
customerId: '<string>',
currency: '<string>',
name: '<string>',
contractStart: '2023-11-07T05:31:56Z',
contractEnd: '2023-11-07T05:31:56Z',
autoCharge: true,
bankTransferOnly: true,
autoApprove: {contract: true, invoices: true},
lines: [
{
itemId: '<string>',
price: {model: '<string>', properties: {}},
billingCadence: '<string>',
billableMetricId: '<string>',
quantity: '3',
billDate: '2023-11-07T05:31:56Z',
startDate: '2023-11-07T05:31:56Z',
endDate: '2023-11-07T05:31:56Z',
billingAnchor: '2023-11-07T05:31:56Z',
invoiceOffsetDays: 0,
featureId: '<string>',
entitlementTemplate: {},
invoiceDisplayName: '<string>',
description: '<string>',
invoiceDisplayGroup: '<string>',
outsideScopeLabel: '<string>'
}
],
billingAnchor: '2023-11-07T05:31:56Z',
billingStartsAt: '2023-11-07T05:31:56Z',
upliftPercent: '<string>',
note: '<string>'
})
};
fetch('https://api.paygentic.io/v0/contracts', 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.paygentic.io/v0/contracts",
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' => '<string>',
'currency' => '<string>',
'name' => '<string>',
'contractStart' => '2023-11-07T05:31:56Z',
'contractEnd' => '2023-11-07T05:31:56Z',
'autoCharge' => true,
'bankTransferOnly' => true,
'autoApprove' => [
'contract' => true,
'invoices' => true
],
'lines' => [
[
'itemId' => '<string>',
'price' => [
'model' => '<string>',
'properties' => [
]
],
'billingCadence' => '<string>',
'billableMetricId' => '<string>',
'quantity' => '3',
'billDate' => '2023-11-07T05:31:56Z',
'startDate' => '2023-11-07T05:31:56Z',
'endDate' => '2023-11-07T05:31:56Z',
'billingAnchor' => '2023-11-07T05:31:56Z',
'invoiceOffsetDays' => 0,
'featureId' => '<string>',
'entitlementTemplate' => [
],
'invoiceDisplayName' => '<string>',
'description' => '<string>',
'invoiceDisplayGroup' => '<string>',
'outsideScopeLabel' => '<string>'
]
],
'billingAnchor' => '2023-11-07T05:31:56Z',
'billingStartsAt' => '2023-11-07T05:31:56Z',
'upliftPercent' => '<string>',
'note' => '<string>'
]),
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.paygentic.io/v0/contracts"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\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.paygentic.io/v0/contracts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/contracts")
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 \"customerId\": \"<string>\",\n \"currency\": \"<string>\",\n \"name\": \"<string>\",\n \"contractStart\": \"2023-11-07T05:31:56Z\",\n \"contractEnd\": \"2023-11-07T05:31:56Z\",\n \"autoCharge\": true,\n \"bankTransferOnly\": true,\n \"autoApprove\": {\n \"contract\": true,\n \"invoices\": true\n },\n \"lines\": [\n {\n \"itemId\": \"<string>\",\n \"price\": {\n \"model\": \"<string>\",\n \"properties\": {}\n },\n \"billingCadence\": \"<string>\",\n \"billableMetricId\": \"<string>\",\n \"quantity\": \"3\",\n \"billDate\": \"2023-11-07T05:31:56Z\",\n \"startDate\": \"2023-11-07T05:31:56Z\",\n \"endDate\": \"2023-11-07T05:31:56Z\",\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"invoiceOffsetDays\": 0,\n \"featureId\": \"<string>\",\n \"entitlementTemplate\": {},\n \"invoiceDisplayName\": \"<string>\",\n \"description\": \"<string>\",\n \"invoiceDisplayGroup\": \"<string>\",\n \"outsideScopeLabel\": \"<string>\"\n }\n ],\n \"billingAnchor\": \"2023-11-07T05:31:56Z\",\n \"billingStartsAt\": \"2023-11-07T05:31:56Z\",\n \"upliftPercent\": \"<string>\",\n \"note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "contract",
"merchantId": "<string>",
"customerId": "<string>",
"currency": "<string>",
"status": "draft",
"createdAt": "2023-11-07T05:31:56Z",
"externalReference": {
"provider": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>",
"pendingChange": {
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>"
},
"decidedAt": "2023-11-07T05:31:56Z",
"decidedByPrincipalId": "<string>",
"rejectReason": "<string>",
"rejectText": "<string>",
"validation": [
{
"scope": "contract",
"code": "<string>",
"message": "<string>",
"lineId": "<string>",
"field": "<string>",
"allowedDates": [
"2023-11-07T05:31:56Z"
]
}
],
"conflicts": [
{
"code": "ITEM_ON_OTHER_LIVE_CONTRACT",
"lineId": "<string>",
"otherContractId": "<string>",
"otherLineId": "<string>",
"message": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>"
}
]
}{
"id": "<string>",
"object": "contract",
"merchantId": "<string>",
"customerId": "<string>",
"currency": "<string>",
"status": "draft",
"createdAt": "2023-11-07T05:31:56Z",
"externalReference": {
"provider": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>",
"pendingChange": {
"name": "<string>",
"contractStart": "2023-11-07T05:31:56Z",
"contractEnd": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"billingStartsAt": "2023-11-07T05:31:56Z",
"upliftPercent": "<string>",
"note": "<string>",
"autoCharge": true,
"bankTransferOnly": true,
"autoApprove": {
"contract": true,
"invoices": true
},
"terminatedAt": "2023-11-07T05:31:56Z",
"terminationReason": "<string>",
"lines": [
{
"id": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>",
"copiedFromPriceId": "<string>",
"price": {
"model": "<string>",
"properties": {}
},
"quantity": "<string>",
"billingCadence": "<string>",
"paymentTerm": "in_advance",
"billDate": "2023-11-07T05:31:56Z",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"billingAnchor": "2023-11-07T05:31:56Z",
"invoiceOffsetDays": 123,
"featureId": "<string>",
"entitlementTemplate": {},
"invoiceDisplayName": "<string>",
"description": "<string>",
"invoiceDisplayGroup": "<string>",
"rateType": "amount",
"supplyScope": "IN_SCOPE",
"outsideScopeLabel": "<string>"
}
],
"updatedAt": "2023-11-07T05:31:56Z",
"createdByPrincipalId": "<string>"
},
"decidedAt": "2023-11-07T05:31:56Z",
"decidedByPrincipalId": "<string>",
"rejectReason": "<string>",
"rejectText": "<string>",
"validation": [
{
"scope": "contract",
"code": "<string>",
"message": "<string>",
"lineId": "<string>",
"field": "<string>",
"allowedDates": [
"2023-11-07T05:31:56Z"
]
}
],
"conflicts": [
{
"code": "ITEM_ON_OTHER_LIVE_CONTRACT",
"lineId": "<string>",
"otherContractId": "<string>",
"otherLineId": "<string>",
"message": "<string>",
"itemId": "<string>",
"billableMetricId": "<string>"
}
]
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"error": "conflict",
"message": "The record already has a contract for another customer",
"code": "CONTRACT_REFERENCE_CUSTOMER_MISMATCH"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Body
Response
The record already had this contract. Nothing was created.
A set of priced lines with a fixed term, owned by one customer and billed in one currency. The fields show the version in force: the last approved one, or the draft while nothing is approved yet. A change that waits for approval is in pendingChange.
draft and rejected hold while the contract was never approved. After approval the status follows the dates, on the customer's clock: scheduled before contractStart, active from it, and ended once contractEnd or terminatedAt has passed.
draft, rejected, scheduled, active, ended Was this page helpful?