Overview
This API lets developers integrate with the SWEAP system to allow for administration outside of the user interface. The API has methods for retrieving user entitlements, assigning remote assessments, retrieving completed assessment reports.
About the API
This API is automatically available to all paying SWEAP users opting for enhanced integration assessments, and the integration details are available via the user interface.
Documented properties will not be removed within a stable version of the API. Once a given API endpoint is documented to return a given property, a property with that name will always appear (although certain properties may only appear under certain conditions, like if the customer is using a specific variation). When SWEAP deprecates a property, the API continues to accept that property in requests, although it no longer has any effect.
Properties that enumerate choices may gain new values at any time, e.g. the formtype
value could return new type of instrument that did not previously exist. SWEAP may cease to return legacy values for properties as well. SWEAP will update our API documentation with changes to property values in a timely fashion, adding new property values or indicating changes to existing property values.
New, undocumented properties may also appear at any time. For instance, SWEAP may make available a beta feature involving extra information returned by an API endpoint. Until the property is documented here its format may change or it may even be entirely removed from our API.
Conventions
The end user can retrieve a single API key for all entitlements for their program or receive individual API keys for each individual assessment type. This allows for flexibility in implementation.
Each program will have a unique four digit alphanumeric code identifying that program and this is generally a prefix on all actions within the system.
Each program will have at least one program director / field coordinator / administrative assistant who purchases and renders reports for the program. This document shall refer to this as administrators.
All times are represented in GMT / UTC.
The standard workflow for an administrator is as follows
- The assessments are purchased from the store
- Each order is then administrated in various ways where they may opt to assign each to a student. field instructor, or graduate. This document will refer to these people as respondents.
- The administrators will assemble completed assessments into a report
The workflow for a standard instrument administration is as follows, and this represents the status.
- START – an unused instrument, the beginning of the process.
- IN PROGRESS – an instrument underway, the respondent has not pressed “Save”
- SAVED – the respondent has pressed “Save” but has not opted to mark this as final. An administrator may deem this as a reportable status.
- FINISHED – the respondent has pressed the option to mark instrument as final.
- CANCELLED – the instrument was marked for exchange and is unusable.
API Details
Base URL
All API methods use the following url: https://sweapinstruments.org/api
Methods always use HTTPS. Unsecured HTTP is not supported. This integration communications via TCP port 443. Also, we do not recommend locking down your firewall to whitelist to individual IP addresses as the address may change at any time.
Request Format
All requests must have “Authorization” header.
If the request method is GET
or DELETE
, URL-encode parameters and send them in the URL query string like this: /api/assign?realname=First%20Last&assessment=ABCD12345
. They still go on a separate line when creating the string to sign for an Authorization header.
Send parameters for POST
requests in the body as URL-encoded key-value pairs (the same request format used by browsers to submit form data). The header “Content-Type: application/x-www-form-urlencoded
” must also be present.
When URL-encoding, all bytes except ASCII letters, digits, underscore (“_”), period (“.”), tilde (“~”), and hyphen (“-“) are replaced by a percent sign (“%”) followed by two hexadecimal digits containing the value of the byte. For example, a space is replaced with “%20” and an at-sign (“@”) becomes “%40”. Use only upper-case A through F for hexadecimal digits.
Response Format
Responses are formatted as a JSON object with a top-level stat
key.
Successful responses will have a stat
value of “OK” and a response
key. The response
will either be a single object or a sequence of other JSON types, depending on which endpoint is called.
{
"stat": "OK",
"response": {
"key": "value"
}
}
Values are returned as strings unless otherwise documented.
Unsuccessful responses will have a stat
value of “FAIL”, an integer code
, and a message
key that further describes the failure. A message_detail
key may be present if additional information is available (like the specific parameter that caused the error).
{
"stat": "FAIL",
"code": 40002,
"message": "Invalid request parameters",
"message_detail": "username"
}
The HTTP response code will be the first three digits of the more specific code
found inside the JSON object. Each endpoint’s documentation lists HTTP response codes it can return. Additionally, all API endpoints that require a signed request can return the following HTTP response codes:
Response | Meaning |
---|---|
200 | The request completed successfully. |
401 | The “Authorization”, “Date”, and/or “Content-Type” headers were missing or invalid. |
403 | This integration is not authorized for this endpoint |
405 | The request’s HTTP verb is not valid for this endpoint (for example, POST when only GET is supported). |
429 | The account has made too many requests of this type recently. Try again later. |
Authentication
The API uses HTTP Basic Authentication to authenticate requests. Use your SWEAP integration key as the HTTP Username, with the password being the integration secret.
To view available integration keys and secrets, refer to the table below.
Please Login to View Credentials
Available Instruments
Retrieve All Available Instruments
This returns the available administration status and URLs for the login supplied. This represents a drill down screen on the individual instrument administration screen.
GET /api/forms
Parameters
Parameter | Required? | Description |
showurl | Optional | Include the administration, integration, reporting URLs. Default is true. |
showid | Optional | Include the internal id number. Default is false. |
form | Optional | The form type, generally 2 letter code to show. Default is all available types. |
updated_since | Optional | If supplied, this should be an ISO-8601 formatted GMT timestamp, i.e. 2021-01-01 17:00:00 |
Response Codes
Response | Meaning |
---|---|
200 | Success. Returns a list of users. |
400 | Invalid parameters. |
Response Format
Key | Value | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
programs | a key value pair identifying program code and the human readable name for the program. | ||||||||||||||||||||||||||||||||||||||
data |
This returns an array of assessment objects, as described below. Each assessment row represents an administration, where each should be administrated to a single student or graduate.
|
Assigning To Respondent
Assign Assessment To A Respondent
This optional service allows an assessment to have an email address or student name assigned before administration to a respondent.
GET /api/assign
Parameters
Parameter | Required? | Description |
id | Required | The alphanumeric id number representing the assessment |
emails | Optional | The email addresses or SMS numbers, comma separated of the respondents |
name | Optional | The repondent’s name |
category | Optional | Additional metadata field for program internal usage. This data is visible on the user interface. |
content | Optional* | If emails and name parameters are supplied, this non HTML, plain-text only field will send an email utilizing our messaging service to send this assessment. There are two special fields, ###student_name### and ###uniquecode### that if they are not found in the content, will be appended to the end of the email, and are substituted within the content if found. |
subject | Optional* | If content is populated, this is the subject line for the email. The same replacement variable rules apply from content. Default is “Please Fill Out Assessment for ##STUDENT_NAME###” |
delay | Optional* | If the parameter content is set, this optional field representing the Unix GMT epoch time can be set indicating when this should be emailed. Past times indicate immediately. |
suppress_email | Optional | If any value is passed, the emailing feature will be disabled, allowing for setting email and contact assignment without utilizing the SWEAP email service. |
assignee_emails | Optional | If this value is supplied, this will add the supplied email to a separate, parallel email service to the instrument. The same content and subject data will emailed. More than one email can be provided space separated. |
assignee_names | Optional | If this value is supplied, this will store the assignee’s name to the instrument. |
Response Codes
Response | Meaning |
---|---|
200 | Success. Returns a list of users. |
400 | Invalid parameters. |
Response Format
Key | Value |
---|---|
diagnostics | Email Diagnostic data if content parameter is set. |
Unassigning Existing Data From An Assessment
Unassigning Assessment To A Respondent
This sparingly used service is the opposite of the assignment service and can be leveraged to exchange an existing administration code for a new clone. Only assessments in a non-cancelled status may be exchanged this way. If an instrument is already reported on or is in a completed status, the data is marked unusable for future reporting. This service returns the newly cloned administration code in the response. The list available on the /api/forms api will also be updated.
GET /api/unassign
Parameters
Parameter | Required? | Description |
id | Required | The alphanumeric id number representing the assessment |
Response Codes
Response | Meaning |
---|---|
200 | Success. Returns a new assessment code in the created field.. |
400 | Invalid parameters. |
Response Format
Key | Value |
---|---|
diagnostics | Email Diagnostic data if content parameter is set. |
Export Completed Assessment
Save Copy Of An Assessment
This returns a copy of the assessment, after it has reached SAVED or FINISHED status in either RTF or PDF format.
Parameters
Parameter | Required? | Description |
id | Required | The alphanumeric id number representing the assessment |
format | Required | Current allowed formats are PDF and RTF. |
Response Codes
Response | Meaning |
---|---|
200 | Success. Returns a list of users. |
400 | Invalid parameters. |
Response Format
Key | Value |
---|---|
data | A Base-64 encoded string representing the exported file requested. |
Available Instruments Summary
Retrieve Summary
This returns the available instruments assessments available along with the current status in bulk format. This shows all available classes of instruments available for administration and also represents the “Instruments” screen when logging into the system via regular UI.
GET /api/entitlements
Parameters
none required
Response Codes
Response | Meaning |
---|---|
200 | Success. Returns a list of users. |
400 | Invalid parameters. |
Response Format
Key | Value | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
program | The program’s internal unique id. | ||||||||||||||||||||||||||||
name | The program’s human readable name. | ||||||||||||||||||||||||||||
entitlements |
Each available type of instruments available for administration
|