Get order messages
GET /v2/post_checkout/orders/{order_id}/order_messages
This operation gets all of an order’s messages and notifications. This includes the messages exchanged between the customer and shoppers, as well as automated order notifications, such as those sent when a shopper replaces an item or completes delivery. The customer-shopper exchanged messages are returned in chat_messages and the status notifications can be found in lifecycle_messages .
To access customer-shopper messages only, use get chat messages.
To protect personal data, chat_messages remain accessible for 24 hours, measured from when an order is delivered or cancelled. The is_expired field indicates whether that time period has elapsed. If true, then the messages are no longer accessible and chat_messages is empty. If false, then all exchanged messages, if any, are still present.
If your account configuration enables the shopper information removal feature, this operation always returns an error.
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. |
Request
None.Request examples
- cURL
- Java
- Python
- Go
curl --request GET \
--url 'https://connect.instacart.com/v2/post_checkout/orders/{order_id}/order_messages' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
HttpResponse<String> response = Unirest.get("https://connect.instacart.com/v2/post_checkout/orders/{order_id}/order_messages")
.header("Accept", "application/json")
.header("Authorization", "Bearer <token>")
.asString();
import http.client
conn = http.client.HTTPSConnection("connect.instacart.com")
headers = {
'Accept': "application/json",
'Authorization': "Bearer <token>"
}
conn.request("GET", "/v2/post_checkout/orders/{order_id}/order_messages", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://connect.instacart.com/v2/post_checkout/orders/{order_id}/order_messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Response
| Field | Type | Required | Description |
|---|---|---|---|
chat_messages | Array(OrderChatMessage) | The messages exchanged between shoppers and the customer while an order is being fulfilled. | |
lifecycle_messages | Array(LifecycleMessage) | The automated notifications sent during an order's lifecycle, such as those that occur when an item is refunded or a delivery is in progress. | |
metadata | OrderMessagesMetadata | Metadata associated with the order messages. |
OrderChatMessage Object
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | The Instacart-generated chat message identifier. Useful for logging purposes or to reference a specific message when working with Instacart support. | |
order_id | integer | The ID of the order associated with the message. | |
created_at | string | When the message was created. A UTC timestamp in ISO-8601 format. | |
recipient_id | integer | The ID of the message recipient. | |
recipient_type | string | The message recipient type. One of | |
sender_id | integer | The ID of the message sender. | |
sender_type | string | The message sender type. One of | |
read | boolean | Indicates whether the recipient has read the message. | |
read_at | string | Indicates the date and time the message was read, if it has been. A UTC timestamp in ISO-8601 format. | |
body | string | The body of the message. | |
image | string | The image associated with this message. |
LifecycleMessage Object
| Field | Type | Required | Description |
|---|---|---|---|
notification_id | integer | The Instacart-generated order notification identifier. Useful for logging purposes or to reference a specific notification when working with Instacart support. | |
medium | string | The medium by which the notification is sent, such as | |
recipient_phone_number | string | The recipient's phone number. Only present for messages that have a | |
sent_from | string | The sender's phone number. Only present for messages that have a | |
created_at | string | When this notification was created. A UTC timestamp in ISO-8601 format. | |
sent_at | string | When this notification was sent. A UTC timestamp in ISO-8601 format. | |
delivered_at | string | When this notification was delivered. A UTC timestamp in ISO-8601 format. | |
body | string | The body of the notification. | |
image | string | The image associated with this notification. |
OrderMessagesMetadata Object
| Field | Type | Required | Description |
|---|---|---|---|
customer | OrderMessageUser | The customer's metadata. | |
current_shopper | OrderMessageUser | The current shopper's metadata. Present only when a shopper is assigned to the order. | |
shoppers | Array(OrderMessageUser) | The metadata of all shoppers who have been assigned to the order. | |
is_expired | boolean | Indicates whether |
OrderMessageUser Object
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | The user's ID. | |
display_name | string | The user's display name. | |
avatar_url | string | The URL of the user's avatar. |
Response examples
200 Success
200Order 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"
}
],
"lifecycle_messages": [
{
"notification_id": 987654321,
"medium": "sms",
"recipient_phone_number": "+14155552671",
"sent_from": "+18005551234",
"created_at": "2021-01-01T00:00:00Z",
"sent_at": "2021-01-01T00:00:01Z",
"delivered_at": "2021-01-01T00:00:02Z",
"body": "Your order has been picked up."
}
],
"metadata": {
"customer": {
"id": 8,
"display_name": "John",
"avatar_url": ""
},
"current_shopper": {
"id": 15,
"display_name": "Robert",
"avatar_url": "https://speedwagon.foundation/avatar/reospeedwagon.jpg"
},
"shoppers": [
{
"id": 55655345,
"display_name": "SomeFirstName",
"avatar_url": "SomeURL"
}
],
"is_expired": false
}
}
4XX Errors
Error responses return either a single error or multiple errors.
| HTTP Code | Cause | Error Message | Error Code | Error Meta |
|---|---|---|---|---|
400 | Order was not created with Fulfillment v3, trying to fetch with client credentials | "User ID not found" | 4001 | Not applicable |
403 | Retailer requested to redact shopper PII | "Shopper PII" | null | Not applicable |
404 | Order not found | "Resource not found" | 4000 | Not applicable |