The feature Send Invitations → API access allows the following functions:
An essential application of the API function for serial mails is the connection of a shop system. For example, you can send a valid participation link to the questionnaire to a customer after purchasing the access authorization.
Usually, SoSci Survey creates a personalized URL to participate in a survey in the moment you send a serial mail. As an alternative, use Access Codes to manually create personalized links, but with restrictions on anonymity and functionality - and access codes (serial numbers) require a different access restriction in the questionnaire than serial emails.
With the Send invitations function → API access you can create personalized links to the questionnaire and, if necessary, use them in external software that works in the same way as the personalized links in serial mail. However, this does not necessarily send an e-mail. If no serial mail is to be sent, not even an e-mail address is necessary.
When calling the API URL, SoSci Survey expects one of the following identification features for the (possibly new) address entry to be transmitted via GET or POST:
If the API URL is https://www.soscisurvey.de/PROJEKT/?act=83w7vaYqaeakXH7axpH2Yexu
, a valid call might look something like this. An identifier (uid, user ID) is used as an identification feature:
https://www.soscisurvey.de/PROJEKT/?act=83w7vaYqaeakXH7axpH2Yexu&uid=112233aabbcc
If a matching entry is found in the List of Contacts, it is used. Otherwise a new entry will be created in the List of Contacts.
SoSci Survey now creates a valid participation link and returns it in response to the call as JSON.
The answer to a valid request could look something like this:
{ "result": "ok", "token": "QS33T6XMVS4KLA9S", "url": "https:\/\/www.soscisurvey.de\/PROJECT\/?d=QS33T6XMVS4KLA9S", "error": null }
If successful, the field result
contains the value ok
, otherwise a different value. In addition, an error message is returned in error
. Here, for example, is the answer to a call without an identification feature:
{ "result": "error", "error": "Request must specify email, mobile, or uid", "url": null }
The API access is designed for an automated call by an external software (machine-to-machine communication), can also be “abused” to create manually valid participation links.
To do this, create an API link as described above. Then call the API URL with different identification features. For example, with the identifiers respondent01
, respondent02
, respondent03
, …
The participant ID must be entered manually in the address line.
https://www.soscisurvey.de/PROJEKT/?act=83w7vaYqaeakXH7axpH2Yexu&uid=respondent01 https://www.soscisurvey.de/PROJEKT/?act=83w7vaYqaeakXH7axpH2Yexu&uid=respondent02 https://www.soscisurvey.de/PROJEKT/?act=83w7vaYqaeakXH7axpH2Yexu&uid=respondent03
Your browser displays a valid participation URL after each call, which can be sent to the participants by e-mail, for example.
A feature to automatically create a larger number of participation links without external software is planned, but currently only with low priority. If anonymity is not critical (or if it is particularly critical), the serial numbers feature can be used.
When calling the API URL, SoSci Survey expects a parameter serial to be submitted with the serial number to be checked.
If the API URL is https://www.soscisurvey.de/PROJEKT/?act=exu83w7vaYqaeakXH7axpH2Y
, a valid call to check the serial number “CD246802” might look something like the following.
https://www.soscisurvey.de/PROJEKT/?act=exu83w7vaYqaeakXH7axpH2Y&serial=CD246802
The return value is a JSON string with the following structure:
{ result: "ok", code: "CD246802", started: true, completed: false, notice: "", error: null }
The attributes have the following meaning:
result
– Return value of the request, can take the value “ok” or “error”.code
– The queried serial numberstarted
– Was the serial number used to start a questionnaire (boolean)completed
– If the started questionnaire was filled in to the last page (boolean)notice
– A note possibly stored for the serial numbererror
– Error message if result
has the value “errorIn case of an error only the status code and an error message are returned, if available also the requested serial number:
{ result: "error", error: "not found", code: "CD246802" }
When calling the API URL, SoSci Survey expects at least one parameter to identify the address entry. If multiple properties are specified, the system searches for an address entry that has all properties. The address entry can be searched for using the following properties:
serial
→ Person code of the address entryemail
→ Email addressmobile
→ Mobile phone numberuid
→ Unique ID of the address entry
If the API-URL is https://www.soscisurvey.de/PROJEKT/?act=erSoqORu4OPzGeWyetpwmbMu
, a valid call to check for the participation status may look like this.
https://www.soscisurvey.de/PROJECT/?act=exu83w7vaYqaeakXH7axpH2Y&email=person@example.com
In return you get a JSON-String with this structure:
{ result: "ok", serial: null email: "person@example.com" mobile: null uid: null mailings: { M1: { id: 1 status: "sent" statusMail: "delivered" statusSMS: "none" sendTime: "2023-11-09" }, M2: { id: 2 status: "skipped", statusMail: "none", statusSMS: "none", sendTime: "2023-07-02" } }, error: null }
The search parameters used are returned in the first part of the response.
The participation status is specified for each serial mail for which sending to this address entry was attempted. The key used for the mailings
is “M” and the ID of the serial mail.
In the event of an error, only the status code and an error message are returned, if available also the requested participation code.
{ result: "error", error: "not found", serial: null email: "nobody@example.com" mobile: null uid: null }