Statut par message mail
- Home
- Statut par message mail
Statut par ID
Cette requête permet de récupérer les statuts de plusieurs mail à partir d’un ID.
A noter : les comptes-rendus sont reçus en moyenne quelques secondes après l’envoi du mail ; cependant, ce délai peut s’étendre jusqu’à 48h maximum selon les opérateurs et la charge de notre plateforme.
URL
GET https://api.mailpartner.fr/v1/bulk-status
Paramètres
Chaque demande d’API prend en charge les paramètres suivants :
apiKey | Clé API de votre compte. Vous l’obtenez dans votre compte Mail Partner |
---|---|
messageId | ID du message. Il se trouve dans la réponse lors de l’envoi d’un mail |
Requête
Exemple de requête :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php // Prepare data for GET request $data = 'apiKey=YOUR_API_KEY&messageId=300'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://api.mailpartner.fr/v1/bulk-status?'.$data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $result = curl_exec($curl); curl_close($curl); // Process your response here echo $result; ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
Imports System.IO Imports System.Net Module Module1 Sub Main() Dim base_url As String = "http://api.mailpartner.fr/v1/" Dim apiKey As String = "VOTRE_APIKEY" Dim messageId As Integer = XXX #check credits Dim url As String url = base_url & "bulk-status" & "?apiKey=" & apiKey & "&messageId=" & messageId Dim credits As String credits = apiRequest("GET", url, Nothing) End Sub Function apiRequest(method As String, url As String, parameters As String) As String Dim request As HttpWebRequest request = WebRequest.Create(url) request.Method = method request.Timeout = 10000 # timeout in ms request.ContentType = "application/json; charset=utf-8" request.ContentLength = 0 #set POST data If Not String.IsNullOrEmpty(parameters) Then request.ContentLength = parameters.Length Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream()) reqStream.Write(parameters) End Using End If #get response Dim returnValue As String = Nothing Using response As HttpWebResponse = request.GetResponse() If response.StatusCode = HttpStatusCode.OK Then Using resStream = response.GetResponseStream() If resStream IsNot Nothing Then Using reader As New StreamReader(resStream) returnValue = reader.ReadToEnd() End Using End If End Using End If End Using apiRequest = returnValue End Function End Module |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# std import logging import json from collections import OrderedDict # 3p import requests API_KEY = "MY API KEY" URL = "https://api.mailpartner.fr/v1" class MailPartner(): def get_delivery(self,message_id): url = URL + "/bulk-status?apiKey=" + API_KEY + "&messageId=" + message_id r = requests.get(url) r_json = r.json() if r_json.get("success") == True: print(r_json) status = True else: print(r_json) status = False return status |
1 |
curl -H "Content-Type: application/json" -X GET https://api.mailpartner.fr/v1/bulk-status?apiKey=xxx&messageId=300 |
Réponses
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "success": true, "code": 200, "messageId": "xxx", "StatutResponseList": [ { "email": "email1", "token": "xxx", "status": "Delivered", "cost": 1, "stopMail": true, "date": "1599061044" }, { "email": "email2", "token": "yyy", "status": "Delivered", "cost": 1, "stopMail": true, "date": "1599061044" } ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?xml version="1.0" encoding="UTF-8"?> <result> <entry>true</entry> <entry>200</entry> <entry> <![CDATA[xxx]]> </entry> <entry> <entry> <entry> <![CDATA[email1]]> </entry> <entry> <![CDATA[xxx]]> </entry> <entry> <![CDATA[Delivered]]> </entry> <entry>1</entry> <entry>true</entry> <entry> <![CDATA[1599061044]]> </entry> </entry> <entry> <entry> <![CDATA[email2]]> </entry> <entry> <![CDATA[yyy]]> </entry> <entry> <![CDATA[Delivered]]> </entry> <entry>1</entry> <entry>true</entry> <entry> <![CDATA[1599061044]]> </entry> </entry> </entry> </result> |
Erreurs
Exemple de message d’erreur :
1 2 3 4 5 |
{ "success": false, "code": 10, "message": "Clé API incorrecte" } |
1 2 3 4 5 6 |
<?xml version='1.0' encoding='UTF-8'?> <result> <entry>false</entry> <entry>10</entry> <entry>Clé API incorrecte</entry> </result> |
Code de contrôle
Réponse | ||
---|---|---|
1 | La Clé API est requise | |
3 | L’ID du message est requis | |
4 | Message introuvable | |
10 | Clé API incorrecte | |
200 | Tout s’est bien passé ! |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales