Gifts Duplication Detection

Overview:

Using a unique key for each gift will enhances the reliability of API calls by preventing duplicate gift submissions within the same API call or across multiple calls. This documentation outlines how to utilize and benefit from this feature effectively.

Why Use This Feature?

  • Prevent Duplicates: Each gift is associated with a unique key, ensuring that duplicate submissions are automatically detected and rejected.
  • Create an effective retry mechanism: Safely implement a retry mechanism for failed calls, knowing no duplicated gifts will be created.

How to Use:

  1. Generate Unique Keys: Before sending each gift, generate a unique key using a reliable method such as UUID (Universally Unique Identifier) generation or based on company logic - e.g. recipientId + date + campaignId (This will ensure each recipient gets only one gift for this campaign each day)
  2. Include Unique Key in create gifts API Requests: For each recipient add the key field as part of the API request payload.
    {
      "campaignId": "12345",
      "recipients": [
        {
          "firstname": "John",
          "lastname": "Doe",
          "externalId": "abc123",
          "phone": 1999999999,
          "email": "[email protected]",
          "key": "123456"
        },
        {
          "firstname": "Jane",
          "lastname": "Doe",
          "externalId": "def456",
          "email": "[email protected]",
          "key": "987654"
        }
      ],
      "sendingMethod": "mailAndSms"
    }
    
  3. Handling Errors: If a duplicate key is detected, the API will return an appropriate error response with errorCode=41008.
    Note: As the key is unique per each gift separately, you might receive a partial success response
{
    “results”: [
        {
            “success”: false,
            “message”: “According to the unique key, this gift was detected as a duplicated gift.“,
            “errorCode”: 41008
        },
        {
            “success”: false,
            “message”: “According to the unique key, this gift was detected as a duplicated gift.“,
            “errorCode”: 41008
        },
        {
            “success”: true,
            “link”: “https://web-dev.snappygifts.com/abc123”,
            “id”: “abc123”
        },
        {
            “success”: true,
            “link”: “https://web-dev.snappygifts.com/efg456”,
            “id”: “efg456”
        },
        {
            “success”: true,
            “link”: “https://web-dev.snappygifts.com/hij789”,
            “id”: “hij789”
        }
    ],
    “message”: “3 gifts out of 5 have been sent successfully.”
}