Twona Developers

Documentation of the Twona API v2.

Index

Short Description

The Twona API allows you manage many aspects of your Organization, from user and group management, data related to requests and file management.

Authentication

Authentication is done with an API token that is sent in the header of each HTTP request under Access-token. The token is assigned per user and inherits all permissions of the user. A token can be obtained directly on Twona under Settings>APITokens.

If a token is invalid, Twona will issue a 401 Unauthorized response.

Terminology

Organization

Organization: An Organization is used to aggregate all aspects of your account. The name of the Organization will typically the name of your company :-)

organization object

Field name Type Description
id integer Id (unique) of the organization
name string Name of the Organization

Get a Token data (testing the API)

You can test the connectivity with Twona by requesting a session call which will return the user and organization data.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/session Get session data

Inputs

Empty

Response

Content

A user object and a organization object.

Code

Http Status Details
200 OK
401 Unauthorized (access-token not valid)

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/session \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "user": {
                                "date_created": "2019-02-19T09:09:23+00:00",
                                "email": "user@mail.com",
                                "id": "iDCHaRs",
                                "name": "User example name",
                                "position": "User position"
                            },
                            "organization": {
                                "id": 123122137,
                                "name": "Test organization"
                            }
                        }

Working with files

Terminology

Files

File: One file object is a file uploaded to the system by a user with more information about it. This file object is temporal until it’s used in some process or some attribute is updated. The file object has a structure described in the particular request.

file object

Field name Type Description
id string Unique id of the file
name string Filename with extension
extension string Extension of the file
filesize string File size in human readable format
size int File size (in bytes)
date timestamp Timestamp of the creation of the file
metadata object If present, metadata associated with the file (added by the user)

Get a file

Obtain details of a specific file.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/files/{FILE_ID}

Response

Content

A file object.

Codes

Http Status Details
200 Ok
404 Failed, file not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/files/{FILE_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "date":"2019-0702T12:24:59+0200",
                            "extension":"png",
                            "id":"e40ed4433ba4",
                            "filesize":"2.96MB",
                            "name":"imagen.png",
                            "size":3108445
                        }

Download a file

Download a specific file.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/files/{FILE_ID}

Headers

Header key Type Description
Content-Type string Content type of the body

Response

Codes

