Skip to content

Consultar Saque ​

Consulta os detalhes de um saque específico.

GET /api/withdraws/ ​

Endpoint ​

GET https://api.divipay.com.br/api/withdraws/{id}

Headers ​

HeaderValorObrigatório
AuthorizationBearerSim

Path Parameters ​

ParâmetroTipoDescrição
idstringID do saque

Query Parameters ​

ParâmetroTipoDescriçãoObrigatório
customerIdstringID da sub-contaNão

Exemplo de Requisição ​

bash
curl -X GET https://api.divipay.com.br/api/withdraws/3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301 \
  -H "Authorization: Bearer SEU_TOKEN"
javascript
const response = await fetch(
  'https://api.divipay.com.br/api/withdraws/3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301',
  {
    headers: {
      'Authorization': 'Bearer SEU_TOKEN'
    }
  }
);

const withdraw = await response.json();
python
import requests

response = requests.get(
    'https://api.divipay.com.br/api/withdraws/3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301',
    headers={
        'Authorization': 'Bearer SEU_TOKEN'
    }
)

withdraw = response.json()

Resposta de Sucesso ​

Status: 200 OK

json
{
  "id": "3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301",
  "status": "FINISHED",
  "amount": 500.00,
  "fee": 1.50,
  "type": "DICT",
  "description": "Saque via Pix",
  "createdAt": "2024-11-04T15:00:00.000Z",
  "customerId": "5a4c2b18-8f01-49cc-9e3d-2b3b7f1d4e66",
  "fileName": null,
  "billetCode": null,
  "endToEndId": "E12345678202411041600abcdef12345",
  "recipient": {
    "name": "ACME COMERCIO LTDA",
    "document": "12345678000190",
    "pixKey": "financeiro@acme.com.br",
    "ispb": null,
    "agency": null,
    "account": null
  }
}

O bloco recipient (favorecido/beneficiário) é o mesmo da listagem: veja Favorecido.

Status do Saque ​

StatusDescrição
PENDINGAguardando processamento
PROCESSINGEm processamento
FINISHEDConcluído
CANCELEDCancelado

Tipos de Saque ​

TipoDescrição
DICTSaque via Chave Pix
MANUSaque via Dados Bancários
BILLETPagamento de Boleto

Exemplo de Uso ​

Verificar Status ​

javascript
async function checkWithdrawStatus(withdrawId) {
  try {
    const response = await fetch(
      `https://api.divipay.com.br/api/withdraws/${withdrawId}`,
      {
        headers: { 'Authorization': `Bearer ${token}` }
      }
    );

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}`);
    }

    const withdraw = await response.json();

    switch (withdraw.status) {
      case 'PENDING':
        console.log('⏳ Saque pendente');
        break;
      case 'PROCESSING':
        console.log('🔄 Saque em processamento');
        break;
      case 'FINISHED':
        console.log('✅ Saque concluído');
        console.log('Concluído em:', withdraw.completedAt);
        break;
      case 'CANCELED':
        console.log('❌ Saque cancelado');
        break;
      default:
        console.log('❓ Status desconhecido:', withdraw.status);
    }

    return withdraw;

  } catch (error) {
    console.error('Erro ao consultar saque:', error);
    throw error;
  }
}

// Uso
const withdraw = await checkWithdrawStatus('3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301');

Aguardar Conclusão ​

javascript
async function waitForWithdraw(withdrawId, maxAttempts = 60) {
  for (let i = 0; i < maxAttempts; i++) {
    const withdraw = await checkWithdrawStatus(withdrawId);

    if (withdraw.status === 'FINISHED') {
      console.log('✅ Saque concluído!');
      return withdraw;
    }

    if (withdraw.status === 'CANCELED') {
      throw new Error('Saque foi cancelado');
    }

    console.log(`Tentativa ${i + 1}/${maxAttempts} - Status: ${withdraw.status}`);
    
    // Aguardar 10 segundos
    await new Promise(resolve => setTimeout(resolve, 10000));
  }

  throw new Error('Timeout aguardando conclusão do saque');
}

// Uso
try {
  const withdraw = await waitForWithdraw('3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301');
  console.log('Saque finalizado:', withdraw);
} catch (error) {
  console.error('Erro:', error.message);
}

ATENÇÃO

Evite polling excessivo. Use webhooks para receber notificações em tempo real.

Exibir Detalhes ​

javascript
function displayWithdrawDetails(withdraw) {
  const typeNames = {
    'DICT': 'Chave Pix',
    'MANU': 'Dados Bancários',
    'BILLET': 'Boleto'
  };

  const statusNames = {
    'PENDING': 'Pendente',
    'PROCESSING': 'Processando',
    'FINISHED': 'Concluído',
    'CANCELED': 'Cancelado'
  };

  return `
    ID: ${withdraw.id}
    Valor: R$ ${withdraw.amount.toFixed(2)}
    Tipo: ${typeNames[withdraw.type]}
    Status: ${statusNames[withdraw.status]}
    Criado em: ${new Date(withdraw.createdAt).toLocaleString()}
    ${withdraw.completedAt ? `Concluído em: ${new Date(withdraw.completedAt).toLocaleString()}` : ''}
  `;
}

// Uso
const withdraw = await checkWithdrawStatus('3b2f09c7-99f0-4a6e-9ea5-6a497bb7f301');
console.log(displayWithdrawDetails(withdraw));

Interface de Detalhes ​

javascript
// React Component
function WithdrawDetails({ withdrawId }) {
  const [withdraw, setWithdraw] = useState(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    loadWithdraw();
  }, [withdrawId]);

  async function loadWithdraw() {
    setLoading(true);
    try {
      const data = await checkWithdrawStatus(withdrawId);
      setWithdraw(data);
    } catch (error) {
      console.error('Erro ao carregar saque:', error);
    } finally {
      setLoading(false);
    }
  }

  if (loading) return <div>Carregando...</div>;
  if (!withdraw) return <div>Saque não encontrado</div>;

  const statusColors = {
    'PENDING': 'orange',
    'PROCESSING': 'blue',
    'FINISHED': 'green',
    'CANCELED': 'red'
  };

  return (
    <div>
      <h2>Detalhes do Saque</h2>
      
      <div>
        <strong>ID:</strong> {withdraw.id}
      </div>
      
      <div>
        <strong>Valor:</strong> R$ {withdraw.amount.toFixed(2)}
      </div>
      
      <div>
        <strong>Tipo:</strong> {withdraw.type}
      </div>
      
      <div>
        <strong>Status:</strong>
        <span style={{ 
          color: statusColors[withdraw.status],
          fontWeight: 'bold'
        }}>
          {withdraw.status}
        </span>
      </div>
      
      <div>
        <strong>Criado em:</strong> {new Date(withdraw.createdAt).toLocaleString()}
      </div>
      
      {withdraw.completedAt && (
        <div>
          <strong>Concluído em:</strong> {new Date(withdraw.completedAt).toLocaleString()}
        </div>
      )}

      <button onClick={loadWithdraw}>
        Atualizar
      </button>
    </div>
  );
}

Respostas de Erro ​

404 Not Found ​

Saque não encontrado.

json
{
  "statusCode": 404,
  "message": "Withdraw not found",
  "error": "Not Found"
}

403 Forbidden ​

Sem permissão para acessar o saque.

json
{
  "statusCode": 403,
  "message": "Forbidden"
}

Próximos Passos ​

Documentação da API DiviPay