Avistadocs
Integration Guides

Webhook Resend

Overview

The Webhook Resend endpoint allows you to request the manual resend of notifications for specific transactions. This is useful in scenarios where:

  • Your server was unavailable when the original webhook was sent
  • You need to reprocess a specific transaction
  • You want to temporarily test the integration with a different URL

This endpoint does not change your account's webhook configuration. The provided URL is used only for the specific resend.


How It Works

Transaction Identification

The endpoint accepts three types of identifiers:

TypeDescriptionScope
Numeric IDInternal transaction ID (transactionId field in webhooks)Global
External IDIdentifier provided by you at creation (externalId field)Unique per account
End-to-End IDBACEN PIX identifier (endToEndId field, format: E/D + 32 chars)Unique per transaction

The system searches simultaneously across all identifier types in your account. In practice there is no ambiguity: numeric id is purely digits; e2eId starts with 'E' or 'D' followed by 32 alphanumeric characters; externalId is any string provided by you.

Which identifier to use? Use the numeric transactionId returned by Avista, the externalId you provided at transaction creation, or the endToEndId from the PIX received in webhooks. All are equally valid.

Synchronous Processing

Webhook resend is processed synchronously. This means:

  • The request waits for the webhook delivery to complete
  • The result is communicated via HTTP status code (200, 502, 504)
  • Response time depends on your server's latency (timeout: 10s)
flowchart TD
    A[Resend Request] --> B{URL provided?}
    B -->|Yes| C[Use temporary URL]
    B -->|No| D{Webhook configured?}
    D -->|Yes| E[Use configured URL]
    D -->|No| F[Error 400: No URL]
    C --> G[Send Webhook HTTP]
    E --> G
    G --> H{Server response}
    H -->|2xx| I[HTTP 200: Success]
    H -->|4xx/5xx| J[HTTP 502: Bad Gateway]
    H -->|Timeout| K[HTTP 504: Gateway Timeout]
    I --> L[Record audit log]
    J --> L
    K --> L
    L --> M[Return result]

Unlike automatic webhooks (which use queues with retry), manual resend is executed immediately and returns the result in the same request.


Use Cases

1. Resend to Configured URL

If you already have a webhook configured on your account, simply call the endpoint without a body:

curl -X POST https://api.avista.global/api/resend-webhook/external-teste-001 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json"

2. Resend with Temporary URL

To test with a different URL or resend to a contingency endpoint:

curl -X POST https://api.avista.global/api/resend-webhook/external-teste-001 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://my-backup-server.com/webhooks/avista"
  }'

The temporary URL is not persisted. The next automatic webhook will be sent to the URL configured on the account.


Response

Success (200)

Webhook sent successfully to the destination URL.

{
  "message": "Webhook resent successfully",
  "webhookLogId": 12345,
  "sentAt": "2024-01-15T10:30:00.000Z",
  "statusCode": 200
}

Error: No URL Configured (400)

{
  "statusCode": 400,
  "message": "No webhook configured and no override URL provided",
  "error": "Bad Request"
}

Error: Transaction Not Found (404)

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

Error: Destination Returned Error (502)

The destination server returned an error (4xx or 5xx) or there was a connection failure.

{
  "statusCode": 502,
  "message": "Webhook failed with status 500",
  "webhookLogId": 12345,
  "sentAt": "2024-01-15T10:30:00.000Z"
}

Even in case of error, the webhook is recorded in the audit log. Use the webhookLogId for tracking.

Error: Timeout (504)

The destination server did not respond within the time limit (10 seconds).

{
  "statusCode": 504,
  "message": "Timeout after 10000ms",
  "webhookLogId": 12345,
  "sentAt": "2024-01-15T10:30:00.000Z"
}

If you are experiencing frequent timeouts, check that your server responds in less than 10 seconds.


Rate Limiting

This endpoint has rate limiting of 60 requests per minute per account to prevent abuse.

If the limit is exceeded, you will receive a 429 Too Many Requests error:

{
  "statusCode": 429,
  "message": "Too Many Requests"
}

Auditing

All manual resends are recorded for auditing and traceability purposes:

InformationDescription
Send typeMarked as manual resend
URL usedRecords whether temporary or configured URL was used
ResultHTTP status and response time
IdentifierUnique log ID for tracking

Use the webhookLogId returned in the response to correlate with support logs if needed.


Integration Examples

const axios = require('axios');

async function resendWebhook(transactionId, overrideUrl = null) {
  const config = {
    headers: {
      'Authorization': `Bearer ${process.env.AVISTA_TOKEN}`,
      'Content-Type': 'application/json'
    }
  };

  const body = overrideUrl ? { url: overrideUrl } : {};

  try {
    const response = await axios.post(
      `https://api.avista.global/api/resend-webhook/${transactionId}`,
      body,
      config
    );

    console.log('Webhook resent:', response.data);
    return response.data;
  } catch (error) {
    console.error('Error resending webhook:', error.response?.data);
    throw error;
  }
}

// Usage
resendWebhook('external-teste-001');
resendWebhook('external-teste-001', 'https://backup.mysite.com/webhook'); // With temporary URL
import requests
import os

def resend_webhook(transaction_id: str, override_url: str = None):
    headers = {
        'Authorization': f'Bearer {os.environ["AVISTA_TOKEN"]}',
        'Content-Type': 'application/json'
    }

    body = {'url': override_url} if override_url else {}

    response = requests.post(
        f'https://api.avista.global/api/resend-webhook/{transaction_id}',
        json=body,
        headers=headers
    )

    response.raise_for_status()
    return response.json()

# Usage
result = resend_webhook('external-teste-001')
print(f"Webhook resent: {result}")

# With temporary URL
result = resend_webhook('external-teste-001', 'https://backup.mysite.com/webhook')
using System.Net.Http;
using System.Text;
using System.Text.Json;

public class AvistaClient
{
    private readonly HttpClient _client;
    private readonly string _token;

    public AvistaClient(string token)
    {
        _client = new HttpClient();
        _token = token;
        _client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_token}");
    }

    public async Task<ResendWebhookResponse> ResendWebhookAsync(
        string transactionId,
        string overrideUrl = null)
    {
        var url = $"https://api.avista.global/api/resend-webhook/{transactionId}";

        var body = overrideUrl != null
            ? JsonSerializer.Serialize(new { url = overrideUrl })
            : "{}";

        var content = new StringContent(body, Encoding.UTF8, "application/json");

        var response = await _client.PostAsync(url, content);
        response.EnsureSuccessStatusCode();

        var json = await response.Content.ReadAsStringAsync();
        return JsonSerializer.Deserialize<ResendWebhookResponse>(json);
    }
}

Next Steps

On this page