curl --request POST \
--url https://api.despezzas.com/v1/categorization-rules/preview \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"match_fields": [
"merchant_name"
],
"rule_id": null,
"transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
match_fields: ['merchant_name'],
rule_id: null,
transaction_id: '8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b'
})
};
fetch('https://api.despezzas.com/v1/categorization-rules/preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.despezzas.com/v1/categorization-rules/preview"
payload = {
"match_fields": ["merchant_name"],
"rule_id": None,
"transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.despezzas.com/v1/categorization-rules/preview"
payload := strings.NewReader("{\n \"match_fields\": [\n \"merchant_name\"\n ],\n \"rule_id\": null,\n \"transaction_id\": \"8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}{
"available_criteria": [
{
"field": "merchant_name",
"normalized": "pao de acucar",
"value": "Pão de Açúcar"
}
],
"is_expense": true,
"match_fields": [
"merchant_name"
],
"matching_existing_count": 14,
"source_id": "3a9e7d21-4b5c-4d6e-8f70-1a2b3c4d5e6f",
"source_kind": "ACCOUNT",
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b",
"suggested_match_fields": [
"merchant_name"
]
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}Pré-visualizar regra
Calcula os critérios disponíveis e quantos lançamentos existentes uma regra atingiria. Não grava nada — exige apenas o escopo read.
Escopo necessário: read.
curl --request POST \
--url https://api.despezzas.com/v1/categorization-rules/preview \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"match_fields": [
"merchant_name"
],
"rule_id": null,
"transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
match_fields: ['merchant_name'],
rule_id: null,
transaction_id: '8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b'
})
};
fetch('https://api.despezzas.com/v1/categorization-rules/preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.despezzas.com/v1/categorization-rules/preview"
payload = {
"match_fields": ["merchant_name"],
"rule_id": None,
"transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.despezzas.com/v1/categorization-rules/preview"
payload := strings.NewReader("{\n \"match_fields\": [\n \"merchant_name\"\n ],\n \"rule_id\": null,\n \"transaction_id\": \"8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}{
"available_criteria": [
{
"field": "merchant_name",
"normalized": "pao de acucar",
"value": "Pão de Açúcar"
}
],
"is_expense": true,
"match_fields": [
"merchant_name"
],
"matching_existing_count": 14,
"source_id": "3a9e7d21-4b5c-4d6e-8f70-1a2b3c4d5e6f",
"source_kind": "ACCOUNT",
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b",
"suggested_match_fields": [
"merchant_name"
]
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}{
"message": "Credenciais de API inválidas",
"statusCode": 401,
"error": "Unauthorized"
}Authorizations
HTTP Basic com o token como usuário e o secret como senha: curl -u dpz_tk_…:dpz_sk_…. Crie a chave em https://despezzas.com/settings/api-keys.
Body
Informe transaction_id (regra nova a partir de um lançamento) ou rule_id (regra existente); match_fields simula outros critérios.
Response
Sucesso.
Critérios disponíveis no lançamento de origem.
Show child attributes
Show child attributes
Se vale para despesas.
true
Campos considerados nesta simulação.
["merchant_name"]
Quantos lançamentos existentes a regra atingiria.
14
Id da conta ou do cartão.
"3a9e7d21-4b5c-4d6e-8f70-1a2b3c4d5e6f"
Origem.
ACCOUNT, CREDIT_CARD "ACCOUNT"
Lançamento de origem.
"8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
Campos que a API sugere.
["merchant_name"]