docs icon indicating copy to clipboard operation
docs copied to clipboard

Incomplete information for /marketing/contacts API endpoint

Open adamalton opened this issue 6 years ago • 4 comments

On the documentation page for the /marketing/contacts API endpoint there is insufficient information to be able to deduce how one is meant to update an existing contact.

The page explicitly says "This endpoint allows the upsert (insert or update) of up to 30000 contacts". So clearly it's possible to update a contact as well as just insert one. But it's not clear how one is meant to do that.

My guess is that you're meant to include an id field in the contact data. But the schema for the endpoint doesn't mention that.

sendgrid-contacts-api-schema

Perhaps the email is the unique identifier? But I'm guess that's not the case because:

  1. This endpoint suggests that there's a separate id field.
  2. If the email was the unique identifier then "updating" an existing contact to change their email address would cause the creation of a new contact, which would then potentially trigger the Automations again, which would be bad.

If you could clarify how this endpoint works and update the docs, that would be really useful.

Thanks!

adamalton avatar Sep 30 '20 15:09 adamalton

It would also be useful if the page could clarify what the behaviour is in terms of updating fields.

E.g. if an existing contact looks like:

{
    "email": "[email protected]",
    "first_name": "Lucy"
}

And an update is made passing contact data of:

{
    "email": "[email protected]",
    "last_name": "Smith"
}

What value will first_name be set to after that update?

adamalton avatar Sep 30 '20 15:09 adamalton

Hi @adamalton

Thanks so much for your feedback! We've added this to our internal docs backlog.

Twilio SendGrid Docs Team

Whatthefoxsays avatar Oct 12 '20 17:10 Whatthefoxsays

Hi @adamalton , we've updated the docs to mention that fields omitted from the upsert request will leave existing values alone when the contacts already exist and that you do not need the contact ID to update a contact as it will be matched by email address.

For the specific use case of updating a contact's email address, you would need to create a new contact using the new email address and delete the old one.

Cheers!

pmcanseco avatar Jun 25 '21 18:06 pmcanseco

Hi @pmcanseco thanks for looking at this and making some initial changes.

However, now the docs no longer seem to mention the id field, which definitely exists and can be used to identify the contacts (because I have code which is doing this). This is particularly problematic because of the confusing and contradictory documentation around the case sensitivity of email addresses.

On this page it says:

The email field is case sensitive. If you add an email with capital letters then try to use the "Get Contacts by Emails" endpoint, you will need to apply the same case you used when updating or adding the contact.

But on the mentioned "Get Contacts By Emails" page, it says this:

Email addresses are not case sensitive, and returned email addresses will be all lower case. Empty strings are excluded from the search and will not be returned.

If that contradiction wasn't bad enough, what's worse is that on the /v3/marketing/contacts/search endpoint, the behaviour is actually neither of those!! For that endpoint you must always supply the email address in lower case, even if the saved email address has upper case characters. So it's case sensitive, but must always be supplied in lower case!

To make life less painful for people, it would be great if you could:

  • Fix the contradictory statements about email case sensitivity.
  • Either fix the /v3/marketing/contacts/search endpoint to either be case sensitive or not case sensitive, rather than its current weird lower-case-only behaviour. Or add a statement to its docs page to explain this behaviour.
  • Ensure that that same strange behaviour doesn't also exist in either the /marketing/contacts/search/emails endpoint or the /marketing/contacts endpoint. (I haven't tested the behaviour on these endpoints.)
  • Add information to the /marketing/contacts endpoint documentation to describe how the id field can be used to identify a contact (which given that my code is still working, appears to be a working feature).

I think that would really help people who are trying to use the API.
Adam

adamalton avatar Jun 25 '21 19:06 adamalton