Skip to main content
POST
/
v1
/
invoices
/
retail
/
ingest
curl --request POST \
  --url https://api.paypulse.io/v1/invoices/retail/ingest \
  --header 'Authorization: Bearer <token>'
{
  "message": "Retail invoices fetched successfully",
  "code": 200,
  "data": {
    "totalEmailsFound": 5,
    "byVendor": {
      "dominos": 2,
      "foodora": 3
    },
    "dateRange": {
      "start": "2025/02/19",
      "end": "2025/03/21"
    },
    "errors": []
  }
}

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/azfar-imtiaz/PayPulse-Cloud/llms.txt

Use this file to discover all available pages before exploring further.

Authentication

All requests to this endpoint must include a valid JWT in the Authorization header.
Authorization: Bearer <token>

What this endpoint does

This endpoint queries the VendorConfig table for all active vendors, then searches the user’s Gmail account for matching invoice emails within the determined date range. HTML content from matching emails is uploaded to S3. Duplicate emails (already present in S3) are skipped. If no custom date range is provided, the search window is determined automatically:
  • First fetch: last 30 days.
  • Subsequent fetches: from the last_retail_invoice_fetch timestamp stored on the user record.
After a successful run, the user’s last_retail_invoice_fetch timestamp is updated. The Gmail account must be connected before calling this endpoint. See Store Gmail tokens.

Request body

The request body is optional. All fields are optional.
start_date
string
Start of the custom search date range, in YYYY-MM-DD format. Must be provided together with end_date.
end_date
string
End of the custom search date range, in YYYY-MM-DD format. Must be provided together with start_date.
vendor_category
string
Optionally restrict processing to a single vendor category. Valid values: food-delivery, clothing, technology, subscriptions, grocery, utility, miscellaneous, travel.

Response

message
string
A human-readable confirmation message. Example: "Retail invoices fetched successfully"
code
number
HTTP status code. 200 on success.
data
object

Error responses

StatusError codeDescription
400MISSING_FIELDSOnly one of start_date / end_date was provided, or a required key is missing.
400INVALID_JSONThe request body is not valid JSON.
401INVALID_CREDENTIALSThe Authorization header is missing or the OAuth token is invalid.
401TOKEN_EXPIREDThe JWT has expired.
404USER_NOT_FOUNDNo account exists for the user ID encoded in the token.
502DEPENDENCY_FAILUREThe Gmail API returned an error.
502GMAIL_TOKEN_EXPIREDThe Gmail OAuth refresh token has expired and the account must be re-connected.
500INTERNAL_SERVER_ERRORAn unexpected server-side error occurred.
Error responses follow this structure:
{
  "error": {
    "code": "MISSING_FIELDS",
    "message": "Both start_date and end_date must be provided for custom date range"
  }
}
curl --request POST \
  --url https://api.paypulse.io/v1/invoices/retail/ingest \
  --header 'Authorization: Bearer <token>'
{
  "message": "Retail invoices fetched successfully",
  "code": 200,
  "data": {
    "totalEmailsFound": 5,
    "byVendor": {
      "dominos": 2,
      "foodora": 3
    },
    "dateRange": {
      "start": "2025/02/19",
      "end": "2025/03/21"
    },
    "errors": []
  }
}

Build docs developers (and LLMs) love