Back to all articles

Policy API

The Policy API is used by customers who have the Compliance module in MyCompliance.

API Calls

  1. AddContentResultsPOST
    Used to show Policy content on own systems but add the responses back into MyCompliance. 
  2. GetAllContentGET 
    Used to get all Compliance content for a customer.
  3. GetPolicyResultsGET
    Used to get all results for an individual Policy.
  4. GetPolicyAuditsGET 
    Used to get all Audits for an individual Policy.
  5. GetSurveyResultsGET
    Used to get all results for an individual Survey.
  6. GetSurveyAuditsGET
    Used to get all Audits for an individual Survey.
  7. GetUserPolicyResultGET
    Used to get all the results for a user for an individual Policy. Can be used with GetAllContent to find the correct Policy.
  8. GetUserResultsGET
    Used to get all Compliance results for an individual user.
  9. GetUserSurveyResultGET
    Used to get all the results for a user for an individual Survey. Could be used with GetAllContent to find the correct Survey.

 

API Call Examples


AddContentResults POST

Example

$params = @ ' [{
"ContentID": "1841",
"Name": "Test Audit Policy",
"Email": "testuser1@metacompliance.com",
"Response": "Close Message",
"Timestamp": "2019-03-21T10:16:21.020",
"SaveResult": ""
}]
'@

$url = "https://api.metacompliance.com/Compliance/AddContentResults?key=7025499DFB89-
438F-8F3D-96C2EA0678G9"
$contentType = "application/json"

Invoke - RestMethod $url - Headers $headers - ContentType $contentType - Method POST
-Body $params


JSON returned

[
{
"Email": "testuser1@metacompliance.com",
"Name": "Test Audit Policy",
"ContentID": 1841,
"Response": "Close Message",
"Timestamp": "2019-03-21T10:16:21.02",
"SaveResult": "Data saved"
}
]

Duplicate data error

[
{
"Email": "testuser1@metacompliance.com",
"Name": " Test Audit Policy",
"ContentID": 1841,
"Response": "Close Message",
"Timestamp": "2019-03-21T10:16:21.02",
"SaveResult": "Inserting a duplicate is not allowed."
}
]

 

 

GetAllContent GET

Example

$url = "https://api.metacompliance.com/Compliance/GetAllContent?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9"
$contentType = "application/json"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"ContentID": 1586,
"Name": "Staff Compliance",
"State": "PUBLISH",
"Description": "",
"Type": "Policy",
"MajorVersion": 1,
"MinorVersion": 0
},
{
"ContentID": 1631,
"Name": "Fire Drill",
"State": "PUBLISH",
"Description": "",
"Type": "Policy",
"MajorVersion": 1,
"MinorVersion": 0
}
]

 

 

GetPolicyResults GET

Example

$url = "https://api.metacompliance.com/Compliance/GetPolicyResults?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&contentName=Staff Compliance&contentID=1586"
$contentType = "application/json"

Optional query parameter – customerTimeStamp

$url = "https://api.metacompliance.com/Compliance/GetPolicyResults?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&contentName=Staff Compliance&contentID=1586
&customerTimeStamp=2020-05-29 10:32:00"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET 

JSON returned

{
"ContentID": 1586,
"Name": " Staff Compliance",
"State": "PUBLISH",
"Type": "Policy",
"MajorVersion": 1,
"MinorVersion": 0,
"UserResults": [
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"ContentID": 3731,
"Response": "Close Message",
"Timestamp": "2019-03-03T00:00:00"
},
{
"Email": "testuser2@metacompliance.com",
"UserID": 450547,
"ContentID": 3731,
"Response": "Close Message",
"Timestamp": "2019-03-03T00:00:00"
}
]
}

 


GetPolicyAudits GET

Example

$url = "https://api.metacompliance.com/Compliance/GetPolicyAudits?key=7025499DFB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814"
$contentType = "application/json"

Optional query parameter – customerTimeStamp

$url = "https://api.metacompliance.com/Compliance/GetPolicyAudits?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814
&customerTimeStamp=2020-05-29 10:32:00"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"Response": "Agree",
"PolicyName": " Policy 0710 ",
"Retargeted": "False",
"MetaEngage": "True",
"CampaignName": "-",
"TimeSpent": "-",
"Actions": "False",
"UserID": "263562",
"AdoptionState": "",
"SendCount": "-",
"State": "PUBLISH",
"SCIMPostcode": "-",

