// Criar uma aprovação via API
const response = await fetch('https://api.nodflow.io/documents', {
method: 'POST',
headers: {
'X-Api-Key': 'nf_live_••••••••••••',
'Content-Type': 'application/json'
},
body: JSON.stringify({
flowId: 'flow_contratos',
title: 'Contrato Fornecedor XYZ',
description: 'Renovação anual — R$ 48.500',
externalId: 'ERP-2847',
webhookUrl: 'https://meu-erp.com/webhook',
metadata: { valor: 48500, cliente: 'XYZ Ltda' }
})
});
// Webhook recebido ao concluir:
// {
// status: "Approved", documentId: "doc_abc123",
// steps: [{ approver: "Carlos", decision: "Approved",
// decidedAt: "2025-03-01T14:32:00Z" }]
// }
// Create an approval via API
const response = await fetch('https://api.nodflow.io/documents', {
method: 'POST',
headers: {
'X-Api-Key': 'nf_live_••••••••••••',
'Content-Type': 'application/json'
},
body: JSON.stringify({
flowId: 'flow_contracts',
title: 'Vendor Contract XYZ',
description: 'Annual renewal — $48,500',
externalId: 'ERP-2847',
webhookUrl: 'https://my-erp.com/webhook',
metadata: { amount: 48500, client: 'XYZ Inc' }
})
});
// Webhook received on completion:
// {
// status: "Approved", documentId: "doc_abc123",
// steps: [{ approver: "Michael", decision: "Approved",
// decidedAt: "2025-03-01T14:32:00Z" }]
// }