Missing contact type when trying to add multiple contacts to a Wallet

Hi Everyone!

I’ve been trying to add some contacts to a wallet I created recently. Currently, I’m using sandbox environment.
Following the documentation here, I am repeatedly getting this error response:

{
    "status": {
        "error_code": "MISSING_EWALLET_CONTACT_TYPE",
        "status": "ERROR",
        "message": "The request tried to create or update a wallet contact, but the 'contact_type' was missing. The request was rejected. Corrective action: Set 'contact_type' to one of the following values: 'personal', 'business'",
        "response_code": "MISSING_EWALLET_CONTACT_TYPE",
        "operation_id": "fdc9b277-ddde-4fad-b3eb-df8113b59f1c"
    }
}

For the API call, this is my url:
/v1/ewallets/${ewalletId}/contacts
ewalletId is a variable that was created by calling create wallet API.

And, this is the body:

{
      "first_name": "Jane",
      "last_name": "Doe",
      "middle_name": "",
      "second_last_name": "",
      "mothers_name": "Jane Smith",
      "gender": "female",
      "marital_status": "single",
      "house_type": "lease",
      "contact_type": "personal",
      "phone_number": "+14155551233",
      "email": "jane200@rapyd.net",
      "identification_type": "PA",
      "identification_number": "1233242424",
      "date_of_birth": "11/22/2000",
      "country": "US",
      "nationality": "FR",
      "address": {
          "name": "Jane Doe",
          "line_1": "123 Lake Forest Drive",
          "line_2": "",
          "line_3": "",
          "city": "Anytown",
          "state": "NY",
          "zip": "12345",
          "phone_number": "+14155551234",
          "metadata": {
              "merchant_defined": true
          },
          "canton": "",
          "district": ""
      },
      "metadata": {
          "merchant_defined": true
      }
  }

I’ve checked the signature and other header fields. I was able to create a wallet, do a test API call on the fetching list of countries as given in the documentation.

Please let me know how to fix this. Thanks!!

Hi @Shikhar_Vaish I was using the body you shared above and no error appear on my end, the reason is that I’ve never added the contact with the same details to that wallet. So very likely, when creating the wallet, a contact is already created and the same details are used, so when you create an additional one, it causes conflict.

My suggestion is to run Wallet Contact Object as to retrieve the existing contacts created under the wallet to see if the contract you want to create is already there.

Good luck with that and let us know in case of any further questions.

1 Like

I’m having trouble reproducing this error. I’ve tried several variations and can’t get this specific error.

First of all, you can only add a contact to a company wallet, and the contact type is not specified as part of the request. This is because there is only one business contact, and the only type of contact you can add is a personal contact.

When you create your company wallet, you must make sure the ‘email’, ‘phone_number’ and ‘ewallet_reference_id’ at the root of the request are unique - have not been used before. Please try again and let me know what results you get.

Hi Charles! Thanks for the info. I had been using duplicate details.

I added a random input generator to make the demo API calls. I noticed null fields in response when I create a company wallet. Here are the details when I create a “company” ewallet having a “business” contact:
API url /v1/user

Request Body

const body = {
      first_name: 'Shikhar',
      last_name: 'Vaish',
      ewallet_reference_id: `Shikhar-${uniqueNum1}-${uniqueNum2}`,
      metadata: {
        merchant_defined: true
      },
      type: 'company',
      contact: {
        phone_number: phoneNum1,
        email: email1,
        first_name: 'Shikhar',
        last_name: 'Vaish',
        mothers_name: 'Jane Smith',
        contact_type: 'business',
        address: {
          name: 'Shikhar Vaish',
          line_1: '123 Main Street',
          line_2: '',
          line_3: '',
          city: 'Anytown',
          state: 'NY',
          country: 'US',
          zip: '12345',
          phone_number: phoneNum2,
          metadata: { number: 2 },
          canton: '',
          district: ''
        },
        identification_type: 'PA',
        identification_number: identificationNum1,
        date_of_birth: '11/22/2000',
        country: 'US',
        metadata: {
          merchant_defined: true
        },
        business_details: {
          entity_type: 'association',
          name: 'Four Star Professional Services',
          registration_number: identificationNum2,
          industry_category: 'company',
          industry_sub_category: 'home services',
          address: {
            name: 'John Doe',
            line_1: '1234 Main Street',
            line_2: 'Suite 1200',
            line_3: '',
            city: 'Anytown',
            state: 'NY',
            country: 'US',
            zip: '10101',
            phone_number: phoneNum3,
            metadata: {
              merchant_defined: true
            }
          }
        }
      }
    };

