> ## Documentation Index
> Fetch the complete documentation index at: https://docs.propaga.mx/llms.txt
> Use this file to discover all available pages before exploring further.

# Send User's KYC Finished Notification

> This webhook is used when the user finishes the KYC process

## Webhook Endpoint

You should configure your webhook endpoint to receive POST requests from Propaga. The webhook will send the user KYC finished notification 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 when the user finishes the KYC process:

```json theme={null}
{
  "userId": "671f75a4-f145-4f4b-82ff-4eaf0fd1e5aa",
  "cornerStoreId": "57b9d911-1c6e-45c0-be98-bfaeec8d9cf8",
  "externalId": "123456789",
  "kycStatus": "completed"
}
```

### Payload Fields

| Field           | Type   | Description                        |
| --------------- | ------ | ---------------------------------- |
| `userId`        | String | The Propaga's ID of the user.      |
| `cornerStoreId` | String | The ID of the corner store.        |
| `externalId`    | String | The ID of the user in your system. |
| `kycStatus`     | String | The status of the KYC process.     |

## Handling the Webhook

Here's an example of how to handle the webhook in different programming languages:

<CodeGroup>
  ```javascript JavaScript theme={null}
  app.post('/webhook/user-kyc-finished-notification', async (req, res) => {
    try {
      const userKYCFinishedNotification = req.body;
      
      // Process the user KYC finished notification data
      await processUserKYCFinishedNotification(userKYCFinishedNotification);
      
      // Respond with success
      res.status(200).json({ status: 'success' });
    } catch (error) {
      console.error('Error processing user KYC finished notification:', error);
      res.status(500).json({ status: 'error', message: error.message });
    }
  });

  async function processUserKYCFinishedNotification(userKYCFinishedNotification) {
    // Validate the user KYC finished notification
    console.log(`Processing user KYC finished notification: ${userKYCFinishedNotification.id}`);
    console.log(`Status: ${userKYCFinishedNotification.kycStatus}`);
    
    // Process the user KYC finished notification
    console.log(`User ID: ${userKYCFinishedNotification.userId}`);
    console.log(`External ID: ${userKYCFinishedNotification.externalId}`);
  }
  ```

  ```python Python theme={null}
  from flask import Flask, request, jsonify

  app = Flask(__name__)

  @app.route('/webhook/user-kyc-finished-notification', methods=['POST'])
  def handle_user_kyc_finished_notification():
      try:
          userKYCFinishedNotification = request.json
          
          # Process the user KYC finished notification data
          process_user_kyc_finished_notification(userKYCFinishedNotification)
          
          return jsonify({'status': 'success'}), 200
      except Exception as e:
          print(f'Error processing user KYC finished notification: {str(e)}')
          return jsonify({'status': 'error', 'message': str(e)}), 500

  def process_user_kyc_finished_notification(userKYCFinishedNotification):
      # Validate the user KYC finished notification
      print(f"Processing user KYC finished notification: {userKYCFinishedNotification['id']}")
      
      # Process the user KYC finished notification
      print(f"User ID: {userKYCFinishedNotification['userId']}")
      print(f"External ID: {userKYCFinishedNotification['externalId']}")
  ```
</CodeGroup>

## Best Practices

1. **Verify the Webhook Source**: Implement security measures to verify that the webhook is coming from Propaga.

2. **Implement Idempotency**: Store the `userId` to avoid processing the same user KYC finished notification 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.
