Introduction
Welcome to the Moodwork Public API, You can use our API to acces Moodwork's API endpoints, which can get enables us to manage users leaving your company.
We have language bindings in Shell, Ruby, Python, and JavaScript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
Authentication
To authorize, use this code:
require 'net/http'
uri = URI("https://public-api.moodwork.com/v3/users/delete")
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = "application/json"
req['Authorization'] = "Bearer mydeveloperkey"
import http.client
import requests
import json
url = "https://public-api.moodwork.com/v3/users/delete"
payload = {}
headers = {
'Authorization': 'Bearer mydeveloperkey',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
# With shell, you can just pass the correct header with each request
curl "https://public-api.moodwork.com/v3/users/delete" \
-H "Authorization: Bearer mydeveloperkey" -H "Content-Type: application/json"
const options = {method: 'POST', headers: {Authorization: 'Bearer mydeveloperkey', Content-Type: 'application/json'}};
fetch('https://public-api.moodwork.com/v3/users/delete', options)
Make sure to replace
mydeveloperkey
with your API key.
Moodwork uses API keys to allow access to the Public API. You can ask a new Moodwork API key at our IT department.
Moodwork expects for the API key to be included in all API requests to the server in a header that looks like the following:
Authorization: Bearer mydeveloperkey
User Management
Delete User from Moodwork's Database
require 'kittn'
require "uri"
require "json"
require "net/http"
url = URI("https://public-api.moodwork.com/v3/users/delete")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer mydeveloperkey"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"emails": [
"john.doe@mycompany.com",
"ashley.doe@mycompany.com"
]
})
response = http.request(request)
puts response.read_body
import requests
import json
url = "https://public-api.moodwork.com/v3/users/delete"
payload = json.dumps({
"emails": [
"john.doe@mycompany.com",
"ashley.doe@mycompany.com"
]
})
headers = {
'Authorization': 'Bearer mydeveloperkey',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
curl --location --request POST 'https://public-api.moodwork.com/v3/users/delete' \
--header 'Authorization: Bearer mydeveloperkey' \
--header 'Content-Type: application/json' \
--data-raw '{
"emails": [
"john.doe@mycompany.com",
"ashley.doe@mycompany.com"
]
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer mydeveloperkey");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"emails": [
"john.doe@mycompany.com",
"ashley.doe@mycompany.com"
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://public-api.moodwork.com/v3/users/delete", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"status": "deleted",
}
]
This endpoint delete all users from moodwork's database.
HTTP Request
POST https://public-api.moodwork.com/v3/users/delete
Query Parameters
Parameter | Default | Description |
---|---|---|
emails | empty Array | An array which contains the list of email to delete |
Errors
The Moodwork's API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is wrong. |
403 | Forbidden -- The resource requested is hidden for administrators only. |
404 | Not Found -- The specified url could not be found. |
406 | Not Acceptable -- You requested a format that isn't json. |
429 | Too Many Requests -- You're requesting the server too many time, Slow down. |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |