Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailjet: delete contact

Is it possible to actually delete a contact from mailjet?

Their contact API doc doesn't even list delete as a supported action.

from mailjet_rest import Client

mailjet = Client(auth=(MAILJET_API_KEY, MAILJET_API_SECRET), version='v3')
mailjet.contact.delete(<contact-id>).json()
{'ErrorInfo': '', 'ErrorMessage': 'Operation not allowed', 'StatusCode': 401}

I am interested in removing a contact, not a list recipient, and hence this question is not a duplicate of How can i delete a contact from a list with the mailjet api and php?.

like image 214
Dušan Maďar Avatar asked Mar 07 '23 07:03

Dušan Maďar


1 Answers

The API reference does not yet seem to be updated with the DELETE method, but under API guides there seems to be information on how to delete contacts:

Retrieve a Contact

To delete a contact, you must first identify its presence in the contact database of your account.

Use GET /contact/$CONTACT_EMAIL to do it.

curl -s \
    -X GET \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v3/REST/contact/$CONTACT_EMAIL 

Delete the Contact

Use the {contact_ID} you retrieved to DELETE the contact with the /v4/contacts/{contact_ID} endpoint. When the deletion is successful, the API will return a 200 OK status. Any other response will indicate that the deletion was not successfully processed.

curl -s \
    -X DELETE \
    --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
    https://api.mailjet.com/v4/contacts/{contact_ID} \

NB: this is a /v4 endpoint, not /v3

like image 51
alisspers Avatar answered Mar 21 '23 06:03

alisspers