API Response:

{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "2a140df5-e8c6-4261-b182-e5d9ba15cdad"
    },
    "data": {
        "phone_number": null,
        "email": null,
        "first_name": null,
        "last_name": null,
        "id": "ewallet_1de586d02ef1141974162e7515be1d98",
        "status": "ACT",
        "accounts": [],
        "verification_status": "not verified",
        "type": "person",
        "metadata": {},
        "ewallet_reference_id": null,
        "category": null,
        "contacts": {
            "data": [
                {
                    "id": "cont_8d441499bc88d9d79d6ba2087d70f0c4",
                    "first_name": "",
                    "last_name": "",
                    "middle_name": "",
                    "second_last_name": "",
                    "gender": "not_applicable",
                    "marital_status": "not_applicable",
                    "house_type": "",
                    "contact_type": "personal",
                    "phone_number": "",
                    "email": "",
                    "identification_type": "",
                    "identification_number": "",
                    "preferred_name": "",
                    "date_of_birth": null,
                    "country": "",
                    "nationality": null,
                    "address": null,
                    "ewallet": "ewallet_1de586d02ef1141974162e7515be1d98",
                    "created_at": 1623315091,
                    "metadata": {},
                    "business_details": null,
                    "compliance_profile": 0,
                    "verification_status": "not verified",
                    "send_notifications": false,
                    "mothers_name": ""
                }
            ],
            "has_more": false,
            "total_count": 1,
            "url": "/v1/ewallets/ewallet_1de586d02ef1141974162e7515be1d98/contacts"
        }
    }
}

Random Inputs

  • The phone numbers are of the following format: “+1<10-digit random number>”
  • The identification number is of the following format: “<10-digit random number>”
  • The ewallet_reference_id is “Shikhar-<2-digit random number>-<2-digit random number>”
  • The email is of the following format: “shikhar.vaish<4-digit random number>@gmail.com”

With ewallet and contactIds as exceptions, other details are null. Also, contact_type is personal instead of business.

The wallets created are getting reflected on my web dashboard with matching Ids.

@Xi_Li I tried using the get contact, and get list of contacts API for the wallet. I get the single contact as above, that was created at the time of creating a wallet. And, it has “personal” type instead of “business” type.

Hi again. Again, I can’t make the API reproduce this. Let me suggest something - Why not start out by putting in only the required fields, then adding non-required fields one by one? Stepping through it like this will help pinpoint the trouble spot.

Personally, I don’t see any advantage to putting the phone number on the wallet itself, since each contact has his own phone number anyway. Same with the email. I’m puzzled, though, about why the first_name and last_name are not being returned in the response.

Hi!
Okay. I just tried reducing the params…

Body

const uniqueNum1 = `${Date.now()}` // Javascript's Date object
const uniqueNum2 = `${Date.now()}`
const body ={
      contact: {
        contact_type: 'business',
        country: 'US',
        email:  `shikhar.vaish${uniqueNum1%100}${uniqueNum2%100}@gmail.com`,
        first_name: 'Shikhar',       
        identification_number: `942${uniqueNum1%100}116${uniqueNum2%100}`,
        identification_type: 'PA',
        last_name: 'Vaish',
        phone_number: `+1812${uniqueNum1%100}307${uniqueNum2%100}`,
        
      },
      ewallet_reference_id: `Shikhar-${uniqueNum1}-${uniqueNum2}`,
      first_name: 'Shikhar',
      last_name: 'Vaish',
      type: 'company',
    };