"ContentID": "121127",
"Name": "Test User 1",
"Email": "testuser1@metacompliance.com",
"Department": "Development",
"Version": "1.0",
"Timestamp": "2021-10-07",
"UserStatus": "Active",
"CollectiveName": "-",
"SubGroup": "-",
"UserType": "AD",
"OU": "Development",
"Domain": "metacompliance",
"SCIMDepartment": "-",
"SCIMStreetAddress": "-",
"SCIMRegion": "-",
"SCIMCountry": "-",
"SCIMLocality": "-",
"SCIMGroup": "-",
"EnrollmentDate": "2021-10-07",
"Supervisor": "-",
"SupervisorsManager": "-",
"CF1": "-",
"CF2": "-",
"AnonResponse": null
}




GetSurveyResults GET

Example

$url = "https://api.metacompliance.com/Compliance/GetSurveyResults?key=7025499DFB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814"
$contentType = "application/json"

Optional query parameter – customerTimeStamp

$url = "https://api.metacompliance.com/Compliance/GetSurveyResults?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814
&customerTimeStamp=2020-05-29 10:32:00"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

{
"ContentID": 3814,
"Name": "Survey Test",
"State": "PUBLISH",
"Type": "Survey",
"PassMark": 0,
"MajorVersion": 1,
"MinorVersion": 0,
"UserResults": [
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"ContentID": 3814,
"AuditStatus": "Completed",
"Timestamp": "2019-03-03T00:00:00",
"Attempts": 1
}
]
}

 

 

GetSurveyAudits GET
Example

$url = "https://api.metacompliance.com/Compliance/GetSurveyAudits?key=7025499DFB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814"
$contentType = "application/json"

Optional query parameter – customerTimeStamp

$url = "https://api.metacompliance.com/Compliance/GetSurveyAudits?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&contentName=Survey Test&contentID=3814
&customerTimeStamp=2020-05-29 10:32:00"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"SurveyName": "Survey 2",
"AuditID": "0",
"UserID": "751452",
"Status": "-",
"Attempts": "0",
"Score": "0",
"Actions": "False",
"Retargeted": "False",
"FirstSurveyScore": "-",
"FirstAttemptDate": "-",
"MetaEngage": "False",
"ManageInCampaign": null,
"SurveyType": "Opinion",
"CampaignName": "-",
"AdoptionState": "Not Request Exemption",
"SendCount": "-",
"State": "PUBLISH",
"SCIMPostcode": "-",

"ContentID": "121425",
"Name": "Test User1",
"Email": "testuser1@metacompliance.com",
"Department": "Development",
"Timestamp": "-",
"UserStatus": "Active",
"CollectiveName": "-",
"SubGroup": "",
"UserType": "AD",
"OU": "Development",
"Domain": "metacompliance",
"SCIMDepartment": "-",
"SCIMStreetAddress": "-",
"SCIMRegion": "-",
"EnrollmentDate": "2021-10-14",
"Supervisor": "-",
"SupervisorsManager": "-",
"CF1": "-",
"AnonResponse": null
}
]

 

 

GetUserPolicyResult GET
Example

$url = "https://api.metacompliance.com/Compliance/GetUserPolicyResult?key=7025499DFB89-
438F-8F3D-96C2EA0678G9&email=testuser1@metacompliance.com&contentID=2057"
$contentType = "application/json"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"Name": "Policy Result Test",
"ContentID": 2057,
"Response": "Close Message",
"Timestamp": "2019-03-03T00:00:00"
},
{
"Email": "testuser1@metacompliance.com",
"UserID": 450547,
"Name": " Policy Result Test",
"ContentID": 2057,
"Response": "Request Exemption",
"Timestamp": "2019-03-03T00:00:00"
}
]

 

 

GetUserResults GET
Example

$url = "https://api.metacompliance.com/Compliance/GetUserResults?key=7025499D-FB89-
438F-8F3D-96C2EA0678G9&email=testuser1@metacompliance.com"
$contentType = "application/json"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"Name": "Test Policy 1
"ContentID": 21419,
"Response": "Close Message",
"Timestamp": "2019-03-21T10:16:21.02"
},
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"Name": "Test Policy 2",
"ContentID": 21586,
"Response": "Close Message",
"Timestamp": "2019-03-21T10:16:21.02"
},
]

 

 

GetUserSurveyResult GET
Example

$url = "https://api.metacompliance.com/Compliance/GetUserSurveyResult?key=7025499DFB89-
438F-8F3D-96C2EA0678G9&email=testuser1@metacompliance.com&contentID=22773"
$contentType = "application/json"

Invoke-RestMethod $url -Headers $headers -ContentType $contentType -Method GET

JSON returned

[
{
"Email": "testuser1@metacompliance.com",
"UserID": 450546,
"Name": "Test Survey",
"ContentID": 22773,
"AuditStatus": "Completed",
"Timestamp": "2019-07-15T13:50:57.913",
"FirstSurveyScore": 100,
"FinalSurveyScore": 100,
"Attempts": 1
}
]