URL structure
1 https://access-service.xy-company.com/api/v1/users/me/contacts
Supported methods and overview
Detailed description
This API endpoint serves a number of purposes:
- Creates a new contact for a Cocoon Data user (whose access token is submitted in the request to this endpoint). This contact consists of a mandatory email address as well as optional first and last names.
Notes:
- A contact can be created for any person who does not have a registered Cocoon Data user account. However, if the Cocoon Data user successfully shares an item with this contact, then a new Cocoon Data user account is automatically created for this contact (with the Ad hoc role).
- A contact can also be created through the Contacts feature of SafeShare for Web.
- Retrieves a list of information for all contacts of a Cocoon Data user (whose access token is submitted in the request to this endpoint). The list of contacts returned in the response can be filtered according to contacts whose email address, first name or last name contains the string specified in the request.
Supported roles
This API endpoint supports requests utilizing Cocoon Data user accounts with the following roles (as described in the Organisation Administrator's Guide) and conditions:
The Cocoon Data Platform's resources available to a Cocoon Data user meeting the criteria above is determined by the access token submitted in the header of requests to this endpoint.
Required headers
The appropriate access token as the Bearer
token:
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE0NjcwMTY2NjYsInVzZXJfbmFtZSI6ImFsZXgub...
The following header is required if the body of the request has a JSON object:
Content-Type: application/json
Required POST-request parameters
The following required parameters must be sent in the body of the POST request, each as individual members of a JSON object:
-
contacts - An array of elements about each contact to be created for the Cocoon Data user (whose access token is submitted in the request to this endpoint). Each element of this array contains the sub-element email (in an object), whose value is the email address of a contact.
-
ignoreDuplicates - A boolean value of:
-
true
to force a valid request to return an HTTP response of 200 OK
(along with a JSON-formatted object with additional data) in the event that existing contacts of this Cocoon Data user match any contacts in the request payload. In such instances, these matching contacts in the request are ignored.
-
false
to return an HTTP response of 400 Bad Request
(along with a JSON-formatted object containing an appropriate message) in the event that an existing contact of this user matches any contact in the request payload. In such instances, no contact in the request payload is created for this user.
Example (POST request): {
"contacts": [
{
"email": "chris.collaborator@xy-company.com"
}
],
"ignoreDuplicate": true
}
Optional POST-request parameters
The following optional parameters can also be sent in the body of the POST request, each as individual members/sub-elements of the JSON object that includes the Required POST-request parameters above:
-
contacts - An array of elements containing one or more of the following sub-elements (relating to the email sub-element above).
-
firstName - The first name for the contact.
-
lastName - The last name for the contact.
Example (POST request with optional parameters): {
"contacts": [
{
"email": "chris.collaborator@xy-company.com",
"firstName": "Chris",
"lastName": "Collaborator"
},
{
"email": "olly.originator@xy-company.com"
}
],
"ignoreDuplicate": true
}
Optional GET-request parameters
The following optional parameters can be sent in the URL of the GET request:
-
searchText - Any text substring used to filter for all contacts of the Cocoon Data user (whose access token is submitted in the request to this endpoint), where this text substring must match that of the contact's email address, first name or last name. If this parameter is omitted, then no filtering is performed.
-
limit - An integer value from
0
to 100
, representing the maximum number of items to be returned in the response from the Cocoon Data Platform, where an individual item is information about a contact of this Cocoon Data user. If this parameter is omitted, then its value is 10
by default.
-
offset - A value representing the count order of all retrievable items (i.e. contacts of this Cocoon Data user) from the Cocoon Data Platform returned in the response. Calls to this API endpoint may amount to potentially unmanageable numbers of items being returned. Therefore, this offset parameter provides pagination for items returned in responses, allowing items to be retrieved from any count greater than
0
(i.e. the first item returned in a response). If this parameter is omitted, then its value is 0
by default.
Example (GET request): 1 https://access-service.xy-company.com/api/v1/users/me/contacts?searchText=xy-company
Returns
If the request succeeded, then an HTTP response status 200 OK
is returned.
For successful requests only, a JSON-formatted response containing the following members is also returned:
-
items - An array containing information about contacts of the Cocoon Data user (whose access token is submitted in the request to this endpoint), either which:
-
have been created for this user (via a
POST
request), or
-
this user currently has (via a
GET
request) filtered by any parameters submitted in the request.
Each element of this array contains information about one of these contacts (represented as an object containing the following members unless otherwise stated):
-
id - The ID of the contact.
-
email - The email address of the contact.
-
firstName - The optional first name of the contact. If this value was not specified when the contact was created and/or last modified, then its value is
null
.
-
lastName - The optional last name of the contact. If this value was not specified when the contact was created and/or last modified, then its value is also
null
.
-
createdAt - The date and time when the contact was created.
-
modifiedAt - The date and time when the contact was last modified.
-
count - The maximum number of items (i.e. all contacts of this Cocoon Data user) that can be returned in the response.
Notes:
-
If the searchText parameter was specified in the request, then this value represents the number of items (above) returned in the response.
-
This value is always
0
for responses returned from POST
requests to this endpoint.
-
offset - The value of the offset which had been used in the
GET
request to this endpoint. This value is always 0
for responses returned from POST
requests to this endpoint.
Example (response from a POST request): {
"items": [{
"id": "762179066710499328",
"email": "chris.collaborator@xy-company.com",
"firstName": "Chris",
"lastName": "Collaborator",
"modifiedAt": "2016-10-04T05:07:30.106Z",
"createdAt": "2016-10-04T05:07:30.106Z"
}, {
"id": "762179066710499329",
"email": "olly.originator@xy-company.com",
"firstName": null,
"lastName": null,
"modifiedAt": "2016-10-04T05:07:30.106Z",
"createdAt": "2016-10-04T05:07:30.106Z"
}],
"count": "0",
"offset": "0"
}