import com.google.gson.Gson;import com.google.gson.GsonBuilder;import com.mangopay.MangoPayApi;import com.mangopay.core.enumerations.EventType;import com.mangopay.entities.Hook;public class CreateHook { public static void main(String[] args) throws Exception { MangoPayApi mangopay = new MangoPayApi(); mangopay.getConfig().setClientId("your-client-id"); mangopay.getConfig().setClientPassword("your-api-key"); Hook hook = new Hook(); hook.setEventType(EventType.USER_KYC_LIGHT); hook.setUrl("http://example.com"); hook.setTag("Create using the Mangopay Java SDK"); Hook createHook = mangopay.getHookApi().create(hook); Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create(); String prettyJson = prettyPrint.toJson(createHook); System.out.println(prettyJson); }}
from pprint import pprintimport mangopaymangopay.client_id='your-client-id'mangopay.apikey='your-api-key'from mangopay.api import APIRequesthandler = APIRequest(sandbox=True)from mangopay.resources import Notificationhook = Notification( event_type = 'USER_KYC_REGULAR', url = 'http://example.com', tag = 'Create using the Mangopay Python SDK')create_hook = hook.save()pprint(create_hook)
using MangoPay.SDK;using MangoPay.SDK.Core.Enumerations;using MangoPay.SDK.Entities.POST;using Newtonsoft.Json;class Program{ static async Task Main(string[] args) { MangoPayApi api = new MangoPayApi(); api.Config.ClientId = "your-client-id"; api.Config.ClientPassword = "your-api-key"; var eventType = EventType.DISPUTE_CREATED; var url = "https://www.example.com/"; var hook = new HookPostDTO(url, eventType) { Tag = "Created using the Mangopay .NET SDK" }; var createHook = await api.Hooks.CreateAsync(hook); string prettyPrint = JsonConvert.SerializeObject(createHook, Formatting.Indented); Console.WriteLine(prettyPrint); }}
{ "Url": "https://example.com", "Status": "ENABLED", "Validity": "VALID", "EventType": "PAYIN_REFUND_SUCCEEDED", "Id": "hook_m_01J8F5RK4R43AYWD8XVG9RSYDT", "Tag": "Created using the Mangopay API Postman Collection", "CreationDate": 1727086218}
Caution – Setting email for consecutive failures after April 2026In Production, if your platform had VALID Hook objects before April 2, 2026, then Mangopay automatically populates the Email property on new Hooks with the previously used global address unless and until you set it proactively using this endpoint.If you send the Email on a POST or PUT request, other new Hooks created without the Email do not populate the Email automatically and do not emit alerts in case of consecutive failed notifications or if the Hook becomes INVALID.Platforms integrating after April 2, 2026 must proactively set the Email to receive alerts.Read more about this change→
Format: A valid email addressThe Email address to which alerts are sent in case of consecutive failed notification attempts.Caution: Mangopay may populate this property automatically if your platform had webhooks integrated in Production before April 2, 2026. If so, setting the Email on a single Hook stops this automatic population for any new Hooks you create - read more.For all platforms, if this property is returned null then no alerts are sent but the Hook still becomes INVALID after 100 consecutive failed notifications.
Returned values:VALID, INVALIDWhether the hook is valid or not. Once INVALID (following unsuccessful retries) the hook must be disabled and re-enabled.
The date and time at which the object was created.
400 - Hook already exists for this EventType
{ "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.", "Type": "param_error", "Id": "829f2782-85a9-45b1-a2bd-993b0978c5bc", "Date": 1690295313.0, "errors": { "EventType": "A hook has already been registered for this EventType" }}
{ "Url": "https://example.com", "Status": "ENABLED", "Validity": "VALID", "EventType": "PAYIN_REFUND_SUCCEEDED", "Id": "hook_m_01J8F5RK4R43AYWD8XVG9RSYDT", "Tag": "Created using the Mangopay API Postman Collection", "CreationDate": 1727086218}
{ "Url": "https://example.com", "EventType" : "PAYIN_REFUND_SUCCEEDED", "Tag": "Created using the Mangopay API Postman Collection"}
<?phprequire_once 'vendor/autoload.php';use MangoPay\MangoPayApi;use MangoPay\Libraries\ResponseException as MGPResponseException;use MangoPay\Libraries\Exception as MGPException;$api = new MangoPayApi();$api->Config->ClientId = 'your-client-id';$api->Config->ClientPassword = 'your-api-key';$api->Config->TemporaryFolder = 'tmp/';try { $hook = new \MangoPay\Hook(); $hook->EventType = \MangoPay\EventType::MandateFailed; $hook->Url = 'http://example.com'; $hook->Tag = 'Created using Mangopay PHP SDK'; $response = $api->Hooks->Create($hook); print_r($response);} catch(MGPResponseException $e) { print_r($e);} catch(MGPException $e) { print_r($e);}