Create a Tenant Classification Rule
Create a tenant rule that categorizes and tags matching transactions across the tenant’s businesses.
Scopes: tenant:update
curl --request POST \
--url https://api.sandbox.getasset.com/v0/tenant/rules/classifications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"classifications": [
{
"target_ledger_name": "Software Expenses",
"conditions": {
"amount": {
"value": 100,
"max_value": 250
},
"date": {
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"splits": [
{
"ledger_name": "Sales Tax Payable",
"percentage": 8.875
},
{
"ledger_name": "Bank Fees",
"percentage": 10
}
],
"tags": {
"Job": [
{
"percentage": 60,
"value": "Maple Street Remodel"
},
{
"percentage": 40,
"value": "Oak Avenue Deck"
}
],
"Location": "NYC"
}
}
],
"merchant": "Starbucks",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"auto_confirm": false
}
'import requests
url = "https://api.sandbox.getasset.com/v0/tenant/rules/classifications"
payload = {
"classifications": [
{
"target_ledger_name": "Software Expenses",
"conditions": {
"amount": {
"value": 100,
"max_value": 250
},
"date": {
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"splits": [
{
"ledger_name": "Sales Tax Payable",
"percentage": 8.875
},
{
"ledger_name": "Bank Fees",
"percentage": 10
}
],
"tags": {
"Job": [
{
"percentage": 60,
"value": "Maple Street Remodel"
},
{
"percentage": 40,
"value": "Oak Avenue Deck"
}
],
"Location": "NYC"
}
}
],
"merchant": "Starbucks",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"auto_confirm": False
}
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({
classifications: [
{
target_ledger_name: 'Software Expenses',
conditions: {
amount: {value: 100, max_value: 250},
date: {value: '2023-12-25', max_value: '2023-12-25'}
},
splits: [
{ledger_name: 'Sales Tax Payable', percentage: 8.875},
{ledger_name: 'Bank Fees', percentage: 10}
],
tags: {
Job: [
{percentage: 60, value: 'Maple Street Remodel'},
{percentage: 40, value: 'Oak Avenue Deck'}
],
Location: 'NYC'
}
}
],
merchant: 'Starbucks',
description_value: 'MONTHLY SOFTWARE SUBSCRIPTION',
auto_confirm: false
})
};
fetch('https://api.sandbox.getasset.com/v0/tenant/rules/classifications', 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.sandbox.getasset.com/v0/tenant/rules/classifications",
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([
'classifications' => [
[
'target_ledger_name' => 'Software Expenses',
'conditions' => [
'amount' => [
'value' => 100,
'max_value' => 250
],
'date' => [
'value' => '2023-12-25',
'max_value' => '2023-12-25'
]
],
'splits' => [
[
'ledger_name' => 'Sales Tax Payable',
'percentage' => 8.875
],
[
'ledger_name' => 'Bank Fees',
'percentage' => 10
]
],
'tags' => [
'Job' => [
[
'percentage' => 60,
'value' => 'Maple Street Remodel'
],
[
'percentage' => 40,
'value' => 'Oak Avenue Deck'
]
],
'Location' => 'NYC'
]
]
],
'merchant' => 'Starbucks',
'description_value' => 'MONTHLY SOFTWARE SUBSCRIPTION',
'auto_confirm' => false
]),
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.sandbox.getasset.com/v0/tenant/rules/classifications"
payload := strings.NewReader("{\n \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\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.sandbox.getasset.com/v0/tenant/rules/classifications")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.getasset.com/v0/tenant/rules/classifications")
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 \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "clr_GA6EG2qFxA97NZHtxeLPUy",
"classifications": [
{
"conditions": {
"amount": {
"operator": "equals",
"value": 100,
"max_value": 250
},
"direction": "money_in",
"date": {
"operator": "equals",
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"target_ledger_name": "<string>",
"splits": [
{
"ledger_name": "<string>",
"percentage": 123
}
],
"tags": {}
}
],
"auto_confirm": true,
"is_active": true,
"match_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"merchant": "Starbucks",
"description_match_type": "contains",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"last_matched_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
- Token URL
- /v0/auth/token
Body
Classifications evaluated in order against matching transactions. Categorization applies the first one whose conditions match and whose ledger name the business has; tagging applies, per tag field, the first one whose conditions match and that sets the field. A classification with no conditions matches every transaction.
1Show child attributes
Show child attributes
Case-insensitive exact merchant name to match. Mutually exclusive with the description criterion; exactly one of the two is required.
255"Starbucks"
How to match the transaction description.
contains, not_contains, equals Description text to match, case-insensitive.
512"MONTHLY SOFTWARE SUBSCRIPTION"
Whether journal entries created from matching transactions are confirmed without manual review.
Response
Successful Response
The id of the classification rule
"clr_GA6EG2qFxA97NZHtxeLPUy"
Classifications evaluated in order. Categorization applies the first one whose conditions match and whose ledger name the business has; tagging applies, per tag field, the first one whose conditions match and that sets the field.
Show child attributes
Show child attributes
Whether the rule takes part in categorization and tagging.
Number of transactions the rule has matched.
Case-insensitive exact merchant name to match. Mutually exclusive with the description criterion; exactly one of the two is required.
255"Starbucks"
How to match the transaction description.
contains, not_contains, equals Description text to match, case-insensitive.
512"MONTHLY SOFTWARE SUBSCRIPTION"
When the rule last matched a transaction.
curl --request POST \
--url https://api.sandbox.getasset.com/v0/tenant/rules/classifications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"classifications": [
{
"target_ledger_name": "Software Expenses",
"conditions": {
"amount": {
"value": 100,
"max_value": 250
},
"date": {
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"splits": [
{
"ledger_name": "Sales Tax Payable",
"percentage": 8.875
},
{
"ledger_name": "Bank Fees",
"percentage": 10
}
],
"tags": {
"Job": [
{
"percentage": 60,
"value": "Maple Street Remodel"
},
{
"percentage": 40,
"value": "Oak Avenue Deck"
}
],
"Location": "NYC"
}
}
],
"merchant": "Starbucks",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"auto_confirm": false
}
'import requests
url = "https://api.sandbox.getasset.com/v0/tenant/rules/classifications"
payload = {
"classifications": [
{
"target_ledger_name": "Software Expenses",
"conditions": {
"amount": {
"value": 100,
"max_value": 250
},
"date": {
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"splits": [
{
"ledger_name": "Sales Tax Payable",
"percentage": 8.875
},
{
"ledger_name": "Bank Fees",
"percentage": 10
}
],
"tags": {
"Job": [
{
"percentage": 60,
"value": "Maple Street Remodel"
},
{
"percentage": 40,
"value": "Oak Avenue Deck"
}
],
"Location": "NYC"
}
}
],
"merchant": "Starbucks",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"auto_confirm": False
}
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({
classifications: [
{
target_ledger_name: 'Software Expenses',
conditions: {
amount: {value: 100, max_value: 250},
date: {value: '2023-12-25', max_value: '2023-12-25'}
},
splits: [
{ledger_name: 'Sales Tax Payable', percentage: 8.875},
{ledger_name: 'Bank Fees', percentage: 10}
],
tags: {
Job: [
{percentage: 60, value: 'Maple Street Remodel'},
{percentage: 40, value: 'Oak Avenue Deck'}
],
Location: 'NYC'
}
}
],
merchant: 'Starbucks',
description_value: 'MONTHLY SOFTWARE SUBSCRIPTION',
auto_confirm: false
})
};
fetch('https://api.sandbox.getasset.com/v0/tenant/rules/classifications', 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.sandbox.getasset.com/v0/tenant/rules/classifications",
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([
'classifications' => [
[
'target_ledger_name' => 'Software Expenses',
'conditions' => [
'amount' => [
'value' => 100,
'max_value' => 250
],
'date' => [
'value' => '2023-12-25',
'max_value' => '2023-12-25'
]
],
'splits' => [
[
'ledger_name' => 'Sales Tax Payable',
'percentage' => 8.875
],
[
'ledger_name' => 'Bank Fees',
'percentage' => 10
]
],
'tags' => [
'Job' => [
[
'percentage' => 60,
'value' => 'Maple Street Remodel'
],
[
'percentage' => 40,
'value' => 'Oak Avenue Deck'
]
],
'Location' => 'NYC'
]
]
],
'merchant' => 'Starbucks',
'description_value' => 'MONTHLY SOFTWARE SUBSCRIPTION',
'auto_confirm' => false
]),
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.sandbox.getasset.com/v0/tenant/rules/classifications"
payload := strings.NewReader("{\n \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\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.sandbox.getasset.com/v0/tenant/rules/classifications")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.getasset.com/v0/tenant/rules/classifications")
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 \"classifications\": [\n {\n \"target_ledger_name\": \"Software Expenses\",\n \"conditions\": {\n \"amount\": {\n \"value\": 100,\n \"max_value\": 250\n },\n \"date\": {\n \"value\": \"2023-12-25\",\n \"max_value\": \"2023-12-25\"\n }\n },\n \"splits\": [\n {\n \"ledger_name\": \"Sales Tax Payable\",\n \"percentage\": 8.875\n },\n {\n \"ledger_name\": \"Bank Fees\",\n \"percentage\": 10\n }\n ],\n \"tags\": {\n \"Job\": [\n {\n \"percentage\": 60,\n \"value\": \"Maple Street Remodel\"\n },\n {\n \"percentage\": 40,\n \"value\": \"Oak Avenue Deck\"\n }\n ],\n \"Location\": \"NYC\"\n }\n }\n ],\n \"merchant\": \"Starbucks\",\n \"description_value\": \"MONTHLY SOFTWARE SUBSCRIPTION\",\n \"auto_confirm\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "clr_GA6EG2qFxA97NZHtxeLPUy",
"classifications": [
{
"conditions": {
"amount": {
"operator": "equals",
"value": 100,
"max_value": 250
},
"direction": "money_in",
"date": {
"operator": "equals",
"value": "2023-12-25",
"max_value": "2023-12-25"
}
},
"target_ledger_name": "<string>",
"splits": [
{
"ledger_name": "<string>",
"percentage": 123
}
],
"tags": {}
}
],
"auto_confirm": true,
"is_active": true,
"match_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"merchant": "Starbucks",
"description_match_type": "contains",
"description_value": "MONTHLY SOFTWARE SUBSCRIPTION",
"last_matched_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}{
"error": "<string>",
"data": "<unknown>"
}