Http Status Details
200 Ok
404 Failed, file not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/files/{FILE_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -H 'Content-Type: application/offset+octet-stream' \

Add metadata to File

Add custom metadata to a specific file. When metadata is added to a file, the file becomes a persistent file and is no longer a temporal file. If the file was temporal, a new reference to the persistent file is returned.

Request

Resource

Method Url
PUT https://{BASE_URL}/api/v2/files/{FILE_ID}

Inputs

Field name Type Description
metadata (required) JSON Keys and values of the metadata to be inserted

Response

Content

A file object.

Code

Http Status Details
301 Redirect to new file updated
200 Metadata successfully added to file

Examples

Request

curl \
                          https://{BASE_URL}/api/v2/files \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d '{"metadata":{"key":"value","key2":"value2"}}'

Response

If the file id is a temporal file, the response will redirect to the new file. If the file id is a persisted file, the response will be a file Object

Get all files

Return all the files from the organization.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/files

Inputs

Field name Type Description
q (optional) string Search query to filter results based on conditions (details)

Filtering list

You can filter the result set by establishing filters based on the metadata fields using the query method ‘q=field:data’.

Response

Content

A collection of file object

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/files \
                          -H 'access-token: {ACCESS_TOKEN}'
# Filtering: All files with a field called owner start with "diego"

                        curl -G \
                          https://{BASE_URL}/api/v2/files \
                          -H 'access-token: {ACCESS_TOKEN}'
                          --data-urlencode 'q=owner:diego*'

Response

[
                            {
                                "active": true,
                                 "date": "2019-10-30T10:02:43+00:00",
                                 "extension": "pdf",
                                 "filesize": "18.65kB",
                                 "id": 267719,
                                 "mimetype": "application/pdf",
                                 "name": "ref.pdf",
                                 "size": 19100,
                                 "metadata": {
                                     "updated": 20191108,
                                     "owner": "diego",
                                     "tag": "test"
                                 }
                            },
                            {
                                "active": true,
                                 "date": "2019-10-30T10:02:43+00:00",
                                 "extension": "pdf",
                                 "filesize": "18.65kB",
                                 "id": 267719,
                                 "mimetype": "application/pdf",
                                 "name": "ref.pdf",
                                 "size": 19100,
                                 "metadata": {
                                     "updated": 20191011,
                                     "owner": "diego",
                                     "tag": "test2"
                                 }
                            }
                        ]

Uploading files

Twona uses the TUS Open Protocol 1.0.0 to upload files. This protocol provides a mechanism for resumable file uploads via HTTP/1.1 (RFC 7230) and HTTP/2 (RFC 7540).

Files can be chunked in parts. The minimum upload part size is 5MB (except the last part). The maximum upload part size is 10MB.

Requesting an upload resource

Files can be uploaded via an upload resource. The first step is to request one.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/files

Inputs

Headers

Header key Type Description
Upload-Length (required) integer The size of an entire upload (in bytes).
Upload-Metadata (required) string Filename (with extension), Filetype (MIME TYPE) or other fields on Base64 encode. (Important! no spaces between fields.)

Body

Empty.

Response

Outputs

Headers

Header key Type Description
location string URL of the upload resource

Body

Empty.

Code

Http Status Details
201 Created
409 Entity already uploaded
413 Request Entity Too Large

Examples

Request

curl -v \
                          -X POST \
                          https://{BASE_URL}/api/v2/files \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -H 'Upload-Length: 100'
                          -H 'Upload-Metadata: filename ZmlsZS5kb2M=,filetype YXBwbGljYXRpb24vbXN3b3Jk'

Response

< HTTP/1.1 201 Created
                        < Tus-Resumable: 1.0.0
                        < location: https://{BASE_URL}/api/v2/files/i6l028r76jsj
                        < Upload-Expires: Wed, 06 Nov 2019 14:24:45 GMT
                        ...

Uploading content

Once an upload URL resource is obtained, files can be uploaded. Files are uploaded using a PATCH request and they MUST use Content-Type: application/offset+octet-stream. If the file is larger than the maximum part size, you need to chunk the file in parts. The minimum part size is 5MB (except the last part). The maximum upload part size is 10MB.

Request

Resource

Method Url
PATCH https://{BASE_URL}/api/v2/files/{FILE_ID}

Inputs

Headers

Header key Type Description
Upload-Offset (required) integer The current offset of the resource (in bytes).
Content-Length (required) integer The size of the body (in bytes).
Content-Type string Content type of the body (MIME TYPE)

Body

File content.

Response

Outputs

Headers

Header key Type Description
Upload-Offset integer Offset of the resource (in bytes). If equal to file size, the upload process is over successfully.
Twona-File-Id string Unique id assigned to the file.

Body

Empty.

Code

Http Status Details
204 No content
409 Entity already uploaded
413 Request Entity Too Large

Examples

Request

curl -v \
                          -X PATCH \
                          https://{BASE_URL}/api/v2/files/i6l028r76jsj \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -H 'Upload-Offset: 0' \
                          -H 'Content-Length: 30' \
                          -H 'Content-Type: application/offset+octet-stream' \
                          --data-binary @{/path/of/file}

Response

< HTTP/1.1 204 No content
                        < Tus-Resumable: 1.0.0
                        < Upload-Offset: 30
                        < Twona-File-Id: i6l028r76jsj
                        < Upload-Expires: Wed, 06 Nov 2019 14:24:45 GMT
                        ...

Check upload

Check the state of an upload.

Request

Resource

Method Url
HEAD https://{BASE_URL}/api/v2/files/{FILE_ID}

Inputs

Headers

None.

Body

Empty.

Response

Outputs

Headers

Header key Type Description
Upload-Offset integer Offset of the resource (in bytes). If equal to file size, the upload process is over successfully.
Upload-Length integer Length of the resource registered.

Body

Empty.

Code

Http Status Details
200 Ok
404 Not found
409 Entity already uploaded

Examples

Request

curl -v \
                          -X HEAD \
                          https://{BASE_URL}/api/v2/files/i6l028r76jsj \
                          -H 'access-token: {ACCESS_TOKEN}' \

Response

< HTTP/1.1 200 OK
                        < Upload-Length: 100
                        < Upload-Offset: 30
                        < Twona-File-Id: i6l028r76jsj

Working with groups

Terminology

Groups

Group: Groups are a way to organise users based on specific permissions or automation sets (also called conditions). They are virtual construct and do not impose any hard constrains on the limitations of access of a user unless the corresponding conditions are set.

Each group has a unique id and name.

group object

Field name Type Description
active boolean The status of the group (active = true, inactive = false)
date_created timestamp The timestap of the creation of the group
date_updated timestamp The timestamp of the last update of group
id integer The group id
name string The name of the group

Add group

Create a new group.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/groups

Inputs

Field name Type Description
name (required) string The name of the group

Response

Content

A group object.

Code

Http Status Details
200 OK

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/groups \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d '{"name": "new group's name"}'

Response

{
                            "active": true,
                            "date_created": "2019-07-01T11:47:04+00:00",
                            "date_updated": "2019-07-01T11:47:04+00:00",
                            "id": 160,
                            "name": "new group's name"
                        }

Get one group

Get the information of a specific group.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/groups/{GROUP_ID}

Response

Content

A group object.

Codes

Http Status Details
200 OK
404 Group not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "active": true,
                            "date_created": "2019-07-01T11:43:04+00:00",
                            "date_updated": "2019-07-01T11:43:04+00:00",
                            "id": 111,
                            "name": "Main group"
                        }

Get all groups

Return a collection of all active/inactive groups.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/groups Get all active groups
GET https://{BASE_URL}/api/v2/groups?deleted=true Get all inactive groups

Response

Content

A collection of group object.

Code

Http Status Details
200 Ok

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/groups \
                          -H 'access-token: {ACCESS_TOKEN}'

                        curl -X GET \
                            https://{BASE_URL}/api/v2/groups?deleted=true \
                            -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "active": true,
                                "date_created": "2019-07-01T11:47:04+00:00",
                                "date_updated": "2019-07-01T11:47:04+00:00",
                                "id": 111,
                                "name": "Main group"
                            },
                            {
                                "active": true,
                                "date_created": "2019-07-01T11:47:04+00:00",
                                "date_updated": "2019-07-01T11:47:04+00:00",
                                "id": 160,
                                "name": "new group's name"
                            }
                        ]

