# Retrieve messages GET https://api.prolific.com/api/v1/messages/ Get messages between you and another user or your messages with all users. Reference: https://beta-docs.prolific.com/api-reference/messages/get-messages ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Retrieve messages version: endpoint_messages.GetMessages paths: /api/v1/messages/: get: operationId: get-messages summary: Retrieve messages description: >- Get messages between you and another user or your messages with all users. tags: - - subpackage_messages parameters: - name: user_id in: query description: >- Another user ID, must be provided if no created_after date is provided. required: false schema: type: string - name: created_after in: query description: >- Only fetch messages created after timestamp. Datetime in ISO8601 format. Must be provided if no user_id is provided. You can only fetch up to the last 30 days of messages. required: false schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: Messages content: application/json: schema: $ref: '#/components/schemas/Messages' '400': description: Error content: {} components: schemas: MessageDataCategory: type: string enum: - value: payment-timing - value: payment-issues - value: technical-issues - value: feedback - value: rejections - value: other MessageData: type: object properties: study_id: type: string description: >- What study the message relates to. In case this is not automatically filled for the participant, they can choose which study their message relates to. category: $ref: '#/components/schemas/MessageDataCategory' description: Participants can self-categorise their message before sending it. Message: type: object properties: id: type: string description: Unique ID of the message sender_id: type: string description: Id of the user who sent the message body: type: string description: Body of the message. sent_at: type: string format: date-time description: Date time when message was sent type: type: string description: Will only me message for now channel_id: type: string description: The channel ID, for linking back to a thread in the Prolific app. data: $ref: '#/components/schemas/MessageData' description: Metadata for a message required: - id - sender_id - body - sent_at - channel_id Messages: type: object properties: results: type: array items: $ref: '#/components/schemas/Message' ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/messages/" headers = {"Authorization": ""} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/messages/'; const options = {method: 'GET', headers: {Authorization: ''}}; 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" "net/http" "io" ) func main() { url := "https://api.prolific.com/api/v1/messages/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "") 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.prolific.com/api/v1/messages/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = '' response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.get("https://api.prolific.com/api/v1/messages/") .header("Authorization", "") .asString(); ``` ```php request('GET', 'https://api.prolific.com/api/v1/messages/', [ 'headers' => [ 'Authorization' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/messages/"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/messages/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers 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() ```