API Docs

Global settings

Get orders by team

Returns all MPower Orders from a selected team within a specified date range.

POST/https://api-get-orders-by-team-kigtdz23uq-ew.a.run.app

Headers

Content-Type
application/json
string
x-api-key
<API_KEY>
string

Body Parameters

team_id
Required, not empty.
BVqCv3Cfr4fIpvauWY7Y
string
status
Required. Must be one of WAITING, LINKING, DELIVERING, DELIVERED, CANCELLED, or ALL.
ALL
WAITING | LINKING | DELIVERING | DELIVERED | CANCELLED | ALL
start_date
Required date in strict YYYY-MM-DD format. Converted to a Unix timestamp in milliseconds using midnight UTC.
2026-01-01
string
end_date
Required date in strict YYYY-MM-DD format. Converted to a Unix timestamp in milliseconds using midnight UTC. The end date is exclusive.
2026-07-03
string

cURL

curl -i \
  -X POST \
  -H "Content-Type: application/json" \
  -H "x-api-key: <API_KEY>" \
  -d '{
    "team_id": "BVqCv3Cfr4fIpvauWY7Y",
    "status": "ALL",
    "start_date": "2026-01-01",
    "end_date": "2026-07-03"
  }' \
  https://api-get-orders-by-team-kigtdz23uq-ew.a.run.app

Response

200 Success

{
  "count": 1,
  "orders": {
    "orderDocumentId": {
      "customer_data": {
        "customer_id": "customer-id",
        "customer_name": "Customer name"
      },
      "invoice_id": "invoice-id",
      "market_id": "market-id",
      "team_id": "team-id"
    }
  }
}

200 Success - No orders found

{
  "count": 0,
  "orders": {}
}

400 Invalid payload

{
  "success": false,
  "message": "Invalid payload",
  "errors": [
    {
      "path": "status",
      "message": "Invalid option: expected one of \"WAITING\"|\"LINKING\"|\"DELIVERING\"|\"DELIVERED\"|\"CANCELLED\"|\"ALL\""
    }
  ]
}

401 Unauthorized

{
  "error": "Unauthorized"
}

405 Method not allowed

{
  "error": "Method not allowed"
}

500 API key is not configured

{
  "error": "API key is not configured"
}

Behavior / Side effects

Read-only endpoint

  • Reads from the orders collection.
  • Does not create, update, or delete Firestore documents.

Request behavior

  • Requires team_id, status, start_date, and end_date.
  • start_date and end_date must use strict YYYY-MM-DD.
  • Dates are converted to Unix timestamps in milliseconds at UTC midnight.
  • end_date is exclusive.
  • No pagination, sorting, or extra filters are supported yet.

Query behavior

  • team_id is matched against orders/{order_id}.ownership.team.id.
  • created_at >= start_date.
  • created_at < end_date.
  • status == payload.status only when status is not ALL.
  • If status is ALL, only the status filter is omitted.

Response shape

  • Returns a top-level count.
  • Returns a top-level orders object.
  • Each key inside orders is the Firestore order document ID.
  • Each order includes customer_data, invoice_id, market_id, and team_id.

Field mapping

  • customer_data.customer_id is read from orders/{order_id}.ownership.customer.id.
  • customer_data.customer_name is read from orders/{order_id}.ownership.customer.name.
  • invoice_id is read from orders/{order_id}.invoicing.id.
  • market_id is read from orders/{order_id}.ownership.market.id.
  • team_id is read from orders/{order_id}.ownership.team.id.

Data quality expectations

  • Mapped string fields are expected to be present in Firestore.
  • If a mapped field is missing or is not a valid non-empty string, the API returns null for that field.