Skip to main content

Webhook Endpoint

You should configure your webhook endpoint to receive POST requests from Propaga. The webhook will send the credit limit update data in JSON format. Please contact us to set up the webhook.

Payload Structure

Here’s an example of the webhook payload you’ll receive:
{
  "userId": "671f75a4-f145-4f4b-82ff-4eaf0fd1e5aa",
  "cornerStoreId": "57b9d911-1c6e-45c0-be98-bfaeec8d9cf8",
  "externalId": "123456789",
  "newCreditLimit": 1000
}

Payload Fields

FieldTypeDescription
userIdStringThe Propaga’s ID of the user.
cornerStoreIdStringThe ID of the corner store.
externalIdStringThe ID of the user in your system.
newCreditLimitNumberThe new credit limit of the user.

Handling the Webhook

Here’s an example of how to handle the webhook in different programming languages:
app.post('/webhook/credit-limit-update', async (req, res) => {
  try {
    const creditLimitUpdate = req.body;
    
    // Process the credit limit update data
    await processCreditLimitUpdate(creditLimitUpdate);
    
    // Respond with success
    res.status(200).json({ status: 'success' });
  } catch (error) {
    console.error('Error processing credit limit update:', error);
    res.status(500).json({ status: 'error', message: error.message });
  }
});

async function processCreditLimitUpdate(creditLimitUpdate) {
  // Validate the credit limit update
  console.log(`Processing credit limit update: ${creditLimitUpdate.id}`);
  console.log(`Status: ${creditLimitUpdate.status}`);
  
  // Process each transaction
  console.log(`User ID: ${creditLimitUpdate.userId}`);
  console.log(`External ID: ${creditLimitUpdate.externalId}`);
}

Best Practices

  1. Verify the Webhook Source: Implement security measures to verify that the webhook is coming from Propaga.
  2. Implement Idempotency: Store the referenceNumber to avoid processing the same conciliation multiple times.
  3. Handle Errors Gracefully: Implement proper error handling and logging to track any issues with webhook processing.
  4. Respond Quickly: Your webhook endpoint should respond as quickly as possible. If processing takes time, handle it asynchronously.
  5. Validate Data: Always validate the incoming data before processing it.