Update one group

Update the data of a specific group.

Request

Resource

Method Url
PUT https://{BASE_URL}/api/v2/groups/{GROUP_ID}

Inputs

Field name Type Description
name (required) string The NEW name of the group.
active (optional) boolean The NEW status of the group.

Response

Content

The updated group object.

Code

Http Status Details
201 ok

Examples

Request

curl -X PUT \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -d '{ "name": "New name",
                                "active": false }'

Response

{
                            "active": false,
                            "date_created": "2019-07-01T11:47:04+00:00",
                            "date_updated": "2019-07-01T11:47:04+00:00",
                            "id": 160,
                            "name": "New name"
                        }

Deactivate one group

Deactivate a specific group. The users in this group will still be active but all conditions associated with the group will stop executing. Users cannot be added to a deactivated group.

Request

Resource

Method Url
DELETE https://{BASE_URL}/api/v2/groups/{GROUP_ID}

Response

Content

Empty

Code

Http Status Details
200 ok

Examples

Request

curl -X DELETE \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Activate one group

Activate a specific group. Users can be added to an active group.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/groups

Inputs

Field name Type Description
id (required) integer Group id

Response

Content

A group object.

Code

Http Status Details
200 ok

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/groups \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d '{"id": 160}'

Response

{
                            "active": true,
                            "date_created": "2019-07-01T12:47:10+00:00",
                            "date_updated": "2019-07-02T08:22:49+00:00",
                            "id": 158,
                            "name": "test July updated new"
                        }

Get users in group

Return the collection of users in a specific group.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users Get users in the group with GROUP ID

Response

Content

A collection of user object.

Code

Http Status Details
200 ok

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                              "date_created": "2019-07-01T10:04:33+00:00",
                              "email": "mail1@twonas.com",
                              "id": "vfCswDrcRsaCP",
                              "name": "Mail 1 Name",
                              "position": null
                            },
                            {
                              "date_created": "2018-07-18T16:16:50+00:00",
                              "email": "mail2@twonas.com",
                              "id": "sjXaodaEwzdf",
                              "name": "Mail2 Name",
                              "position": null
                            }
                        ]

Add one user to group

Add one user in a specific group.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users

Inputs

Field name Type Description
id (required) string The User id to add to the group

Response

Content

A user object.

Code

Http Status Details
201 ok

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d '{"id": "iDCHaRs"}'

Response

{
                            "date_created": "2019-06-20T10:37:21+00:00",
                            "email": "user@mail.com",
                            "id": "iDCHaRs",
                            "name": "User name",
                            "position": "User position"
                        }

Deactivate one user in group

Dactivate one user in a specific group. The user will no longer be part of set of active users in a group.

Request

Resource

Method Url
DELETE https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users/{USER_ID}

Response

Content

Empty

Code

Http Status Details
204 No content

Examples

Request

curl -X DELETE \
                          https://{BASE_URL}/api/v2/groups/{GROUP_ID}/users/{USER_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Auto-key for Login

Auto-key is a method based on a “magic link” that allows to log a user without password. This is the prefered method for integrating within a third party application so that user control is made through the API and transparent for the users.

You need additional permissions for this feature. If you you obtain an error when making this API calls, please contact our customer support.

Request a link to log in a specific user.

Twona will return an Autokey to which you can append the access URL with an href query and encoding for url urlencode the section you want the user to access.

An example in PHP:

$urlToApp = $autologin."?href=".urlencode("https://app.twonas.com/app/p/apollo/upload?reference=".$referenceId."&target=".$targetId);

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/login/auto-key

Inputs

Field name Type Description
email (required) string Email of the user you wish to log in

Response

Response headers

Header key Type Description
Location string Magic link.

Body content

Empty.

Code

Http Status Details
204 Ok
401 Unauthorized (you do not have permission to request an auto-key)
403 Not allowed (the user does not exist)

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/login/auto-key \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d '{"email":"user@twonas.com"}'

Response

< HTTP/1.1 204 No Content
                        < Location: https://{URL_BASE}/login/auto-key/{HASH}/{CHECKSUM}

Working with Requests

Terminology

Request

Request: A Request is used to group, track and aggregate the process of creating assets (or artworks). A request will follow the steps defined in a workflow and will link together Versions, Attachments, Messages, Approvals and anything else related to a specific project.

request object

Field name Type Description
id integer Id (unique) of the Request
labels array Collection of assigned labels
labels_text string Coma separated labels as text
info string Info field (HTML text)
date_created ISO 8601 date Timestamp of creation
priority float Priority (relative to other requests)
status Status Object Current status (step in the workflow) of the Request
user_owner User Object Creator of the request

Status

Status: The Status represents the current state of the request within the assigned workflow.

status object

Field name Type Description
id string Id (unique) of the Status
name string Status name (the step in the workflow)
color string HEX Color

Get a Request

Get the information of a specific request.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/requests/{REQUEST_ID}

Inputs

Empty.

Response

Content

A request object.

Code

