Criar regra
curl --request POST \
--url https://api.despezzas.com/v1/categorization-rules \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"match_fields": [
"merchant_name"
],
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
category_id: 'b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d',
match_fields: ['merchant_name'],
source_transaction_id: '8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b'
})
};
fetch('https://api.despezzas.com/v1/categorization-rules', 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"
payload = {
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"match_fields": ["merchant_name"],
"source_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"
payload := strings.NewReader("{\n \"category_id\": \"b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d\",\n \"match_fields\": [\n \"merchant_name\"\n ],\n \"source_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))
}{
"rule": {
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"enabled": true,
"id": "d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f7a",
"is_expense": true,
"match_fields": [
"merchant_name"
],
"source_id": "3a9e7d21-4b5c-4d6e-8f70-1a2b3c4d5e6f",
"source_kind": "ACCOUNT",
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b",
"available_criteria": [
{
"field": "merchant_name",
"normalized": "pao de acucar",
"value": "Pão de Açúcar"
}
],
"createdAt": "2026-09-01T09:00:00.000Z",
"fingerprint": "sha256:4f2a…",
"profile_id": null,
"subcategory_id": "d7e8f9a0-b1c2-4d3e-8f4a-5b6c7d8e9f0a",
"updatedAt": "2026-09-15T14:32:10.000Z",
"user_id": "0d6b923c-3392-424e-a152-2ee32474e8d5"
},
"source_transaction_updated": true,
"updated_existing_count": 14
}{
"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"
}Regras de categorização
Criar regra
Cria uma regra a partir de um lançamento de origem; apply_to_existing recategoriza o histórico. Devolve a regra e o que foi recategorizado.
Escopo necessário: write.
POST
/
v1
/
categorization-rules
Criar regra
curl --request POST \
--url https://api.despezzas.com/v1/categorization-rules \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"match_fields": [
"merchant_name"
],
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
category_id: 'b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d',
match_fields: ['merchant_name'],
source_transaction_id: '8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b'
})
};
fetch('https://api.despezzas.com/v1/categorization-rules', 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"
payload = {
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"match_fields": ["merchant_name"],
"source_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"
payload := strings.NewReader("{\n \"category_id\": \"b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d\",\n \"match_fields\": [\n \"merchant_name\"\n ],\n \"source_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))
}{
"rule": {
"category_id": "b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"enabled": true,
"id": "d4e5f6a7-b8c9-4d0e-8f1a-2b3c4d5e6f7a",
"is_expense": true,
"match_fields": [
"merchant_name"
],
"source_id": "3a9e7d21-4b5c-4d6e-8f70-1a2b3c4d5e6f",
"source_kind": "ACCOUNT",
"source_transaction_id": "8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b",
"available_criteria": [
{
"field": "merchant_name",
"normalized": "pao de acucar",
"value": "Pão de Açúcar"
}
],
"createdAt": "2026-09-01T09:00:00.000Z",
"fingerprint": "sha256:4f2a…",
"profile_id": null,
"subcategory_id": "d7e8f9a0-b1c2-4d3e-8f4a-5b6c7d8e9f0a",
"updatedAt": "2026-09-15T14:32:10.000Z",
"user_id": "0d6b923c-3392-424e-a152-2ee32474e8d5"
},
"source_transaction_updated": true,
"updated_existing_count": 14
}{
"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
basicAuthapiSecret & apiToken
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
application/json
Categoria a aplicar.
Example:
"b1a2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
Campos a comparar.
Example:
["merchant_name"]
Lançamento de origem.
Example:
"8f1c2a34-5b6d-4e7f-8a9b-0c1d2e3f4a5b"
Recategoriza os lançamentos existentes que combinam. Padrão: false.
Example:
true
Subcategoria a aplicar.
Example:
"d7e8f9a0-b1c2-4d3e-8f4a-5b6c7d8e9f0a"