List all user relationships in Skillhive
Endpoint: /api/v2/user-relationships
Method | Action | Parameters |
---|---|---|
GET | List user relationships |
|
An example of a return response:
{
"data": [ // The returned user relationship collection
{ // A relationship object
"type": "user-relationships",
"id": "12345", // The user relationship id
"attributes": {
"relationship": "subordinate",
"created-at": "Wed, 21 May 2014 10:11:24 +0300",
"updated-at": "Tue, 03 Jun 2014 12:28:56 +0300"
},
"relationships": {
"target": {
"data": {
"type": "users",
"id": "9876" // This is the user Id of the "target" of the relationship
}
}
}
},
... // More user relationships
],
"meta": {
"total-count": 5 // Number of user relationships.
}
}
Delete a single user relationship
Endpoint: /api/v2/user-relationships/:user_relationship_id
Method | Action | Parameters |
---|---|---|
DELETE | Delete the relationship defined by user_relationship_id |
N/A |
Create a new user relationship
Endpoint: /api/v2/user-relationships
Method | Action | Parameters |
---|---|---|
POST | Create user relationship |
You can add new user relationships to Skillhive by doing a POST
request to the api endpoint. Here's an example, to create a subordinate
relationship between two users. In this example user 9876
is the supervisor of user 1234
.
{
"data": {
"type": "user-relationships",
"attributes": {
"relationship": "subordinate",
},
"relationships": {
"user": {
"data": { // This is the user ID of the "owner" of the
"type": "users", // relationship. In this example this is the subordinate.
"id": "1234" // This is usually the loggedin user whos is creating
} // the relationship.
},
"target": {
"data": {
"type": "users", // This is the user ID of the "target" of the
"id": "9876" // relationship. In this example this is the supervisor.
}
}
}
}
}
The API endpoint will return a 201 Created
response with all the data for the newly created relationsip. If a non-admin user tries to create new relationship for someone else, they will get a 403 Forbidden
response instead.