Skip to content

Webhooks -- Overview

Webhooks allow your application to receive real-time notifications about events on the Owem Pay platform. When an event occurs, Owem Pay sends an HTTP POST to the registered URL.

How It Works

  1. Register a webhook URL in your account
  2. When an event occurs (e.g., PIX received), Owem Pay sends an HTTP POST to your URL
  3. Your application processes the notification and responds with a 2xx status (200, 201, or 204)

Available Events

EventDescription
pix.receivedPIX received in the account (cash-in confirmed)
pix.completedPIX transfer sent successfully (cash-out)
pix.failedPIX transfer failed
pix.refundPIX refund processed
pix.medMED notification received from BACEN

Security

Each notification includes security headers for validation:

HeaderDescription
X-Owem-SignatureHMAC-SHA256 signature of the payload
X-Owem-TimestampTimestamp of the delivery (ISO 8601)
X-Owem-Event-IdUnique event ID (for deduplication)
X-Owem-Event-TypeEvent type (e.g., pix.received)

Validating the Signature

Validate the signature to ensure the notification was sent by Owem Pay:

javascript
const crypto = require('crypto');

function validateWebhook(payload, timestamp, signature, secret) {
  const message = `${timestamp}.${payload}`;
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(message)
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(signature)
  );
}

Always validate

Never process a webhook without validating the signature. This protects against forged requests.

Retry Policy

If your URL returns a non-2xx status, Owem Pay performs automatic retries:

AttemptInterval
1stImmediate
2nd1 minute
3rd5 minutes
4th30 minutes
5th2 hours

After 5 unsuccessful attempts, the event is marked as failed and will not be automatically resent.

Idempotency

Your application must be idempotent: if it receives the same event more than once (identified by X-Owem-Event-Id), it should process it without duplicating effects.

Endpoint Requirements

  • The URL must use HTTPS
  • Must respond with a 2xx status within 5 seconds
  • The response body is ignored

Next Steps

Owem Pay Instituição de Pagamento — ISPB 37839059