# Run the model using the Thymia Activity Plugin POST /v1/models/mental-wellness-activity Content-Type: application/json Create a new run of the Mental Wellness model for a specific user, using the Thymia Activity Plugin to host an activity and capture a recording. The response contains: * A link for the user to perform an activity. The link should then be embedded in the Thymia Activity Plugin. Once the activity is completed, the recording of it will be used automatically as input to the model. * The id of the new model run which can be used to poll for results **after the activity has been completed**. Reference: https://docs.thymia.ai/api-reference/plant-store-api/mental-wellness-thymia-helios/create-model-run-with-activity-v-1-models-mental-wellness-activity-post ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: Thymia API version: 1.0.0 paths: /v1/models/mental-wellness-activity: post: operationId: create-model-run-with-activity-v-1-models-mental-wellness-activity-post summary: Run the model using the Thymia Activity Plugin description: >- Create a new run of the Mental Wellness model for a specific user, using the Thymia Activity Plugin to host an activity and capture a recording. The response contains: * A link for the user to perform an activity. The link should then be embedded in the Thymia Activity Plugin. Once the activity is completed, the recording of it will be used automatically as input to the model. * The id of the new model run which can be used to poll for results **after the activity has been completed**. tags: - subpackage_mentalWellnessThymiaHelios parameters: - name: x-api-key in: header description: Your API Activation Key required: true schema: type: string responses: '200': description: >- Details of new model run created, including a link to a thymia activity. content: application/json: schema: $ref: >- #/components/schemas/MentalWellnessModelRunCreateActivityResponse '422': description: Validation Error content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' requestBody: content: application/json: schema: $ref: '#/components/schemas/MentalWellnessModelRunActivityCreate' components: schemas: BirthSex: type: string enum: - MALE - FEMALE - INTERSEX - UNKNOWN description: An enumeration. title: BirthSex UserDetails: type: object properties: userLabel: type: string description: A unique label identifying a user that all model input refers to dateOfBirth: type: string format: date description: >- An ISO 8601 date; if day or month are unknown, supply the parts which *are* known and use `01` for the rest birthSex: $ref: '#/components/schemas/BirthSex' description: The sex assigned to a user at birth required: - userLabel - dateOfBirth - birthSex title: UserDetails LanguageCode: type: string enum: - en - en-AU - en-GB - en-IE - en-IN - en-US - en-ZA - es-ES - es-US - id-ID - ja-JP description: An enumeration. title: LanguageCode Accent: type: string enum: - ID - NG - KE description: An enumeration. title: Accent Tag: type: object properties: name: type: string value: type: string required: - name - value title: Tag DataDeletionType: type: string enum: - RECORDINGS description: An enumeration. title: DataDeletionType MentalWellnessModelRunActivityCreate: type: object properties: user: $ref: '#/components/schemas/UserDetails' description: The user that this model run is being submitted for language: $ref: '#/components/schemas/LanguageCode' description: >- The code of the language being spoken by the user in the recording to be uploaded accent: $ref: '#/components/schemas/Accent' description: >- The accent of the user speaking, in addition to the language they are speaking sleepTime: type: string format: date-time description: >- When the user fell asleep for their last main sleep before the recording was made (as an ISO 8601 datetime). This should not include timezone information but it is assumed to be in the local timezone of the user in the recording so the time of day can be inferred. wakeTime: type: string format: date-time description: >- When the user woke from their last main sleep before the recording was made (as an ISO 8601 datetime). This should not include timezone information but it is assumed to be in the local timezone of the user in the recording so the time of day can be inferred. tags: type: array items: $ref: '#/components/schemas/Tag' description: |- Name/Value pairs to tag a model run for later identification. Note: * Tag names must be unique * At most 20 tags are allowed per model run deleteData: type: boolean default: false description: >- Boolean flag indicating if user data is to be deleted after the completion of the model run. If True, the recordings, model inputs and model results will be deleted 12 hrs after the model run completes. Attempts to retrieve results after this time will receive a 404 error. If you wish to be more specific about which types of data are deleted, see the `data_to_delete` field below. dataToDelete: type: array items: $ref: '#/components/schemas/DataDeletionType' description: >- An array of data types to indicate which data inputs should be deleted after completion of the model run. To be used in combination with the `delete_data` boolean flag. Note: * If `delete_data` is set to `true` and `data_to_delete` value is omitted, all data will be deleted. * If `delete_data` is set to `true` and `data_to_delete` value is set to one or more data types, only the specified data will be deleted. activityType: type: string description: >- The type of activity to show to users. If omitted, a default activity will be used. See the [online docs](https://thymia.ai/docs/building-your-integration) for the latest list of activities to choose from. required: - user - language title: MentalWellnessModelRunActivityCreate MentalWellnessModelRunCreateActivityResponse: type: object properties: id: type: string format: uuid description: The id of the newly created model run activityLink: type: string description: >- A link to the thymia app, allowing users to perform an activity which captures a recording required: - id - activityLink title: MentalWellnessModelRunCreateActivityResponse ValidationErrorLocItems: oneOf: - type: string - type: integer title: ValidationErrorLocItems ValidationError: type: object properties: loc: type: array items: $ref: '#/components/schemas/ValidationErrorLocItems' msg: type: string type: type: string required: - loc - msg - type title: ValidationError HTTPValidationError: type: object properties: detail: type: array items: $ref: '#/components/schemas/ValidationError' title: HTTPValidationError securitySchemes: APIKeyHeader: type: apiKey in: header name: x-api-key description: Your API Activation Key ``` ## SDK Code Examples ```python import requests url = "https://api.example.com/v1/models/mental-wellness-activity" payload = { "user": { "userLabel": "a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e", "dateOfBirth": "1985-04-12", "birthSex": "MALE" }, "language": "en-GB" } headers = { "x-api-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.example.com/v1/models/mental-wellness-activity'; const options = { method: 'POST', headers: {'x-api-key': '', 'Content-Type': 'application/json'}, body: '{"user":{"userLabel":"a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e","dateOfBirth":"1985-04-12","birthSex":"MALE"},"language":"en-GB"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/v1/models/mental-wellness-activity" payload := strings.NewReader("{\n \"user\": {\n \"userLabel\": \"a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e\",\n \"dateOfBirth\": \"1985-04-12\",\n \"birthSex\": \"MALE\"\n },\n \"language\": \"en-GB\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("x-api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.example.com/v1/models/mental-wellness-activity") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"user\": {\n \"userLabel\": \"a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e\",\n \"dateOfBirth\": \"1985-04-12\",\n \"birthSex\": \"MALE\"\n },\n \"language\": \"en-GB\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/v1/models/mental-wellness-activity") .header("x-api-key", "") .header("Content-Type", "application/json") .body("{\n \"user\": {\n \"userLabel\": \"a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e\",\n \"dateOfBirth\": \"1985-04-12\",\n \"birthSex\": \"MALE\"\n },\n \"language\": \"en-GB\"\n}") .asString(); ``` ```php request('POST', 'https://api.example.com/v1/models/mental-wellness-activity', [ 'body' => '{ "user": { "userLabel": "a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e", "dateOfBirth": "1985-04-12", "birthSex": "MALE" }, "language": "en-GB" }', 'headers' => [ 'Content-Type' => 'application/json', 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.example.com/v1/models/mental-wellness-activity"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"user\": {\n \"userLabel\": \"a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e\",\n \"dateOfBirth\": \"1985-04-12\",\n \"birthSex\": \"MALE\"\n },\n \"language\": \"en-GB\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "x-api-key": "", "Content-Type": "application/json" ] let parameters = [ "user": [ "userLabel": "a1f5c3d9-7b2e-4f8a-9c3d-2e7f1b6a4d8e", "dateOfBirth": "1985-04-12", "birthSex": "MALE" ], "language": "en-GB" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/models/mental-wellness-activity")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```