Get the messages associated to the order
GET /v2/post_checkout/chat/{order_id}/messages
Gets all the messages of the conversation between the customer and the shopper.
Security
Name | In | Description |
---|---|---|
Authorization | header | The Authorization header with the bearer token acquired during authentication. |
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
order_id | path | string | The ID of the order. | |
X-Treat-Ids-As-Internal | header | boolean |
Request
None.Request examples
- cURL
- Java
- Python
- Go
curl --request GET \
--url 'https://connect.instacart.com/v2/post_checkout/chat/{order_id}/messages' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'X-Treat-Ids-As-Internal: true'
HttpResponse<String> response = Unirest.get("https://connect.instacart.com/v2/post_checkout/chat/{order_id}/messages")
.header("Accept", "application/json")
.header("Authorization", "Bearer <token>")
.header("X-Treat-Ids-As-Internal", "true")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
headers = {
'Accept': "application/json",
'Authorization': "Bearer <token>",
'X-Treat-Ids-As-Internal': "true"
}
conn.request("GET", "/v2/post_checkout/chat/{order_id}/messages", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://connect.instacart.com/v2/post_checkout/chat/{order_id}/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Treat-Ids-As-Internal", "true")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
Field | Type | Required | Description |
---|---|---|---|
chat_messages | Array(Message) | The list of messages. | |
metadata | ChatMessagesMetadata | Metadata associated with the chat messages. |
Message Object
Field | Type | Required | Description |
---|---|---|---|
id | integer | The ID of the message. | |
order_id | integer | The order ID for this message. | |
created_at | string | When this message was created. | |
recipient_id | integer | The ID of the message recipient. | |
recipient_type | string | The type of the message recipient. One of be 'user' or 'driver'. | |
sender_id | integer | The ID of the message sender. | |
sender_type | string | The type of the message sender. One of 'user' or 'driver'. | |
read | boolean | Indicates whether this message has been read. | |
read_at | string | Indicates the time this message was read. | |
body | string | The body of this message. | |
image | string | The image associated with this message. |
ChatMessagesMetadata Object
Field | Type | Required | Description |
---|---|---|---|
customer | ChatUser | The metadata of the customer. | |
current_shopper | ChatUser | The metadata for the current shopper. | |
shoppers | Array(ChatUser) | The metadata of the shoppers. |
ChatUser Object
Field | Type | Required | Description |
---|---|---|---|
id | integer | The ID of the user. | |
display_name | string | The display name of the user. | |
avatar_url | string | The URL of the user's avatar. |
Response examples
200 Success
200
Messages Fetched
{
"chat_messages": [
{
"id": 123456789,
"order_id": 122233,
"created_at": "2021-01-01T00:00:00Z",
"recipient_id": 334354343,
"recipient_type": "user",
"sender_id": 55655345,
"sender_type": "driver",
"read": false,
"body": "MessageBody"
}
],
"metadata": {
"customer": {
"id": 2,
"display_name": "John",
"avatar_url": ""
},
"current_shopper": {
"id": 4,
"display_name": "Robert",
"avatar_url": "https://speedwagon.foundation/avatar/reospeedwagon.jpg"
},
"shoppers": [
{
"id": 55655345,
"display_name": "SomeFirstName",
"avatar_url": "SomeURL"
},
{
"id": 123456789,
"display_name": "SomeFirstName2",
"avatar_url": "SomeURL2"
},
{
"id": 4,
"display_name": "Robert",
"avatar_url": "https://speedwagon.foundation/avatar/reospeedwagon.jpg"
}
]
}
}
4XX Errors
Error responses return either a single error or multiple errors.
HTTP Code | Cause | Error Message | Error Code | Error Meta |
---|---|---|---|---|
404 | Order not found | "Resource not found" | 4000 | Not applicable |