Tool API

Adding a tool through the REST-API

The Minddistrict API allows clients, related therapists and API users with the neccessary permissions to add tools to client accounts. Tools are created using content ids as published through the Catalogue API.

The endpoint is discoverable through the Client API. It is listed as tools under the @links.

Note

Clients can only add tools for self-help content items.

Send a content id to the tools endpoint to create a tool:

POST /api/2/c/c4a1446b21674c82b9cde931b5be1b3e/tools HTTP/1.1
Host: customer.minddistrict.com
Accept: application/json
Authorization: md-token gAAAAABgZBtPqrhCCvMZaP5HjMI5pXMVZ-Pf1novgNpTI3KU9MDy1NMs2Mo-CPhtMsXMA89_qJjCwSKXBcjXdjmbmYfNIMKkYgxEogXwgsrV4wCERvWwNqdDcpuUfwAh9Y9y9Ogt2qtfuWFZQuDpMNImXc_ftlL1VMnTjUIeWThHCfYdy083adrmcQcZOmNzDFykyt-iRcMl
Content-Length: 26
Content-Type: application/json

{
    "id": "docs_topic"
}

The response contains the URL of the newly created tool, or, in some cases, the updated tool (diaries):

HTTP/1.0 201 Created
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Length: 103
Content-Type: application/json;charset=UTF-8
Location: https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/module/l.2

{
    "@url": "https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/module/l.2"
}

Content that does not result in a self-help tool can not be added by the client itself.:

POST /api/2/c/c4a1446b21674c82b9cde931b5be1b3e/tools HTTP/1.1
Host: customer.minddistrict.com
Accept: application/json
Authorization: md-token gAAAAABgZBtPqrhCCvMZaP5HjMI5pXMVZ-Pf1novgNpTI3KU9MDy1NMs2Mo-CPhtMsXMA89_qJjCwSKXBcjXdjmbmYfNIMKkYgxEogXwgsrV4wCERvWwNqdDcpuUfwAh9Y9y9Ogt2qtfuWFZQuDpMNImXc_ftlL1VMnTjUIeWThHCfYdy083adrmcQcZOmNzDFykyt-iRcMl
Content-Length: 48
Content-Type: application/json

{
    "id": "9755e3b8e5194b8eb329d9c4b5970fb7"
}

Will trigger this result:

HTTP/1.0 400 Bad Request
Content-Length: 170
Content-Type: application/json;charset=UTF-8

{
    "code": 400,
    "extra": [
        {
            "message": "Unknown value.",
            "name": "id"
        }
    ],
    "message": "Invalid query parameters"
}

This content is added, as it was the API user that issued the request.:

POST /api/2/c/c4a1446b21674c82b9cde931b5be1b3e/tools HTTP/1.1
Host: customer.minddistrict.com
Accept: application/json
Authorization: md-token gAAAAABgZBtS8Ua9Pcla5dnUix2uJFPm0HT900z-5Y8-zrdwkYL8si-LAOjmPHwF-9ttGIQZ3emBV9IVe2F03-A7M1h0NTO4VrqQxdsKLhkJauBHDSaJk2un3c8_URGlF5EQ0Hu48G6ZVJhWNJum4hA7XLgzwl2kvbsPezsP7QdvWj91n227SGS4nGA-FmNuUhyE2462bOw2
Content-Length: 48
Content-Type: application/json

{
    "id": "9755e3b8e5194b8eb329d9c4b5970fb7"
}

Will trigger this result:

HTTP/1.0 201 Created
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Length: 145
Content-Type: application/json;charset=UTF-8
Location: https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/diary/configuration/9755e3b8e5194b8eb329d9c4b5970fb7

{
    "@url": "https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/diary/configuration/9755e3b8e5194b8eb329d9c4b5970fb7"
}

Additional tool details

Only the API user can pass extra options to the endpoint, controlling details about the newly added tool. The optional therapist is defined as a professional reference).

Name

Value

Explanation

Value type

Notes

id

Content id

Id of the content to be added as a tool

Choice

Required
therapist

Guiding therapist

Therapist user reference.

JSON object

require_feedback

Feedback moments

Whether the tool should have feedback moments enabled, where applicable.

Boolean

notify

Email notification

Whether to send an email notification to the client about the new tool.

Boolean

The following query:

POST /api/2/c/c4a1446b21674c82b9cde931b5be1b3e/tools HTTP/1.1
Host: customer.minddistrict.com
Accept: application/json
Authorization: md-token gAAAAABgZBtS8Ua9Pcla5dnUix2uJFPm0HT900z-5Y8-zrdwkYL8si-LAOjmPHwF-9ttGIQZ3emBV9IVe2F03-A7M1h0NTO4VrqQxdsKLhkJauBHDSaJk2un3c8_URGlF5EQ0Hu48G6ZVJhWNJum4hA7XLgzwl2kvbsPezsP7QdvWj91n227SGS4nGA-FmNuUhyE2462bOw2
Content-Length: 130
Content-Type: application/json

{
    "id": "docs_topic",
    "notify": false,
    "require_feedback": true,
    "therapist": {
        "id": "tina123456"
    }
}

The response will be the URL to the tool that was created.:

HTTP/1.0 201 Created
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Content-Length: 103
Content-Type: application/json;charset=UTF-8
Location: https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/module/l.3

{
    "@url": "https://customer.minddistrict.com/api/2/c/c4a1446b21674c82b9cde931b5be1b3e/module/l.3"
}