Http Status Details
201 Ok
403 Error: Forbidden
404 Error: Not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/requests/{REQUEST_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "id": 80001,
                            "labels": [
                                {
                                    "id": 33001,
                                    "group": {
                                        "color": "#E85637",
                                        "id": 49,
                                        "name": "Group 1"
                                    },
                                    "name": "Label 1"
                                },
                                {
                                    "id": 33022,
                                    "group": {
                                        "color": "#63B7AD",
                                        "id": 59,
                                        "name": "Group 2"
                                    },
                                    "name": "Label 2"
                                }
                            ],
                            "labels_text": "Label 1, Label 2",
                            "info": "Hi,<br><p>Please find attached pdf file annotated.</p><br><p>Thank you</p><p>Best regards</p><p>Charles</p>",
                            "date_created": "2021-02-09T17:27:36+00:00",
                            "date_updated": "2021-02-10T09:09:23+00:00",
                            "priority": 80746.00001,
                            "status": {
                                "color": "#63B7AD",
                                "id": 798,
                                "name": "Finished"
                            },
                            "user_owner": {
                                "date_created": "2019-02-19T09:09:23+00:00",
                                "email": "user@mail.com",
                                "id": "iDCHaRs",
                                "name": "User example name",
                                "position": "User position"
                            },
                        
                        }

Get files (attachments)

Return a list of all active files (attachments) in a request.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/requests/{REQUEST_ID}/files

Inputs

Empty

Response

Content

A collection of files object.

Code

Http Status Details
200 OK
403 Error: Forbidden
404 Error: Not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/requests/{REQUEST_ID}/files \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "active": true,
                                "date": "2021-02-09T17:27:36+00:00",
                                "extension": "pdf",
                                "filesize": "274.59kB",
                                "id": 1844020,
                                "mimetype": "application/pdf",
                                "name": "file1.pdf",
                                "size": 281183,
                                "metadata": []
                            },
                            {
                                "active": true,
                                "date": "2021-02-09T17:27:36+00:00",
                                "extension": "pdf",
                                "filesize": "154.56kB",
                                "id": 1844020,
                                "mimetype": "application/pdf",
                                "name": "file2.pdf",
                                "size": 154560,
                                "metadata": []
                            }
                        ]

Get all Requests

Return the list of all requests in the organization.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/requests

Inputs

Field name Type Description
q (optional) string Search query to filter results based on conditions (details)
sort_by (optional) string Order by field (details)
page (optional) Page of results (default: 1)

Filtering list

To filter the list of requests, you can add a conditional query q as field:query (#search-queries).

Allowed filters:

Field Type Description
status integer Id of the status
workflow integer Id of the workflow
user_owner integer Id of the owner
label integer Id of the label

To order the list of requests, you can add a short query short_by as field1,field2 (#search-queries).

Order fields:

Field Description
priority Order by
id Order by

Response

Content

A collection of request objects.

Code

Http Status Details
204 OK

Examples

Request

# Get requests from the workflow 31 order by id desc
                        curl -X GET \
                          https://{BASE_URL}/api/v2/requests \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          --data-urlencode 'q=workflow:31' \
                          --data-urlencode 'sort_by=-id'

Response

[
                           {
                              "id":80745,
                              "labels":[
                                 {
                                    "id":169,
                                    "group":{
                                       "color":"#E85637",
                                       "id":49,
                                       "name":"Manufacturer"
                                    },
                                    "name":"Label 169"
                                 },
                                 {
                                    "id":212,
                                    "group":{
                                       "color":"#63B7AD",
                                       "id":59,
                                       "name":"Dose"
                                    },
                                    "name":"Label 212"
                                 }
                              ],
                              "labels_text":"Label 169, Label 212",
                              "info":"",
                              "date_created":"2021-02-09T17:27:36+00:00",
                              "date_updated":"2021-02-10T09:09:23+00:00",
                              "priority":80746.00001,
                              "status":{
                                 "color":"#63B7AD",
                                 "id":571,
                                 "name":"Finished"
                              },
                              "user_owner": {
                                  "date_created": "2019-02-19T09:09:23+00:00",
                                  "email": "user@mail.com",
                                  "id": "iDCHaRs",
                                  "name": "User example name",
                                  "position": "User position"
                              },
                           },
                           {
                              "id":80732,
                              "labels":[
                                 {
                                    "id":928,
                                    "group":{
                                       "color":"#E85637",
                                       "id":94,
                                       "name":"Manufacturer"
                                    },
                                    "name":"Label 928"
                                 },
                                 {
                                    "id":78,
                                    "group":{
                                       "color":"#EAC739",
                                       "id":98,
                                       "name":"Presentation"
                                    },
                                    "name":"Label 78"
                                }
                              ],
                              "labels_text":"Label 928, Label 78",
                              "info":"",
                              "date_created":"2021-02-09T14:17:29+00:00",
                              "date_updated":"2021-02-10T11:12:37+00:00",
                              "priority":80746.000005,
                              "status":{
                                 "color":"#E1AB32",
                                 "id":542,
                                 "name":"Checking"
                              },
                              "user_owner": {
                                  "date_created": "2019-02-19T09:09:23+00:00",
                                  "email": "user@mail.com",
                                  "id": "iDCHaRs",
                                  "name": "User example name",
                                  "position": "User position"
                              }
                           }
                        ]

Get all status

Return the list of all request status in the organization.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/requests/status Get all request status

Inputs

Field name Type Description
workflow (optional) Integer Id (unique) of the workflow

Response

Content

A collection of status object.

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/requests/status \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "color": "#97CBC0",
                                "id": 371,
                                "name": "Received"
                            },
                            {
                               "color":"#E1AB32",
                               "id":542,
                               "name":"Checking"
                            },
                            {
                               "color":"#63B7AD",
                               "id":571,
                               "name":"Finished"
                            }
                        ]

