Skip to main content

Reports - Delivery Data

How does it work?

This report can generate a report of your delivery data in either CSV or JSON format. You can then use it to manipulate the data yourself using a spreadsheet app, import it into your BI tooling software, or import it into other third-party systems.

It allows you to specify the format you want the data to be in, the start and end dates, as well as the fields you'd like. You can request data for either a set of accounts, or an entire business, or company.

The report may take some time to complete, and this endpoint is only responsible for triggering the report. To get the actual data, you can either do it via our API or get a webhook from us when the report has finished processing.

Reports expire after 30 days.


Part 1. Triggering the request

- Request Values

KeyTypeValue
entitystringOne of: company, business, or account. Specifying either company or business will result in generating a report for accounts under that company or business.
uuidsarrayArray of uuids.
kindstringOne of: delivery_data
file_formatstringOne of: csv of json
date_startstringStart date of the report
date_endstringEnd date of the report
fieldsarraySpecify the fields to be included in the report. Please see available fields below.

POST /v1/analytics/reports

Example Request

POST /v1/analytics/reports

{
"entity": "account",
"uuids": [
"83f8e61ca65f"
],
"kind": "delivery_data",
"file_format": "csv",
"date_start": "2022-10-01",
"date_end": "2022-11-01",
"fields": [
"account_uuid",
"order_uuid",
"order_recipient_email",
"order_grand_total_including_tax",
"order_description",
"crowfly_distance_mi"
]
}

Example Response

{
"uuid": "fYH8L5hXv9djr3tBgQVHxzcr",
"kind": "delivery_data",
"status": "created"
}

Part 2. Getting the report

There are two ways of getting the report output via our API:

  • Continuously call our API to check if it has finished processing. When you create the report, you will get a unique ID (uuid) that you can then reference.
  • Opt to receive a webhook instead.

Getting the report via API

Request

GET /v1/analytics/reports/:uuid

Example Request

GET /v1/analytics/reports/fYH8L5hXv9djr3tBgQVHxzcr

Response

KeyTypeValue
uuidstringThe UUID of the report. Use this to reference in further calls to actually get the data.
kindstringThe report type. The only report we currently have is delivery_data. Please ensure you add a check for this to ensure that new report types dont' break anything.
statusstringOne of: created, processing, completed, failed, or expired.
urlstringThe URL of the file containing the report.

Example Response

{
"uuid": "fYH8L5hXv9djr3tBgQVHxzcr",
"kind": "delivery_data",
"status": "completed",
"url": "https://cds-report-exports.s3.amazonaws.com/production/1546831361/fYH8L5hXv9djr3tBgQVHxzcr/delivery_data.csv?response-content-disposition=attachment%3B%20filename%3Ddelivery_data.csv&X-Amz-Algorithm=x&X-Amz-Credential=x&X-Amz-Date=x&X-Amz-Expires=x&X-Amz-SignedHeaders=host&X-Amz-Signature=x"
}

Getting the report via webhook

Please contact your account manager to get this setup. The URL has to be the same for all report types.

{
"data": {
"uuid": "fYH8L5hXv9djr3tBgQVHxzcr",
"kind": "delivery_data",
"status": "completed",
"url": "https://cds-report-exports.s3.amazonaws.com/production/1546831361/fYH8L5hXv9djr3tBgQVHxzcr/delivery_data.csv?response-content-disposition=attachment%3B%20filename%3Ddelivery_data.csv&X-Amz-Algorithm=x&X-Amz-Credential=x&X-Amz-Date=x&X-Amz-Expires=x&X-Amz-SignedHeaders=host&X-Amz-Signature=x"
},
"event_name": "analytics_report_ready"
}

Available Fields

General

KeyTypeValue
uuidstringCaptain's unique order ID. This is generated at the point of the order being created.
order_uuidstringDuplicate of the above.
statusstringOne of: created, being_prepared, prepared, in_progress, completed, failed, cancelled, auto_closed, not_dispatched
delivery_statusstringOne of: unassigned_to_driver, assigned_to_driver, assigned_and_accepted_by_driver, collected, dropped_off
special_instructionsstringSpecial instructions for the order, as passed in by you at the point of the order being created.
order_descriptionstringA friendly order ID, as passed in by you at the point of the order being created.
order_partners_unique_internal_order_idstringA unique order ID, as passed in by you at the point of the order being created.

Delivery Information

KeyTypeValue
geo_verifiedboolean or nilWhether or not the delivery was performed correctly by the driver, i.e. whether or not the driver marked the order as picked up and delivered at the right physical places,. It will be set to true if both of these conditions are true, otherwise it will be set to false. It will be empty if geoverification was not performed on the delivery (e.g. if the delivery was cancelled)
dropoff_sequence_numberintegerIf this delivery is part of a multi-drop delivery group, the sequence number of this delivery.
crowfly_distance_kmdecimalCrowfly distance between the store and the dropoff address, in kilometers.
crowfly_distance_midecimalCrowfly distance between the store and the dropoff address, in miles.
bearingdecimalBearing from the store towards the dropoff location.

Timings

KeyTypeValue
created_atdatetimeThe time that the order was received by Captain.
order_placed_atdatetimeThe time that your system marked the order as created
collected_atdatetimeThe time the order was marked as picked up by the driver.
delivered_atdatetimeThe time the order was marked as delivered by the driver.
promised_delivery_time_atdatetimeThe time that the customer was promised the delivery, as passed in by you at the point of the order being created.
promised_delivery_minutesintegerThe promised amount of minutes it will take to deliver the order to the customer, as passed in by you at the point of the order being created.

Store / Account

KeyTypeValue
account_uuidstringThe store's unique identifier on Captain.
store_namestringThe store's name.
store_partners_external_identifierstringThe store's unique identifier on your system.

Recipient & Address

KeyTypeValue
order_recipient_full_namestringThe recipient's full name
order_recipient_emailstringThe recipient's email address
order_recipient_phone_numberstringThe recipient's phone number
order_recipient_first_line_addressstringThe first line of the receipient's address
order_recipient_zipcodestringThe recipient's zip code / postcode
order_recipient_citystringThe recipient's city
order_recipient_latitudestringThe recipient's latitude
order_recipient_longitudestringThe recipient's longitude

Financial Data

KeyTypeValue
order_grand_total_including_taxdecimalThe grand total of the order, as passed in by you at the point of the order being created.
order_total_tip_left_for_driverdecimalThe total tip

Driver Data

KeyTypeValue
assigned_driver_uuidstringThe driver's unique driver ID on the Captain.AI system, unique per store.
assigned_driver_user_uuidstringThe driver's unique user ID on the Captain.AI system. If you have the same driver working in multiple stores, you can use this field as a unique identifier.
assigned_driver_first_namestringThe driver's first name
assigned_driver_last_namestringThe driver's last name
assigned_driver_phone_numberstringThe driver's phone number
assigned_driver_profile_picture_urlstringThe driver's profile picture URL
odometer_at_collectionstringThe driver's phone's odometer reading at the point of this order being picked up.
odometer_at_deliverystringThe driver's phone's odometer reading at the point of this order being delivered.
odometer_upon_return_to_basestringThe driver's phone's odometer reading at the point of the driver returning to the store for the first time after this delivery was completed.