Bulk update (synchronous)
This updates and/or creates a number of sender entries at once.
With this endpoint, you can update or create many sender objects in one call. This endpoint is only available for users with SI-FULL participant status.
File types
The content type can be JSON (application/json) or CSV (text/csv).
If the content-type is JSON, the expected data format is a list of objects you would send to the senders_create or senders_update endpoints. Note that partial updates are not supported for this endpoint; each element should contain all the data of the sender that is to be published.
If the content type is CSV, the data format is as follows:
- No headers line
- Double quotes as the quotation mark
- Comma as the separator
The line elements are as follows:
- Organisation name
- ISO6523 scheme
- ISO6523 Identifier
- (Optional) Website URL
- (Optional) Contact e-mail address
Example CSV FILE:
"Example Company 1", "0106", "11111111", "https://ionite.net", "example@example.nl",
"Example Company 1", "0106", "11111112", "https://ionite.net",,
"Example Company 2", 106, "22222221", , ,
Data handling
The data is handled as follows, for each sender element in the data:
- if an id value is present (JSON only), the Sender with the given id is updated
- if not, the sender is searched by the iso6523 scheme and identifier
- if it exists, that one is updated
- if not, a new sender is created
This update is not transactional; every update/create will happen even if some fail.
Returns an object of the following form:
{
'entries updated': integer,
'entries created': integer,
'errors': integer,
'data': [ <list of entry results, see below> ]
}
Each entry in the data list contains the following elements:
{
'index': the index of the element in the original bulk request (integer),
'input_data': the input data of the element in the original request (dict)
'success': true if update/create was successful, false if there was an error (boolean)
'saved_data': if the status was 'success', contains the saved data (dict)
'errors': if the status was 'error', contains a dict of errors
}
The result HTTP code is 200 if ALL updates/creates were successful, 400 if none were, and 202 if some were
Method and endpoint:
POST https://peppol-senders.nl/api/senders/bulk_update/
Headers:
Authorization: Token <your auth token>
Content-Type: application/json
Accept: application/json
Example
Post data:
[
{
"email": "example@ionite.net",
"iso6523_identifier": "1111122222",
"iso6523_scheme": 106,
"name": "Ionite"
},
{
"email": "example@example.nl",
"iso6523_identifier": "12345678",
"iso6523_scheme": 106,
"name": "Example Company 1",
"website": "badwebsite"
},
{
"email": "badaddress",
"iso6523_identifier": "00000001234561",
"iso6523_scheme": 190,
"name": "Example Company 1 Holding",
"website": null
},
{
"email": "example@example.net",
"iso6523_identifier": "12345678",
"iso6523_scheme": 106,
"name": "Example Company 2",
"updated_on": "2018-11-22T19:53:01.117287Z",
"website": "https://example.nl"
}
]
Response code: 202
Response data:
{
"data": [
{
"created": true,
"index": 0,
"input_data": {
"email": "example@ionite.net",
"iso6523_identifier": "1111122222",
"iso6523_scheme": 106,
"name": "Ionite"
},
"saved_data": {
"api_url": "https://peppol-senders.nl/api/senders/5029/",
"created_on": "2018-11-28T23:28:48.581168Z",
"email": "example@ionite.net",
"email_verified": true,
"id": 5029,
"iso6523_identifier": "1111122222",
"iso6523_scheme": 106,
"iso6523_verified": true,
"name": "Ionite",
"updated_on": "2018-11-28T23:28:48.581187Z",
"website": null
},
"success": true
},
{
"created": false,
"errors": {
"website": [
"Enter a valid URL."
]
},
"index": 1,
"input_data": {
"email": "example@example.nl",
"iso6523_identifier": "12345678",
"iso6523_scheme": 106,
"name": "Example Company 1",
"website": "badwebsite"
},
"success": false
},
{
"created": false,
"errors": {
"email": [
"Enter a valid email address."
]
},
"index": 2,
"input_data": {
"email": "badaddress",
"iso6523_identifier": "00000001234561",
"iso6523_scheme": 190,
"name": "Example Company 1 Holding",
"website": null
},
"success": false
},
{
"created": true,
"index": 3,
"input_data": {
"email": "example@example.net",
"iso6523_identifier": "12345678",
"iso6523_scheme": 106,
"name": "Example Company 2",
"updated_on": "2018-11-22T19:53:01.117287Z",
"website": "https://example.nl"
},
"saved_data": {
"api_url": "https://peppol-senders.nl/api/senders/5030/",
"created_on": "2018-11-28T23:28:48.603156Z",
"email": "example@example.net",
"email_verified": true,
"id": 5030,
"iso6523_identifier": "12345678",
"iso6523_scheme": 106,
"iso6523_verified": true,
"name": "Example Company 2",
"updated_on": "2018-11-28T23:28:48.603177Z",
"website": "https://example.nl"
},
"success": true
}
],
"entries_created": 2,
"entries_updated": 0,
"errors": 2
}
Example with CSV File
Headers:
Accept: application/json
Content-Type: text/csv
Authorization: Token c58a93962eaa75fbebb92abd41fbc62c4d0f09e7
Post data:
"Example Company 1", "0106", "11111111", "https://ionite.net", "example@example.nl",
"Example Company 1", "0106", "11111112", "https://ionite.net",,
"Example Company 2", 106, "22222221", , ,
Response code: 200
Response data:
{
"data": [
{
"created": false,
"index": 0,
"input_data": {
"email": "example@example.nl",
"iso6523_identifier": "11111111",
"iso6523_scheme": 106,
"name": "Example Company 1",
"website": "https://ionite.net"
},
"saved_data": {
"api_url": "http://localhost:9001/api/senders/10036/",
"created_on": "2018-11-29T23:18:09.909639Z",
"email": "example@example.nl",
"email_verified": true,
"id": 10036,
"iso6523_identifier": "11111111",
"iso6523_scheme": 106,
"iso6523_verified": true,
"name": "Example Company 1",
"updated_on": "2018-11-29T23:22:11.674358Z",
"website": "https://ionite.net"
},
"success": true
},
{
"created": false,
"index": 1,
"input_data": {
"iso6523_identifier": "11111112",
"iso6523_scheme": 106,
"name": "Example Company 1",
"website": "https://ionite.net"
},
"saved_data": {
"api_url": "http://localhost:9001/api/senders/10037/",
"created_on": "2018-11-29T23:18:09.939389Z",
"email": null,
"email_verified": false,
"id": 10037,
"iso6523_identifier": "11111112",
"iso6523_scheme": 106,
"iso6523_verified": true,
"name": "Example Company 1",
"updated_on": "2018-11-29T23:22:11.692733Z",
"website": "https://ionite.net"
},
"success": true
},
{
"created": false,
"index": 2,
"input_data": {
"iso6523_identifier": "22222221",
"iso6523_scheme": 106,
"name": "Example Company 2"
},
"saved_data": {
"api_url": "http://localhost:9001/api/senders/10038/",
"created_on": "2018-11-29T23:18:09.969367Z",
"email": null,
"email_verified": false,
"id": 10038,
"iso6523_identifier": "22222221",
"iso6523_scheme": 106,
"iso6523_verified": true,
"name": "Example Company 2",
"updated_on": "2018-11-29T23:22:11.709962Z",
"website": null
},
"success": true
}
],
"entries_created": 0,
"entries_updated": 3,
"errors": 0
}