API documentation |
We would love to hear any questions and feedback you may have! Please mail us at api@laposta.org. The API key used in the examples is available for testing. |
||||||||||||||||||||||||||||||||||||||||||||
The Laposta API has been set up according to the REST principle. All responses from the API, including error messages, have been formatted in JSON format. The API primarily focuses on the addition and reading subscribers. This allows for Laposta to, among other things, synchronize with other systems, like a CMS or a CRM. Another of its common applications is the automatic addition of subscribers to Laposta, for instance when placing an order in a webshop. It is also possible for partners to create accounts using the API, so that the set-up of customer accounts can fully be achieved without the need of our assistence. In order to make programming with the API easier php and .NET (C#) libraries have been made available for users. |
Default API URLThe API is available via http and https. For security reasons, we strongly recommend users to work with https URLs.
Available URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
AuthenticationEach request must include the account's API key. This can be found by logging in and proceeding to click on 'Access & Subscription' on the top right, and then going to 'Links - API'. The Authentication process is achieved using Basic Authentication. The API-key functions as the username; a password is not required. |
Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); LapostaMember member = new LapostaMember(); member = memberService.Get("9978ydioiZ"); |
||||||||||||||||||||||||||||||||||||||||||||
Rate limitingIn order to protect our systems, we have decided to limit the number of requests per unit of time. If you have reached a limit, you will recieve a notification from our server. This notification also indicates after how many seconds a next request is possible again. For free accounts, there is a limit of 30 requests per minute. For paid accounts, the limit is 120 requests per minute. Try to cache as much information as possible! For instance, it's not practical/necessary to create a sign-up form and then retrieve the information about the fields at every page view. |
If the limit is reachedIf you reach the limit, the server will respond with status code 429 (Too Many Requests). The server will also send a Retry-After header indicating the number of seconds to wait until the next request is possible. |
||||||||||||||||||||||||||||||||||||||||||||
Error messagesOur API uses as many standard HTTP status codes as possible in order to indicate how a request has proceeded. Codes in the 2xx range indicate a successful request, codes in the 4xx range indicate the presence of an error in the delivery of information (e.g. missing parameters), and codes in the 5xx range indicate that something went wrong on our end. All error messages are formatted in JSON format and include an indication in regards to the type of error, a notification in regular language, and potentially a code with a parameter (in order to indicate the nature of the error). |
Overview of used HTTP status codes
Overview of attributes in error messages
Overview of codes in error messages
Example of an error object{ "error": { "type": "invalid_input", "message": "Email: invalid address", "code": 208, "parameter": "email" } } |
||||||||||||||||||||||||||||||||||||||||||||
ListsThis element allows the user to retrieve, add, modify, delete and empty lists. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
URL patternsFields
|
Example of list object{ "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Testlist", "remarks": "A list for testing purposes", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net", "members": { "active": 1232, "unsubscribed": 113, "cleaned": 14 } } } |
||||||||||||||||||||||||||||||||||||||||||||
Adding a listIf there is something wrong with the parameters provided, a code is displayed with an error message. You may use these in combination with the variable 'parameter' to display a message to the user. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/list Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var listService = new LapostaListService(); LapostaList list = new LapostaList(); list.Name = "Testlijst"; list.Remarks = "Testing purposes."; list = listService.Create(list); Example of response{ "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Testlist", "remarks": "A list for testing purposes.", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net", "members": { "active": 0, "unsubscribed": 0, "cleaned": 0 } } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting a listAll information about a list. Parameters
|
DefinitionGET https://api.laposta.org/v2/list/{list_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var listService = new LapostaListService(); LapostaList list = new LapostaList(); list = listService.Get("BaImMu3JZA"); |
||||||||||||||||||||||||||||||||||||||||||||
Modifying listsYou will only have to include the fields that need to be modified in the application. Fields that are not mentioned will keep their current value. As soon as a field is mentioned, it is checked and may therefore cause an error message. A code is displayed with this error message. You may use this code in combination with the variable 'parameter' to display a message to the user. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/list/{list_id} Example of requestThis example changes the name. LapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var listService = new LapostaListService(); LapostaList list = new LapostaList(); list.Name = "A new name for this list"; list = listService.Update("BaImMu3JZA", list); Example of response{ "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Customers", "remarks": "A list for testing purposes.", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net", "members": { "active": 1232, "unsubscribed": 113, "cleaned": 14 } } } |
||||||||||||||||||||||||||||||||||||||||||||
Deleting a listThis permanently deletes a list. If the list does not exist, an error message is displayed. In response you are shown another list object, but now with the state 'deleted'. After having finished this procedure, it is no longer possible for the user to request the list. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/list/{list_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var listService = new LapostaListService(); LapostaList list = new LapostaList(); list = listService.Delete("BaImMu3JZA"); Example of response{ "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "deleted", "name": "Customers", "remarks": "A list for testing purposes", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net", "members": { "active": 1232, "unsubscribed": 113, "cleaned": 14 } } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting all listsAll lists in an array of list objects. The list objects have been ordered in an array with the name 'data'. ParametersNo parameters need to be provided. |
DefinitionGET https://api.laposta.org/v2/list Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var listService = new LapostaListService(); var lists = Enumerable.Empty Example of response{ "data": [ { "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Testlist", "remarks": "A list for testing purposes.", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net" "members": { "active": 1232, "unsubscribed": 113, "cleaned": 14 } } }, { "list": { "list_id": "Z87Jajj9Ak", "created": "2012-03-30 12:23:46", "modified": "2012-04-10 13:33:21", "state": "active", "name": "Another list", "remarks": "Customers", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net" "members": { "active": 8182, "unsubscribed": 205, "cleaned": 56 } } } ] } |
||||||||||||||||||||||||||||||||||||||||||||
Purging a listThis permanently purges all active subscribers from a list, but doesn't delete the list itself. If the list does not exist, an error message is displayed. In response, you are shown another list object. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/list/{list_id}/members Example of request[a .NET wrapper is not yet available for this functionality] Example of response{ "list": { "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "deleted", "name": "Customers", "remarks": "A list for testing purposes", "subscribe_notification_email": "subscription@example.net", "unsubscribe_notification_email": "unsubscription@example.net", "members": { "active": 1232, "unsubscribed": 113, "cleaned": 14 } } } |
||||||||||||||||||||||||||||||||||||||||||||
Filling / editing a list (in bulk)This feature is not available for free accounts. Allows you to modify and/or simultaneously add several relations to an existing list. If the list does not exist or if mandatory parameters are missing, you will receive an error message. Please note that data delivery is via JSON. Parameters
JSON Object
Member Object
|
DefinitionPOST https://api.laposta.org/v2/list/{list_id}/members Example of request[No .NET wrapper is available yet for this feature] Example of responseFirst of all, an error message may be reported back as described under error messages. This happens when the request is rejected on the basis of an unsubmitted or incorrectly submitted list_id, or when the embedded JSON data is not correct. If there is no error message as described above, we always send out a successful response in accordance with the following example of the mode add: { "report": { "provided_count": 3, "errors_count": 1, "skipped_count": 1, "edited_count": 0, "added_count": 1 }, "errors": [ { "provided_data": { "email": "member1@example.org" }, "error": { "message": "Field my_required_field: cannot be empty", "code": 201, "parameter": "my_required_field", "id": "lRZBQFQdBk", "type": "invalid_input" } } ], "skipped": [ { "provided_data": { "member_id": "9978ydioiZ", "email": "member2@example.org", "custom_fields": { "my_optional_field": "My optional value" } }, "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "member2@example.org", "state": "active", "signup_date": "2023-01-01 11:58:16", "modified": null, "confirm_date": null, "ip": "198.51.100.10", "source_url": "", "custom_fields": { "my_required_field": "My required field value", "my_optional_field": "" } } } ], "edited": [], "added": [ { "provided_data": { "email": "member3@example.org", "custom_fields": { "my_required_field": "My required field value", "my_optional_field": "My optional value" } }, "member": { "member_id": "vnvj2cfQ3a", "list_id": "BaImMu3JZA", "email": "member3@example.org", "state": "active", "signup_date": "2023-02-07 17:29:33", "modified": null, "confirm_date": null, "ip": "198.51.100.10", "source_url": null, "custom_fields": { "my_required_field": "My required field value", "my_optional_field": "My optional value" } } } ] } As illustrated in the example above, you will receive a report, and we sort the provided member objects into errors, skipped, edited, and added. You will always receive this report from us, even if there is no data in it. For every member we process, you will receive the provided_data, and wherever possible you will also receive a member object the way as the member is currently known to us in the system. This way you will be able to easily compare the submitted list with the status at Laposta. Members end up in skipped when, according to the given mode, they are not allowed to be processed but have been included regardless. |
||||||||||||||||||||||||||||||||||||||||||||
FieldsThis section allows you to request, add and modify fields of lists. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
The field objectFields
|
Example of field object{ "field": { "field_id": "Z87ysHha9A", "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Name", "tag": "{{name}}", "custom_name": "name", "defaultvalue": "", "datatype": "text", "datatype_display": null, "required": true, "in_form": true, "in_list": true, "autocomplete": "on" } } |
||||||||||||||||||||||||||||||||||||||||||||
Adding a fieldIf there is something wrong with the parameters provided, a code is displayed with an error message. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/field Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var fieldService = new LapostaFieldService("BaImMu3JZA"); LapostaField field = new LapostaField(); field.Name = "Age"; field.DefaultValue = "Age"; field.Datatype = "numeric"; field.Required = true; field = fieldService.Create(field); Example of response{ "field": { "field_id": "GeVKetES6z", "list_id": "srbhotdwob", "created": "2016-06-06 22:24:38", "modified": null, "state": "active", "name": "Color", "tag": "{{color}}", "defaultvalue": "Green", "datatype": "select_single", "datatype_display": "radio", "required": true, "in_form": true, "in_list": true, "autocomplete": "on", "is_email": false, "options": [ "Red", "Green", "Blue" ], "options_full": [ { "id": 1, "value": "Red" }, { "id": 2, "value": "Green" }, { "id": 3, "value": "Blue" } ] } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting a fieldAll information about a field. Parameters
|
DefinitionGET https://api.laposta.org/v2/field/{field_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var fieldService = new LapostaFieldService("BaImMu3JZA"); LapostaField field = new LapostaField(); field = fieldService.Get("gt2Em8vJwi"); |
||||||||||||||||||||||||||||||||||||||||||||
Modifying fieldsYou will only have to include the parts that need to be modified. Parts that are not mentioned will keep their current values. As soon as a part is mentioned it does get checked, and thus can cause an error message. This error message contains a code with a message. See above under 'Error messages' what these codes stand for. Please note that changing the data type removes all data from the field in question. Parameters
|
DefinitionPOST https://api.laposta.org/v2/field/{field_id} Example of requestThis example makes the field no longer mandatory. LapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var fieldService = new LapostaFieldService("BaImMu3JZA"); LapostaField field = new LapostaField(); field.Required = false; field = fieldService.Update("hsJ5zbDfzJ", field); Example of response{ "field": { "field_id": "hsJ5zbDfzJ", "list_id": "BaImMu3JZA", "created": "2012-10-31 11:55:50", "modified": "2012-10-31 12:05:44", "state": "active", "name": "Age, "tag": "{{Age}}", "custom_name": "Age", "defaultvalue": "", "datatype": "text", "datatype_display": null, "required": false, "in_form": true, "in_list": true, "autocomplete": "on" } } |
||||||||||||||||||||||||||||||||||||||||||||
Deleting a fieldThis permanently deletes a field. If the field does not exist, an error message is displayed. In response you are shown another field object, but now with the state 'deleted'. After having finished this procedure, it is no longer possible for the user to request the field. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/field/{field_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var fieldService = new LapostaFieldService("BaImMu3JZA"); LapostaField field = new LapostaField(); field = fieldService.Delete("lxwc8OyD3a"); Example of response{ "field": { "field_id": "lxwc8OyD3a", "list_id": "BaImMu3JZA", "created": "2012-10-30 21:44:40", "modified": null, "state": "deleted", "name": "FavoriteColor", "tag": "{{favoritecolor}}", "custom_name": "favoritecolor", "defaultvalue": "", "datatype": "text", "datatype_display": null, "required": false, "in_form": true, "in_list": true, "autocomplete": "on" } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting all fields of a listAll fields of a list in an array of field objects. The field objects are formatted in an array named 'data'. Parameters
|
DefinitionGET https://api.laposta.org/v2/field Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var fieldService = new LapostaFieldService("BaImMu3JZA"); var fields = Enumerable.Empty Example of response{ "data": [ { "field": { "field_id": "Z87ysHha9A", "list_id": "BaImMu3JZA", "created": "2012-02-18 11:42:38", "modified": "2012-06-02 14:07:20", "state": "active", "name": "Name", "tag": "{{name}}", "custom_name": "name", "defaultvalue": "reader", "datatype": "text", "required": true, "in_form": true, "in_list": true, "autocomplete": "on" } }, { "field": { "field_id": "9hj8HA_8A2", "list_id": "BaImMu3JZA", "created": "2012-03-28 20:12:02", "modified": "2012-03-28 20:13:10", "state": "active", "name": "Age", "tag": "{{age}}", "custom_name": "age", "defaultvalue": "unknown", "datatype": "date", "required": true, "in_form": true, "in_list": true, "autocomplete": "on" } } ] } |
||||||||||||||||||||||||||||||||||||||||||||
SubscribersThis section allows you to retrieve, add and modify subscribers. You will need a list_id as a parameter each time. You can find this by logging in, and proceeding to the corresponding list under 'Subscribers'. Next up, click on the tab labeled 'Attributes list'. On the right side you will see the ID there. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
The member objectFields
|
Example of member object{ "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "active", "signup_date": "2012-08-13 16:13:07", "modified": "2012-08-13 16:14:27", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries", "dateofbirth": "1973-05-10 00:00:00", "children": 2, "prefs": [ "optionA", "optionB" ] } } } |
||||||||||||||||||||||||||||||||||||||||||||
Adding a subscriberIf there is something wrong with the parameters provided, a code is displayed with an error message. You can use this in combination with the variable 'parameter' to display a message to the user. See above under 'Error messages' what the codes stand for. Parameters
If it concerns a double-optin list then a confirmation email will be sent with each subscription, unless the 'ignore_doubleoptin' option is included (see above). If there are custom_fields that have been set to mandatory, then filling these fields via the API is also mandatory. |
DefinitionPOST https://api.laposta.org/v2/member Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); LapostaMember member = new LapostaMember(); member.Email = "maartje@example.net"; member.IP = "198.51.100.0"; member.SourceUrl = "http://example.com"; member.CustomFields = new Dictionary Multiple choice custom fields can be filled with the currently defined options for that field. So you can simply enter the value of the field. If multiple choices can be made, you can pass them in an array; see the example above. Example of response{ "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "active", "signup_date": "2012-08-13 16:13:07", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries", "dateofbirth": "1973-05-10 00:00:00", "children": 2, "prefs": [ "optionA", "optionB" ] } } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting a subscriberAll information about a subscriber in a member object Parameters
|
DefinitionGET https://api.laposta.org/v2/member/{member_id}?list_id={list_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); LapostaMember member = new LapostaMember(); member = memberService.Get("9978ydioiZ"); |
||||||||||||||||||||||||||||||||||||||||||||
Modifying a subscriberYou only have to include the fields that need to be modified in the request. Fields that are not named will keep their current value. As soon as a field is mentioned it does get checked, and thus can cause an error message. This error message displays a code with a message. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/member/{member_id} Example of requestThis example changes the name and the amount of children LapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); LapostaMember member = new LapostaMember(); member.CustomFields = new Dictionary Instead of using the member_id, you may also use the email address Multiple choice custom fields that are not mandatory can be emptied by including the variable in the change request, but without an assigned value. Example of response{ "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "active", "signup_date": "2012-08-13 16:13:07", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries - Abbink", "dateofbirth": "1973-05-10 00:00:00", "children": 3, "prefs": [ "optionA", "optionB" ] } } } |
||||||||||||||||||||||||||||||||||||||||||||
Deleting a subscriberThis permanently deletes a subscriber. If the subscriber does not exist, an error message is displayed. In response you are shown another list object, but now with the state 'deleted'. After having finished this procedure, it is no longer possible for the user to request the subscriber. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/member/{member_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); LapostaMember member = new LapostaMember(); member = memberService.Delete("9978ydioiZ"); You may also use the email address here instead of the member_id. Example of response{ "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "deleted", "signup_date": "2012-08-13 16:13:07", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries - Abbink", "dateofbirth": "1973-05-10 00:00:00", "children": 3, "prefs": [ "optionA", "optionB" ] } } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting all subscribers of a listAll fields of a list in an array of member objects. The member objects are formatted in an array named 'data'. Parameters
|
DefinitionGET https://api.laposta.org/v2/member Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var memberService = new LapostaMemberService("BaImMu3JZA"); var members = Enumerable.Empty Example of response{ "data": [ { "member": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "active", "signup_date": "2012-08-13 16:13:07", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries - Abbink", "dateofbirth": "1973-05-10 00:00:00", "children": 3, "prefs": [ "optionA", "optionB" ] } } }, { "member": { "member_id": "Hy8RA178HB", "list_id": "BaImMu3JZA", "email": "stefan@example.net", "state": "active", "signup_date": "2012-06-24 11:54:12", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Stefan van Aalst", "dateofbirth": null, "children": 0, "prefs": [ "optionA" ] } } } ] } |
||||||||||||||||||||||||||||||||||||||||||||
WebhooksWebhooks are a separate part of the API. With the normal API, the request for information always comes from the developer. With webhooks it is the other way around and Laposta takes the initiative to inform the developer of something. A webhook does this by querying a URL that you have specified; in the form of a POST with a JSON object containing information. You can enter URLs for adding, changing or deleting subscribers. Let us suppose you create a webhook for additions, and someone registers via a Laposta registration form, then almost immediately after this new registration you will receive a POST at the URL you have specified. Application: Syncronization with other systemsOur API is mainly used to synchronize the subscribers file in Laposta with another application, for example a CMS or a CRM. Adding and changing subscribers to Laposta is then aclished via the API (as described above). Webhooks notify your application of modifies in the subscriber file that take place within Laposta (subscriptions, the cancelling of subscriptions, or modifications). With the combination of these two functions, you are able to keep the two files in sync. The processing of webhooksWith a webhook, a URL is requested on your server. You are completely in control of how that information is processed. To indicate that you have received a webhook correctly, the server must return a 200 HTTP status code. (This will usually be the case by default). After modifications via the APIBy default, the webhooks are not called when you add or modify relationships via the API. The reasoning behind this is that you are already aware of the changes, and receiving this information via a webhook would be redundant. However, there may be situations where this is desired (for example, if the API is called from an external form). This is possible; if you send us an email about this, we can activate it. |
Registering webhooksYou can register webhooks per list. This is done by going to the appropriate list (under Subscribers), and proceeding to the Attributes list. There, you will find the tab called Webhooks. For each webhook, you can specify the event for which it should be requested: adding a subscriber, modifying a subscriber, or deleting a subscriber. In addition, you specify the URL to which the information should be POSTed. It is possible to moderate the webhooks through this API; please see the information below. TimingIt may happen that calling up a webhook fails, for example, because your server is not accessible or produces an error message. Laposta will then continue to offer the webhook a number of times (7, to be exact). First after 5 minutes and then in increasing intervals of up to about 14 days. If no contact has been made by then, the webhook is deleted. Bundling eventsEvery 5 seconds, the present webhooks are called. If there happen to be several, they are bundled together, up to a maximum of 1000 events per request. This prevents your server from being overloaded with requests, e.g. when importing larger numbers of subscribers into Laposta. |
||||||||||||||||||||||||||||||||||||||||||||
Structure of a webhookYou will receive an object in JSON format from the URL you have specified. This object consists of an array with the name data, in which the different events are listed. This means that several events can be included in a single request (see above under 'Bundling events').. Fields
Fields info object
|
Example of webhook response{ "data": [ { "type": "member", "event": "deactivated", "data": { "member_id": "9978ydioiZ", "list_id": "BaImMu3JZA", "email": "maartje@example.net", "state": "deleted", "signup_date": "2012-08-13 16:13:07", "ip": "198.51.100.10", "source_url": "http://example.com", "custom_fields": { "name": "Maartje de Vries - Abbink", "dateofbirth": "1973-05-10 00:00:00", "children": 3, "prefs": [ "optionA", "optionB" ] } }, "info": { "source": "app", "action": "deleted", "date_event": "2012-08-17 20:56:31 } } ], "date_requested": "2012-08-17 20:56:34 } |
||||||||||||||||||||||||||||||||||||||||||||
Managing webhooksYou can also manage the webhooks with the API. Below is explained how to retrieve, add and modify webhooks. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
The webhook objectFields
|
Example of webhook object{ "webhook": { "webhook_id": "cW5ls8IVJl", "list_id": "BaImMu3JZA", "created": "2012-10-31 17:03:21", "modified": "2012-10-31 17:12:08", "state": "active", "event": "subscribed", "url": "http://example.net/webhook.asp", "blocked": false } } |
||||||||||||||||||||||||||||||||||||||||||||
Adding a webhookIf there is something wrong with the parameters provided, a code is displayed with an error message. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/webhook Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var webhookService = new LapostaWebhookService("BaImMu3JZA"); LapostaWebhook webhook = new LapostaWebhook(); webhook.Event = "modified"; webhook.Url = "http://example.net/webhook.pl"; webhook.Blocked = false; webhook = webhookService.Create(webhook); Example of response{ "webhook": { "webhook_id": "JH_y9dEsfH", "list_id": "BaImMu3JZA", "created": "2012-10-31 21:08:58", "modified": null, "state": "active", "event": "modified", "url": "http://example.com/webhook.pl", "blocked": false } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting a webhookAll information about a webhook Parameters
|
DefinitionGET https://api.laposta.org/v2/webhook/{webhook_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var webhookService = new LapostaWebhookService("BaImMu3JZA"); LapostaWebhook webhook = new LapostaWebhook(); webhook = webhookService.Get("cW5ls8IVJl"); |
||||||||||||||||||||||||||||||||||||||||||||
Modifying a webhookIf there is something wrong with the parameters provided, a code is displayed with an error message. Fields that are not mentioned will keep their current value fields keep their current value. As soon as a field is mentioned it does get checked, and thus can cause an error message. This error message displays a code with a message. See above under 'Error messages' what the codes stand for. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/webhook/{webhook_id} Example of requestThis example modifies the URL LapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var webhookService = new LapostaWebhookService("BaImMu3JZA"); LapostaWebhook webhook = new LapostaWebhook(); webhook.Url = "http://example.com/dir/webhook.pl"; webhook = webhookService.Update("iH52rJwguo", webhook); Example of response{ "webhook": { "webhook_id": "iH52rJwguo", "list_id": "BaImMu3JZA", "created": "2012-10-31 21:08:58", "modified": "2012-10-31 21:32:21", "state": "active", "event": "modified", "url": "http://example.com/dir/webhook.pl", "blocked": false } } |
||||||||||||||||||||||||||||||||||||||||||||
Deleting a webhookThis permanently deletes a webhook. Potentially outstanding requests from the webhook will still be completed. If the field does not exist, an error message is displayed. In response you are shown another webhook object, but now with the state 'deleted'. After having finished this procedure, it is no longer possible for the user to request the webhook. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/webhook/{webhook_id} Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var webhookService = new LapostaWebhookService("BaImMu3JZA"); LapostaWebhook webhook = new LapostaWebhook(); webhook = webhookService.Delete("8HdlEGtlml"); Example of response{ "webhook": { "webhook_id": "8HdlEGtlml", "list_id": "BaImMu3JZA", "created": "2012-10-31 17:11:15", "modified": null, "state": "deleted", "event": "modified", "url": "http://example.com/laposta.php", "blocked": true } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting all webhooks of a listAll webhooks of a list in an array of member objects. The webhook objects are formatted in an array named 'data'. Parameters
|
DefinitionGET https://api.laposta.org/v2/webhook Example of requestLapostaConfig.apiKey = "JdMtbsMq2jqJdQZD9AHC"; var webhookService = new LapostaWebhookService("BaImMu3JZA"); var webhooks = Enumerable.Empty Example of response{ "data": [ { "webhook": { "webhook_id": "8HdlEGtlml", "list_id": "BaImMu3JZA", "created": "2012-10-31 17:11:15", "modified": null, "state": "active", "event": "modified", "url": "http://example.com/laposta.php", "blocked": false } }, { "webhook": { "webhook_id": "mh7Qao0_lR", "list_id": "BaImMu3JZA", "created": "2012-09-20 14:20:14", "modified": null, "state": "active", "event": "subscibed", "url": "http://example.com/laposta.php", "blocked": false } } ] } |
||||||||||||||||||||||||||||||||||||||||||||
CampaignsRetrieving, creating, filling and sending campaigns. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
The campaign objectFields
|
Example of campaign object{ "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "njhgaf61ye", "created": "2014-12-11 11:26:19", "modified": "2014-12-11 11:27:31", "type": "regular", "delivery_requested": null, "delivery_started": "2014-12-11 11:27:29", "delivery_ended": "2014-12-11 11:27:31", "name": "My first campaign", "subject": "My first campaign", "from": { "name": "Laposta API", "email": "api@laposta.org" }, "reply_to": "api@laposta.org", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/njhgaf61ye", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/9dknAdbAXm.2.png" "226x268": "https://app.laposta.org/clients/images/screenshots/9dknAdbAXm.2.png" } } } |
||||||||||||||||||||||||||||||||||||||||||||
Creating a campaignParameters
The campaign has not yet been filled or scheduled after the request. Use the |
DefinitionPOST https://api.laposta.org/v2/campaign Example of request[No .NET wrapper is available yet for this feature] Example of response{ "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "pbrqulw2tc", "created": "2016-05-16 21:24:12", "modified": null, "type": "regular", "delivery_requested": null, "delivery_started": null, "delivery_ended": null, "name": "Test via API", "subject": "Hello from us", "from": { "name": "Max de Vries", "email": "max@example.net" }, "reply_to": "reply@example.net", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/pbrqulw2tc", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png", "226x268": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png" } } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting a campaignAll information about a campaign Parameters
|
DefinitionGET https://api.laposta.org/v2/campaign/{campaign_id} Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Modifying a campaignYou only have to submit the fields that require to be modified in the application. Fields that are not mentioned will keep their current value fields keep their current value. As soon as a field is mentioned it does get checked, and thus can cause an error message. This error message displays a code with a message. See above under 'Error messages' what the codes stand for. Parameters
|
DefinitionPOST https://api.laposta.org/v2/campaign/{campaign_id} Example of requestThis example changes the subject line. No .NET wrapper is available yet for this feature Example of response{ "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "pbrqulw2tc", "created": "2016-05-16 21:24:12", "modified": "2016-05-16 21:51:27", "type": "regular", "delivery_requested": null, "delivery_started": null, "delivery_ended": null, "name": "Test via API", "subject": "Hello from us, modified", "from": { "name": "Max de Vries", "email": "max@example.net" }, "reply_to": "reply@example.net", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/pbrqulw2tc", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png", "226x268": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png" } } } |
||||||||||||||||||||||||||||||||||||||||||||
Deleting a campaignThis deletes a campaign. Unsent campaigns will be permanently deleted. Campaigns that have been sent are permanently deleted only after 180 days. In the meantime, they can be restored in the overview of campaigns in our program. In response you are shown another campaign object, but now with the state 'deleted'. After having finished this procedure, it is no longer possible for the user to request the campaign. Parameters
|
DefinitionDELETE https://api.laposta.org/v2/campaign/{campaign_id} Example of request[No .NET wrapper is available yet for this feature] Example of response{ "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "az0ndh7akc", "created": "2016-05-16 22:44:49", "modified": "2016-05-16 22:44:49", "type": "regular", "delivery_requested": null, "delivery_started": null, "delivery_ended": null, "name": "Test API 16-05-2016 22:44:49", "subject": "This is the subject", "from": { "name": "Max de Vries", "email": "max@example.net" }, "reply_to": "reply@example.net", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/az0ndh7akc", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png", "226x268": "https://app.laposta.org/clients/images/screenshots/default/113x134_nl.png" }, "state": "deleted" } } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting all campaigns of an accountAll campaigns in an array of campaign objects. The campaign objects have been ordered in an array with the name 'data'. Parameters
|
DefinitionGET https://api.laposta.org/v2/campaign Example of request[No .NET wrapper is available yet for this feature] Example of response{ "data": [ { "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "njhgaf61ye", "created": "2014-12-11 11:26:19", "modified": "2014-12-11 11:27:31", "type": "regular", "delivery_requested": null, "delivery_started": "2014-12-11 11:27:29", "delivery_ended": "2014-12-11 11:27:31", "name": "My first campaign", "subject": "My first campaign", "from": { "name": "Laposta API", "email": "api@laposta.org" }, "reply_to": "api@laposta.org", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/njhgaf61ye", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/9dknAdbAXm.2.png" } } }, { "campaign": { "account_id": "wFiUS4HL4e", "campaign_id": "qzgllqculd", "created": "2014-12-11 11:27:45", "modified": "2014-12-11 11:27:56", "type": "regular", "delivery_requested": null, "delivery_started": null, "delivery_ended": null, "name": "My second campaign", "subject": "My second campaign", "from": { "name": "Laposta API", "email": "api@laposta.org" }, "reply_to": "api@laposta.org", "list_ids": { "kxhysrt26s": [ "2noVadDLbd" ], "t1jmacge9a": [ "GJn80BiYxo" ], "shb5vujyxj": [], "eiwhvx595g": [ "PtIXMx2sG0" ] }, "stats": { "ga": "true", "mtrack": "false" }, "web": "https://laposta-api.email-provider.nl/web/wFiUS4HL4e/qzgllqculd", "screenshot": { "113x134": "https://app.laposta.org/clients/images/screenshots/ClCvez9GXQ.2.png" } } } ] } |
||||||||||||||||||||||||||||||||||||||||||||
Requesting campaign contentRequesting the content of a campaign. Please note that this is only possible if it involves a campaign that has been exported, and not for a campaign created within the application using the drag & drop editor. Parameters
|
DefinitionGET https://api.laposta.org/v2/campaign/{campaign_id}/content Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Filling campaign contentFilling in the content of a campaign ParametersThe campaign can either be filled directly with html, or through a URL, in which case Laposta imports the html found at the specified URL. One of the two must be chosen. If both parameters are given the html is taken.
Report resultIf the import fails, a 400 error message from the API will occur. If it does succeed in importing the html, but problems were found during the import, they are shown in the variable
Solving these problems is not necessary in order to properly send the newsletter, but it is highly recommended. Advertising and unsubscribe linkIn the case of a free account, our advertising is added to the bottom of the newsletter. If the offered html does not contain an unsubscribe link, it will simply be added by our program. |
DefinitionPOST https://api.laposta.org/v2/campaign/{campaign_id}/content Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Sending a campaignDirectly sending a campaign Parameters
Note: A campaign that has been sent before can also be re-sent. The campaign will then only be sent to the addresses that have been added since the last send. |
DefinitionPOST https://api.laposta.org/v2/campaign/{campaign_id}/action/send Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Planning a campaignPlanning a campaign for a later date. Parameters
Note: A campaign that has been sent before can also be re-planned. The campaign will then only be sent to the addresses that have been added since the last send. |
DefinitionPOST https://api.laposta.org/v2/campaign/{campaign_id}/action/schedule Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Testing a campaignSending a test mail Parameters
Note: only in the case of a campaign for which there already is content, but which has not yet been sent, is it possible for a test email to be sent. |
DefinitionPOST https://api.laposta.org/v2/campaign/{campaign_id}/action/testmail Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
ResultsRetrieve the figures of the results of campaigns. |
URL patterns
|
||||||||||||||||||||||||||||||||||||||||||||
The objectFields
|
Example of report object{ "report": { "account_id": "wFiUS4HL4e", "campaign_id": "njhgaf61ye", "sent": 20882, "accepted": 20139, "cleaned": 744, "complained": 1, "hardbounced": 743, "unsubscribed": 184, "opened_unique": 5711, "clicked_unique": 1348, "webversion_unique": 64, "accepted_ratio": 0.96, "opened_ratio": 0.28, "clicked_ratio": 0.07 } } |
||||||||||||||||||||||||||||||||||||||||||||
Results of a campaign requestThe results of a campaign. Parameters
|
DefinitionGET https://api.laposta.org/v2/report/{campaign_id} Example of request[No .NET wrapper is available yet for this feature] |
||||||||||||||||||||||||||||||||||||||||||||
Viewing the results of all campaigns of an accountThe results of all campaigns in an array of list objects. The report objects have been ordered in an array with the name 'data'. Parameters
|
DefinitionGET https://api.laposta.org/v2/report Example of request[No .NET wrapper is available yet for this feature] Example of response{ "data": [ { "report": { "account_id": "wFiUS4HL4e", "campaign_id": "njhgaf61ye", "sent": 20882, "accepted": 20139, "cleaned": 744, "complained": 1, "hardbounced": 743, "unsubscribed": 184, "opened_unique": 5711, "clicked_unique": 1348, "webversion_unique": 64, "accepted_ratio": 0.96, "opened_ratio": 0.28, "clicked_ratio": 0.07 } }, { "report": { "account_id": "wFiUS4HL4e", "campaign_id": "keim8js77f", "sent": 6989, "accepted": 6863, "cleaned": 126, "complained": 0, "hardbounced": 126, "unsubscribed": 260, "opened_unique": 3385, "clicked_unique": 1013, "webversion_unique": 120, "accepted_ratio": 0.98, "opened_ratio": 0.49, "clicked_ratio": 0.15 } } ] } |