Search and Sort Queries

In some cases you can filter and sort the results of a returned list using query strings. Results can also be returned with page.

Syntax

A filter/sort query is composed of three parts: the query q to filter (search) the result set, the sort short_by to arrange the order, and the page page to navigate the pages of results. You can add more than one filter/short term. Spaces are not allowd in the final query string.

q=field1:term1+field2:term2+field3:term3&sort_by=field1,-field2&page=2 // + -> is a condition

IMPORTANT: the string needs to be encoded before it is added to the url.

Filter field

You can establish filter (search) queries using: q=[conditions]. Individual consitions consist of the form field=term and can be concatenated by using AND, AND NOT and OR statements as follows:

Concatenation Description
+ AND
- AND NOT
| OR (start a new condition block)

Modifiers

You can use modifiers to expand the filter (search) criteria as follows:

Modifier Types allowed Description
* string Define the position of the string
> number, date Greater than, after than
< number, date Lower than, before than
Example Modifier
:term (Without modifier) Search exactly the term.
:*term Search the term at the end of the value.
:term* Search the term at the beginning of the value.
:*term* The value contains the term. (In this case the term can be also at the beginning and/or at the end of the value).

IMPORTANT: query field is mandatory.

Sort field

You can sort the result set by using: sort_by=[field1,field2]

By default the order is ASC. You can use - to specify the order DESC before the field as in the example below.

q=...&sort_by=field1,-field2...

Page field

Results can be returned by pages using page=[int] as follows:

q=...&sort_by=...&page=2

Search Examples

A table like:

ID NAME EMAIL
1 Seva Halter seva.halter@twonas.com
2 Brigitte Marland brigitter.marland@twonas.com
3 Diego Beltrán diego@twonas.com
4 Donna Brinn donna@twona.com
5 Seva Blade seva.blade@gmail.com

Example 1

Where the email is equal to diego@twonas.com.

String Encoded Expected result
q=email:diego@twonas.com email%3Adiego%40twonas.com [1]

Example 2

Where the email field ends with twonas.com.

String Encoded Expected result
q=email:*twonas.com&sort_by=id q%3Demail%3A%2Atwonas.com%26sort_by%3Did [1,2,3,4]

Example 3

Where the email field ends with twonas.com and starts with diego.

String Encoded Expected result
q=email:*twonas.com+email:diego* q%3email%3A%2Atwonas.com%2Bemail%3Adiego%2A [3]

Example 4

Where the email field ends with twonas.com and starts with diego, or the email field starts with seva.

String Encoded Expected result
q=email:*twonas.com+email:diego*|email:seva*&sort_by=-id q%3Demail%3A%2Atwonas.com%2Bemail%3Adiego%2A%7Cemail%3Aseva%2A%26sort_by%3D-id [5,3,1]

Example 5

Where the email field starts with seva and not ends with twonas.com.

String Encoded Expected result
q=email:seva*-email:*twonas.com q%3email%3Aseva%2A-email%3A%2Atwonas.com [5]

Example 6

Where the email field starts with seva and not ends with twonas.com, or the email field starts with diego.

String Encoded Expected result
q=email:seva*-email:*twonas.com|email:diego*&sort_by=name q%3Demail%3Aseva%2A-email%3A%2Atwonas.com%7Cemail%3Adiego%2A%26sort_by%3Dname [3, 5]

Working with users

Terminology

Invitation

Invitation: an invitation is the process of providing access to a new user via his own email to a specific organization.

invitation object

Field name Type Description
date timestamp The timestamp when the invitation was sent
date_expiration timestamp The timestamp when the invitation will expire
email string The email address to which the invitation was sent
name string The name of the invited user
organization_id integer The identifier (id) of the organization to which the user would be added
status_code integer Internal code to identify the status of the invitation: 2/3 (TODO: which codes?)
status_text string Internal text to display the status of the invitation: Expired/Pending (TODO: which texts?)
users_group_id integer The initial group assigned for the user (TODO: you send an array but get only an integer, is it the first one?)

User

User: one user is a single point of access associated to a unique email address. Each user has its own identifier, email and name among other data. The user object has a structure described in the particular request.

user object

Field name Type Description
date_created timestamp The timestamp of the creation of the user
email string The email address of the user
id string The unique identifier (id) of the user (we call it user id)
name string The name of the user
position string The position of the user

Invite a new user

This call will send an invitation to the user’s email address provided in the parameter’s set. Once the link in the email has been clicked, the user will be added to the provided user’s group.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/users/invitations

Inputs

Field name Type Description
name (required) string The name of the new user to invite
email (required) string The email address of the user to invite
groups (optional) array IDs (numerical) of the user groups where the user will be placed on. Groups are mostly used to limit access and grant special permissions.
message (optional) string Text to be included in the email with the invitation