Response

{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "9bf5bc16-a4fe-481e-bd6f-0c71bed9dc2e"
    },
    "data": {
        "phone_number": null,
        "email": null,
        "first_name": null,
        "last_name": null,
        "id": "ewallet_f760992b34f1c4c0d2ff68e673ea1078",
        "status": "ACT",
        "accounts": [],
        "verification_status": "not verified",
        "type": "person",
        "metadata": {},
        "ewallet_reference_id": null,
        "category": null,
        "contacts": {
            "data": [
                {
                    "id": "cont_a13fff6bde3f233ca46cbc99717f010f",
                    "first_name": "",
                    "last_name": "",
                    "middle_name": "",
                    "second_last_name": "",
                    "gender": "not_applicable",
                    "marital_status": "not_applicable",
                    "house_type": "",
                    "contact_type": "personal",
                    "phone_number": "",
                    "email": "",
                    "identification_type": "",
                    "identification_number": "",
                    "preferred_name": "",
                    "date_of_birth": null,
                    "country": "",
                    "nationality": null,
                    "address": null,
                    "ewallet": "ewallet_f760992b34f1c4c0d2ff68e673ea1078",
                    "created_at": 1623326775,
                    "metadata": {},
                    "business_details": null,
                    "compliance_profile": 0,
                    "verification_status": "not verified",
                    "send_notifications": false,
                    "mothers_name": ""
                }
            ],
            "has_more": false,
            "total_count": 1,
            "url": "/v1/ewallets/ewallet_f760992b34f1c4c0d2ff68e673ea1078/contacts"
        }
    }
}

Headers:

const timestamp = (Math.floor(new Date().getTime() / 1000) - 10).toString()
    const salt = Date.now() + ''
    const http_method = 'post';
    const url_path = '/v1/user'
    const secret_key = config.secret_key
    const access_key = config.access_key
    const body_string = ''
    
    const to_sign = http_method + url_path + salt + timestamp + access_key + secret_key + body_string
    let signature = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(to_sign, secret_key));
    signature = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(signature));
    
    const headers = {
      'content-type': 'application/json',
      'access_key': access_key,
      'salt': salt,
      'signature': signature,
      'timestamp': timestamp
    }

Hello,
I tried to run a very similar request on my sandbox via Postman and did not receive null values in the contact’s first and last name. The response also includes the correct contact type.
Here is the code. Please try it yourself and let me know if you still get null values and the wrong contact type.

curl --location --request POST 'https://sandboxapi.rapyd.net/v1/user' \
{
    "first_name": "Shikhar",
    "last_name": "Vaish",
    "ewallet_reference_id": "Shikhar1",
    "metadata": {
        "merchant_defined": true
    },
    "type": "company",
    "contact": {
        "phone_number": "+14155551311",
        "email": "1234email1@sample.net",
        "first_name": "Shikhar",
        "last_name": "Vaish",
        "mothers_name": "Jane Smith",
        "contact_type": "business",
        "address": {
            "name": "Shikhar Vaish",
            "line_1": "123 Main Street",
            "line_2": "",
            "line_3": "",
            "city": "Anytown",
            "state": "NY",
            "country": "US",
            "zip": "12345",
            "phone_number": "+14155551312",
            "metadata": {
                "merchant_defined": true
            },
            "canton": "",
            "district": ""
        },
        "identification_type": "PA",
        "identification_number": "identificationNum1",
        "date_of_birth": "11/22/2000",
        "country": "US",
        "metadata": {
            "merchant_defined": true
        },
        "business_details": {
            "entity_type": "association",
            "name": "Four Star Professional Services",
            "registration_number": "identificationNum2",
            "industry_category": "company",
            "industry_sub_category": "home services",
            "address": {
                "name": "John Doe",
                "line_1": "1234 Main Street",
                "line_2": "Suite 1200",
                "line_3": "",
                "city": "Anytown",
                "state": "NY",
                "country": "US",
                "zip": "10101",
                "phone_number": "+14155551321",
                "metadata": {
                    "merchant_defined": true
                }
            }
        }
    }
}


