Creating Loyalty Account Fails

I’m getting the following error from the Loyalty API when creating an account from the following payload. The docs say the number must be in the E.164 format. For example, “+14155551111”.

The phone number “+19281735585” passes every regex E.164 test I’ve run, so I don’t understand why the API is returning this error.

I’ve scrambled the IDs and last 4 of the phone number for privacy, but I’m receiving this error both in my code and in the Square API Explorer.

Payload:

{
  "loyalty_account": {
    "program_id": "26de-4df7-a8c3-48724c2793e5-1398ede9",
    "customer_id": "4DA991AZSEQF7EMAVHQJ37DYCT",
    "mapping": {
      "phone_number": "+19281735585"
    }
  },
  "idempotency_key": "65ba8c204ffe7"
}

Error:

{
  "errors": [
    {
      "code": "INVALID_PHONE_NUMBER",
      "detail": "Loyalty phone number +19281734485 is not formatted correctly or uses an unsupported country code",
      "field": "phone",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

Hi @danjy ,
I would like to take a look into this.
Could I get your application id, so I can take a look at your API Logs.

Thank you. Logs are below.

Request:

{
  "loyalty_account": {
    "program_id": "1398ede9-26de-4df7-a8c3-48724c2793e5",
    "customer_id": "AVHQJ37DYCT4DA991AZSEQF7EM",
    "mapping": {
      "phone_number": "+19281734485"
    }
  },
  "idempotency_key": "65ba8c204ffe7"
}

Response:

{
  "errors": [
    {
      "code": "INVALID_PHONE_NUMBER",
      "detail": "Loyalty phone number +19281734485 is not formatted correctly or uses an unsupported country code",
      "field": "phone",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

@danjy Thanks for the example API call. But I would also like to take at the related API calls that were make in by your application. If you could provide your application id from Developer Dashboard, then I can take a look at all your recent API calls in your API Logs.

Those logs are from the Square API Explorer. The application id is “sq0idp-Um5jtq1sP6NGk99RLqo75w”

Hi - was this ever resolved? I’m getting the same error back while using a valid phone number.
Thanks!

Do you have a +1 in the number? :slightly_smiling_face:

Hi. Yes, I have a +1 and then 10 digit number. I should mention that I am pointing to my staging environment, and am using the API Explorer

What’s your application ID? :slightly_smiling_face:

My App ID is sandbox-sq0idb-yubk-ejnlBpODqT5Bb2AZw. Thanks so much for looking into this!

Hi Bryan. It seems to be working now for some reason. Do you know if there was some issue in the backend?

I took a look at the logs and all the error messages seem to be correct. The details of the error messages explain why the request failed. Whether it be a format issue, incorrect country code, or if it’s already associated to a Loyalty account. What phone number are you having trouble with? :slightly_smiling_face:

Thanks Bryan. So I think it may have to do with the test phone numbers that I’m using. For example, ```
+14151112222 failed, but +14153334569 worked ok. The first number did not already exist in my sandbox account, so I’m wondering if there is some type of check for a valid number somehow?