Response

Content

Empty

Code

Http Status Details
204 No content
422 Error: The required fields were not found (or incomplete) or the groups (ids) are not valid

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/users/invitations \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -d '{ "name": "User's name",
                                "email": "example@twonas.com",
                                "groups": [12,14],
                                "message": "Wellcome!" }'

Get all invitations

Return the list of all pending or expired invitations.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/users/invitations

Inputs

Empty

Response

Content

A collection of invitation object.

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/users/invitations \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "date": "2019-06-28T10:27:21+0200",
                                "email": "test1@twonas.com",
                                "hash": "98dadeas37faa5",
                                "name": "test1 name",
                                "organization_id": 1,
                                "status_code": 2,
                                "status_text": "Expired",
                                "users_group_id": 12
                            },
                            {
                                "date": "2019-06-18T09:48:33+0200",
                                "email": "test2@twonas.com",
                                "hash": "f7c92315b32e",
                                "name": "test2 name",
                                "organization_id": 1,
                                "status_code": 2,
                                "status_text": "Expired",
                                "users_group_id": 12
                            }
                        ]

Cancel an invitation

Cancel a “Pending” invitation. Expired or accepted invitations cannot be canceled.

Request

Resource

Method Url
DELETE https://{BASE_URL}/api/v2/users/invitations/{EMAIL}

Inputs

Empty

Response

Content

Empty

Code

Http Status Details
204 OK

Examples

Request

curl -X DELETE \
                          https://{BASE_URL}/api/v2/users/invitations/example@twonas.com \
                          -H 'access-token: {ACCESS_TOKEN}'

Get all users

Return the list of all active/inactive users in the organization.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/users Get all active users
GET https://{BASE_URL}/api/v2/users?deleted=true Get all inactive users

Inputs

Field name Type Description
deleted (optional) boolean Return all inactive users
q (optional) string Filter the users to be returned with matching conditions (details)

Filtering list

To filter the list of users, you can add a conditional query q as field:query (details).

Allowed filters:

Field Type Description
email string Email of the user
name string Name of the user

Response

Content

A collection of user object.

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/users \
                          -H 'access-token: {ACCESS_TOKEN}'

                        curl -X GET \
                            https://{BASE_URL}/api/v2/users?deleted=true \
                            -H 'access-token: {ACCESS_TOKEN}'
Filtering: All users with email starting with “diego”
curl -G \
                          https://{BASE_URL}/api/v2/users \
                          -H 'access-token: {ACCESS_TOKEN}'
                          --data-urlencode 'q=email:diego*'

Response

[
                            {
                              "date_created": "2019-07-01T10:04:33+00:00",
                              "email": "mail1@twonas.com",
                              "id": "vfCssaCP",
                              "name": "Mail 1 Name",
                              "position": null
                            },
                            {
                              "date_created": "2018-07-18T16:16:50+00:00",
                              "email": "mail2@twonas.com",
                              "id": "sjXaozdf",
                              "name": "Mail2 Name",
                              "position": null
                            }
                        ]

Get one user

Return the details of a specific user (by its unique user id)

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/users/{USER_ID}

Inputs

Empty

Response

Content

A user object.

Codes

Http Status Details
200 Ok
404 Failed, user not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/users/{USER_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "date_created": "2019-06-20T10:37:21+00:00",
                            "email": "user@mail.com",
                            "id": "iDCHaRs",
                            "name": "New user's name",
                            "position": "User position"
                        }

Update one user

Update the personal data of a specific user (by its unique user id)

Request

Resource

Method Url
PUT https://{BASE_URL}/api/v2/users/{USER_ID}

Inputs

Field name Type Description
name (optional) string The NEW name of the user
telephone (optional) string The NEW phone number of the user
position (optional) string The NEW position of the user

Response

Content

The updated user object.

Code

Http Status Details
201 Ok
404 Failed, user not found

Example

Request

curl -X PUT \
                          https://{BASE_URL}/api/v2/users/{USER_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -d '{ "name": "New user's name",
                                "telephone": "+34000000000",
                                "position": "User position" }'

Response

{
                            "date_created": "2019-06-20T10:37:21+00:00",
                            "email": "user@mail.com",
                            "id": "iDCHaRs",
                            "name": "New user's name",
                            "position": "User position"
                        }

Deactivate one user

Deactivate (make inactive) a specific a specific user (by its unique user id). Once a user is deactivated, he will no longer be able to log in.

Resource

Request

Method Url
DELETE https://{BASE_URL}/api/v2/users/{USER_ID}

Inputs

Empty

Response

Content

Empty

Codes

Http Status Details
204 No content

Examples

Request

curl -X DELETE \
                          https://{BASE_URL}/api/v2/users/{USER_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Activate one user

Activate (make active) a specific a specific user (by its unique user id). Once a user is activated, he will be able to log in.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/users

Inputs

Field name Type Description
id (required) string The user id

Response

Content

The updated user object.

Codes

Http Status Details
201 ok

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/users \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -d '{ "id": "iDCHaRs" }'

Response

{
                            "date_created": "2019-06-20T10:37:21+00:00",
                            "email": "user@mail.com",
                            "id": "iDCHaRs",
                            "name": "user's name",
                            "position": "User position"
                        }