{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "9beb37b8-16e0-4ded-a4b5-879b22da6360"
    },
    "data": {
        "phone_number": null,
        "email": null,
        "first_name": "Shikhar",
        "last_name": "Vaish",
        "id": "ewallet_eeaf7c3ac08f9a9f0338d18e1a31ba8e",
        "status": "ACT",
        "accounts": [],
        "verification_status": "not verified",
        "type": "company",
        "metadata": {
            "merchant_defined": true
        },
        "ewallet_reference_id": "Shikhar1",
        "category": null,
        "contacts": {
            "data": [
                {
                    "id": "cont_c31d9d0bee1080601752955003cf652d",
                    "first_name": "Shikhar",
                    "last_name": "Vaish",
                    "middle_name": "",
                    "second_last_name": "",
                    "gender": "not_applicable",
                    "marital_status": "not_applicable",
                    "house_type": "",
                    "contact_type": "business",
                    "phone_number": "+14155551311",
                    "email": "1234email1@sample.net",
                    "identification_type": "PA",
                    "identification_number": "identificationNum1",
                    "preferred_name": "",
                    "date_of_birth": "2000-11-22",
                    "country": "US",
                    "nationality": null,
                    "address": {
                        "id": "address_0e6b46ec83a217d9d9b973991e786ecd",
                        "name": "Shikhar Vaish",
                        "line_1": "123 Main Street",
                        "line_2": "",
                        "line_3": "",
                        "city": "Anytown",
                        "state": "NY",
                        "country": "US",
                        "zip": "12345",
                        "phone_number": "+14155551312",
                        "metadata": {
                            "merchant_defined": true
                        },
                        "canton": "",
                        "district": "",
                        "created_at": 1623328331
                    },
                    "ewallet": "ewallet_eeaf7c3ac08f9a9f0338d18e1a31ba8e",
                    "created_at": 1623328331,
                    "metadata": {
                        "merchant_defined": true
                    },
                    "business_details": {
                        "id": "busi_51339cac6676d7f451d62a915d5b1a8c",
                        "name": "Four Star Professional Services",
                        "registration_number": "identificationNum2",
                        "entity_type": "association",
                        "industry_category": "company",
                        "industry_sub_category": "home services",
                        "address": {
                            "id": "address_36ba0645e7d5be6e743e8dfe8ea56dc8",
                            "name": "John Doe",
                            "line_1": "1234 Main Street",
                            "line_2": "Suite 1200",
                            "line_3": "",
                            "city": "Anytown",
                            "state": "NY",
                            "country": "US",
                            "zip": "10101",
                            "phone_number": "+14155551321",
                            "metadata": {
                                "merchant_defined": true
                            },
                            "canton": "",
                            "district": "",
                            "created_at": 1623328331
                        },
                        "created_at": 1623328331,
                        "annual_revenue": 0,
                        "establishment_date": null,
                        "legal_entity_type": null,
                        "cnae_code": null
                    },
                    "compliance_profile": 0,
                    "verification_status": "not verified",
                    "send_notifications": false,
                    "mothers_name": "Jane Smith"
                }
            ],
            "has_more": false,
            "total_count": 1,
            "url": "/v1/ewallets/ewallet_eeaf7c3ac08f9a9f0338d18e1a31ba8e/contacts"
        }
    }
}
2 Likes

Hi! I just found the bug.
I did not pass “body_string” as required in signature. I was declaring body after the headers and making the API call.

I’m getting all responses correctly now. Thanks a lot!!

3 Likes

That would do it!

By the way, one thing to watch out for in the signature - Postman by default puts an empty pair of curly braces in the body. This will mess up the signature calculation, so if you have any requests with an empty body, be sure it’s really empty - delete those unhelpful curly braces. All GET methods have empty body sections, and some of the DELETE methods do too.

1 Like

Oh! I’ll keep that in mind.