Cancel contract
Cancels a draft or active contract, and completes its active plan instances. For an active contract, Aira closes the current billing cycle on the day of the cancellation, prices it up to that day and moves its invoice to review, or issues it when the contract has autoIssue on, and cancels the other open billing cycles with their invoices that are not issued. Issued invoices stay as they are. The connected integrations receive the cancellation. Canceling a canceled contract leaves it as it is.
Requires the role contracts:write.
curl --request POST \
--url https://api.useaira.com/v1/contracts/{id}/cancel \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.useaira.com/v1/contracts/{id}/cancel"
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.useaira.com/v1/contracts/{id}/cancel', 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.useaira.com/v1/contracts/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.useaira.com/v1/contracts/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
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.useaira.com/v1/contracts/{id}/cancel")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useaira.com/v1/contracts/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"contractNumber": "MERCA-CTR-01",
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-12-25",
"endDate": "2023-12-25",
"retroactiveDate": "2023-12-25",
"invoicingStartDate": "2023-12-25",
"status": "active",
"rateAdjustmentIndex": "none",
"customFields": {
"customField1": "value1",
"customField2": [
"value2",
"value3"
]
},
"invoiceAllocationStrategy": "single",
"includeNewSubsidiariesOnUsageScope": true,
"usageScopes": [
{
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"allocations": [
{
"paymentAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"allocationPercentage": "50.000000"
}
],
"billingSchedule": {
"periodUnit": "week",
"anchorSource": "based_on_contract_start_date",
"anchorDay": 16
},
"planInstances": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"planId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Plano Essencial",
"status": "active"
}
],
"legalEntityId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"legalEntity": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"businessName": "Padaria Central Ltda",
"tradeName": "Padaria Central"
},
"taxRegimeId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"autoIssue": true,
"billingSettings": {
"invoiceMinimumAmount": 1,
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"paymentGatewaySettings": {
"paymentMethod": "bolepix",
"dueDateMode": "days_after_issue",
"dueOffsetDays": 1,
"dueDay": 16,
"dueMonthOffset": 0,
"rollDueDateToBusinessDay": true
}
}Response
An agreement with an individual or an organization that bills plans, each through at most one active plan instance. It holds the term, the billing schedule, the usage scope, the payment accounts and the payment conditions.
Read-only. Start date of the first billing cycle Aira invoices for this contract, recorded when it is activated: the cycle containing the retroactive date when one is set, otherwise the cycle running on the activation day, or the contract start when that is still ahead. Null while the contract is a draft.
How each billing act of the contract becomes invoices: single makes one invoice, percent_split makes one per payment account by fixed percentages, and subsidiary_usage_split makes one per payment account by the share of the usage of its customer.
single, percent_split, subsidiary_usage_split curl --request POST \
--url https://api.useaira.com/v1/contracts/{id}/cancel \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.useaira.com/v1/contracts/{id}/cancel"
headers = {"X-API-KEY": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.useaira.com/v1/contracts/{id}/cancel', 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.useaira.com/v1/contracts/{id}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.useaira.com/v1/contracts/{id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("X-API-KEY", "<api-key>")
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.useaira.com/v1/contracts/{id}/cancel")
.header("X-API-KEY", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useaira.com/v1/contracts/{id}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"contractNumber": "MERCA-CTR-01",
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-12-25",
"endDate": "2023-12-25",
"retroactiveDate": "2023-12-25",
"invoicingStartDate": "2023-12-25",
"status": "active",
"rateAdjustmentIndex": "none",
"customFields": {
"customField1": "value1",
"customField2": [
"value2",
"value3"
]
},
"invoiceAllocationStrategy": "single",
"includeNewSubsidiariesOnUsageScope": true,
"usageScopes": [
{
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"allocations": [
{
"paymentAccountId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"allocationPercentage": "50.000000"
}
],
"billingSchedule": {
"periodUnit": "week",
"anchorSource": "based_on_contract_start_date",
"anchorDay": 16
},
"planInstances": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"planId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Plano Essencial",
"status": "active"
}
],
"legalEntityId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"legalEntity": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"businessName": "Padaria Central Ltda",
"tradeName": "Padaria Central"
},
"taxRegimeId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"autoIssue": true,
"billingSettings": {
"invoiceMinimumAmount": 1,
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"paymentGatewaySettings": {
"paymentMethod": "bolepix",
"dueDateMode": "days_after_issue",
"dueOffsetDays": 1,
"dueDay": 16,
"dueMonthOffset": 0,
"rollDueDateToBusinessDay": true
}
}