Add users in bulk

Add users in bulk by WITHOUT email confirmation. Users will be added (and made active) without confirmation of the email address. A maximum of 100 users can be added per request.

Request

Resource

Method Url
POST https://{BASE_URL}/api/v2/users/bulk

Inputs

Field name Type Description
emails (required) array Emails of the users to add
groups (optional) array Group ids to which each user will be added (maximum one group per user) (TODO: one group per user or one array per user?)

Response

Content

A collection of user object with the successfully added users.

Codes

Http Status Details
201 ok
400 Emails are required
403 This action is not allowed
413 Too many emails
422 One or more group ids do not exist or are invalid
422 Error processing the collection of groups

Examples

Request

curl -X POST \
                          https://{BASE_URL}/api/v2/users/bulk \
                          -H 'access-token: {ACCESS_TOKEN}'
                          -d '{ "emails": ["newUserMail@yourDomain.com","anotherUserMail@yourDomain.com",...],
                                "groups": [11,12,13,...]}'

Response

[
                          {
                            "date_created": "2019-06-20T10:37:21+00:00",
                            "email": "user@mail.com",
                            "id": "iDCHaRs",
                            "name": "user's name",
                            "position": "User position"
                          }
                        ]

Working with Versions

Terminology

Version

Version: A version is a collection of files that are considered a set to which a specific state and version number (a human one and a computer one) is assigned. Versions are used to ensure the correct files are used. A version is identified by a unique ID and a user number.number model (ex. Version 1.2) and is defined by the set of labels assigned to it. A version must contain AT LEAST one file.

version object

Field name Type Description
id integer Id of the Version
labels array Collection of labels
labels_text string Coma separated labels
version_number integer Version number
subversion_number integer Subversion number
version string String format Version dot Subversion
date_created ISO 8601 date The timestamp of the creation of the version
status Status Object Current status of the Version
user_owner User Object User who uploaded the version

Status

Status: A version can be set to a specific Status (ex. Approved). This determines the purpose of the Version and can be used to filter, limit access, etc.

status object

Field name Type Description
id string Id (unique) of the status
name string The name of the status
color string HEX Color

Get one Version

Return the details of a specific version.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/versions/{VERSION_ID}

Inputs

Empty.

Response

Content

A version object.

Code

Http Status Details
201 Ok
403 Error: Forbidden
404 Error: Not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/versions/{VERSION_ID} \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

{
                            "id": 956783,
                            "labels": [
                                {
                                    "id": 928,
                                    "group": {
                                        "color": "#E85637",
                                        "id": 49,
                                        "name": "Manufacturer"
                                    },
                                    "name": "Label 928"
                                },
                                {
                                    "id": 78,
                                    "group": {
                                        "color": "#EAC739",
                                        "id": 89,
                                        "name": "Presentation"
                                    },
                                    "name": "Label 78"
                                }
                            ],
                            "labels_text": "Label 928, Label 78",
                            "version": "4.2",
                            "version_number": 4,
                            "subversion_number": 2,
                            "time_created": "2021-02-10T11:32:07+00:00",
                            "user_owner": {
                                "date_created": "2019-02-19T09:09:23+00:00",
                                "email": "user@mail.com",
                                "id": "iDCHaRs",
                                "name": "User example name",
                                "position": "User position"
                            },
                            "status": {
                                "color": "#E1AB32",
                                "id": 12,
                                "name": "In process"
                            }
                        }

Get files from a Version

Return the list of all files in a version.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/versions/{VERSION_ID}/files

Inputs

Empty

Response

Content

A collection of files object.

Code

Http Status Details
200 OK
403 Error: Forbidden
404 Error: Not found

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/versions/{VERSION_ID}/files \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "active": true,
                                "date": "2021-02-09T17:27:36+00:00",
                                "extension": "pdf",
                                "filesize": "274.59kB",
                                "id": 1844020,
                                "mimetype": "application/pdf",
                                "name": "file1.pdf",
                                "size": 281183,
                                "metadata": []
                            },
                            {
                                "active": true,
                                "date": "2021-02-09T17:27:36+00:00",
                                "extension": "pdf",
                                "filesize": "154.56kB",
                                "id": 1844020,
                                "mimetype": "application/pdf",
                                "name": "file2.pdf",
                                "size": 154560,
                                "metadata": []
                            }
                        ]

Get all Versions

Return the list of all versions in the organization.

Version

Resource

Method Url
GET https://{BASE_URL}/api/v2/versions

Inputs

Field name Type Description
q (optional) string Search query to filter results based on conditions (details)
sort_by (optional) string Order by field (details)
page (optional) Page of results (default: 1)

Filtering list

To filter the list of versions, you can add a conditional query q as field:query (#search-queries).

Allowed filters:

Field Type Description
status integer Id of the status
label integer Id of the label

To order the list of versions, you can add a short query short_by as field1,field2 (#search-queries).

Order fields:

Field Description
id Order by

Response

Content

A collection of version objects.

Code

Http Status Details
204 OK

Examples

Request

# Get requests from the workflow 31 order by id desc
                        curl -X GET \
                          https://{BASE_URL}/api/v2/versions \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          --data-urlencode 'q=status:12' \
                          --data-urlencode 'sort_by=-id'

Response

[
                            {
                                "id": 956783,
                                "labels": [
                                    {
                                        "id": 922,
                                        "group": {
                                            "color": "#E85637",
                                            "id": 49,
                                            "name": "Manufacturer"
                                        },
                                        "name": "Label 922"
                                    },
                                    {
                                        "id": 78,
                                        "group": {
                                            "color": "#EAC739",
                                            "id": 89,
                                            "name": "Presentation"
                                        },
                                        "name": "Label 78"
                                    }
                                ],
                                "labels_text": "Label 922, Label 78",
                                "version": "1.2",
                                "version_number": 1,
                                "subversion_number": 2,
                                "time_created": "2021-02-10T11:32:07+00:00",
                                "user_owner": {
                                    "date_created": "2019-02-19T09:09:23+00:00",
                                    "email": "user@mail.com",
                                    "id": "iDCHaRs",
                                    "name": "User example name",
                                    "position": "User position"
                                },
                                "status": {
                                    "color": "#E1AB32",
                                    "id": 12,
                                    "name": "In process"
                                }
                            },
                            {
                                "id": 956743,
                                "labels": [
                                    {
                                        "id": 923,
                                        "group": {
                                            "color": "#E85637",
                                            "id": 49,
                                            "name": "Manufacturer"
                                        },
                                        "name": "Label 923"
                                    },
                                    {
                                        "id": 76,
                                        "group": {
                                            "color": "#EAC739",
                                            "id": 89,
                                            "name": "Presentation"
                                        },
                                        "name": "Label 76"
                                    }
                                ],
                                "labels_text": "Label 923, Label 76",
                                "version": "4.2",
                                "version_number": 4,
                                "subversion_number": 2,
                                "time_created": "2021-02-09T11:32:07+00:00",
                                "user_owner": {
                                    "date_created": "2019-02-19T09:09:23+00:00",
                                    "email": "user@mail.com",
                                    "id": "iDCHaRs",
                                    "name": "User example name",
                                    "position": "User position"
                                },
                                "status": {
                                    "color": "#E1AB32",
                                    "id": 12,
                                    "name": "In process"
                                }
                            }
                        ]

Get all status

Return the list of all version status in the organization.

Request

Resource

Method Url Description
GET https://{BASE_URL}/api/v2/versions/status Get all versions status

Inputs

Empty

Response

Content

A collection of status object.

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/versions/status \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "color": "#E1AB32",
                                "id": 12,
                                "name": "In process"
                            },
                            {
                                "color": "#E85637",
                                "id": 267,
                                "name": "Discarded Version"
                            },
                            {
                               "color":"#63B7AD",
                               "id":571,
                               "name":"Finished"
                            }
                        ]

Working with workflows

Terminology

Workflow

Workflow: A workflow defines the pathway of a request. It is a constellation of potential transitions between Request Statuses, thus a Request can only be placed in a “target” Status if there is a transition with the current Status as “origin” and the corresponding “target”. A workflow typically represents a specific process in your Organization and can be an object of permission restrictions.

workflow object

Field name Type Description
id integer Id of the workflow
name string Name of Workflow
initial_status Status object Initial status

Transitions

Transition: A transition represents the potential to change the Status of a request from an “origin” Status to a “target” Status. Transitions a can be objects of permission restrictions

transition object

Field name Type Description
id string Id (unique) of the transition
origin Status object Origin status
target Status object Target status

Get all workflows

Return the details of a specific request (by its unique request id)

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/workflows

Inputs

Empty.

Response

Content

A collection of workflow object.

Code

Http Status Details
201 Ok

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/workflows \
                          -H 'access-token: {ACCESS_TOKEN}'

Response

[
                            {
                                "id": 333,
                                "name": "Standard",
                                "initial_status": {
                                    "color": "#CECECE",
                                    "id": 81,
                                    "name": "Draft"
                                }
                            },
                            {
                                "id": 334,
                                "name": "Design team",
                                "initial_status": {
                                    "color": "#cecece",
                                    "id": 991,
                                    "name": "Received"
                                }
                            }
                        ]

Get workflow transitions

Return the list of all active transitions of a workflow.

Request

Resource

Method Url
GET https://{BASE_URL}/api/v2/workflows/{WORKFLOW_ID}/transitions

Inputs

Empty

Filtering

Field Type Description
origin integer Id of the origin status
target integer Id of the target status

Response

Content

A collection of transition object.

Code

Http Status Details
200 OK

Examples

Request

curl -X GET \
                          https://{BASE_URL}/api/v2/workflows/{WORKFLOW_ID}/transitions \
                          -H 'access-token: {ACCESS_TOKEN}' \
                          -d 'origin=81'

Response

[
                            {
                                "id": 162,
                                "origin": {
                                    "color": "#CECECE",
                                    "id": 81,
                                    "name": "Draft"
                                },
                                "target": {
                                    "color": "#EAC739",
                                    "id": 471,
                                    "name": "Processing"
                                }
                            },
                            {
                                "id": 762,
                                "origin": {
                                    "color": "#CECECE",
                                    "id": 81,
                                    "name": "Draft"
                                },
                                "target": {
                                    "color": "#97CBC0",
                                    "id": 173,
                                    "name": "Received"
                                }
                            }
                        ]