Skip to main content
POST
/
reports
/
generate
curl --request POST \
  --url https://api.otpiq.com/api/reports/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "startDate": "2026-01-01T00:00:00.000Z",
  "endDate": "2026-01-31T23:59:59.999Z"
}
'
{
  "_id": "65a1b2c3d4e5f6789012345",
  "reportId": "65a1b2c3d4e5f6789012345",
  "filename": "delivery-report-myproject-2026-02-12T12-00-00-000Z-a1b2c3d4.csv",
  "fileId": "4_z1234567890_f1020304050607080",
  "downloadUrl": "https://cdn.example.com/files/delivery-report-....csv",
  "recordCount": 150,
  "dateRange": {
    "startDate": "2026-01-01T00:00:00.000Z",
    "endDate": "2026-01-31T23:59:59.999Z"
  },
  "filters": {
    "startDate": "2026-01-01T00:00:00.000Z",
    "endDate": "2026-01-31T23:59:59.999Z",
    "phoneNumbers": [
      "+9647701234567"
    ],
    "statuses": [
      "sent",
      "failed"
    ]
  },
  "expiresAt": "2026-03-14T12:00:00.000Z",
  "status": "available",
  "createdAt": "2026-02-12T12:00:00.000Z",
  "updatedAt": "2026-02-12T12:00:00.000Z",
  "message": "Delivery report generated successfully"
}
Use the downloadUrl from the response to download the CSV file directly. There is no separate download endpoint—reports are available for 30 days after generation.

CSV content

The downloaded CSV includes these columns:
ColumnDescription
Message IDInternal message identifier (smsId)
Phone NumberRecipient phone number
Sender IDSender ID name (or “System”)
Cost (IQD)Cost in IQD
Message TypeOTP, Custom, WhatsApp Template, or Other
Delivery Statuspending, sent, delivered, read, or failed
Error ReasonLast error in the message flow (empty if none)
RefundedYes/No
Created AtISO 8601
Sent AtISO 8601 (if sent)

Authorizations

Authorization
string
header
required

API key authentication. Format: Bearer sk_live_your_api_key_here

Body

application/json

Report generation parameters. startDate and endDate are required.

startDate
string<date-time>
required

Start of the date range (ISO 8601, e.g. 2026-01-01T00:00:00.000Z)

Example:

"2026-01-01T00:00:00.000Z"

endDate
string<date-time>
required

End of the date range (ISO 8601). Must be on or after startDate.

Example:

"2026-01-31T23:59:59.999Z"

phoneNumbers
string[]

If provided, only messages to these phone numbers are included

Example:
["+9647701234567"]
statuses
enum<string>[]

If provided, only messages with these delivery statuses are included

Available options:
pending,
sent,
delivered,
read,
failed
Example:
["sent", "failed"]

Response

Delivery report generated successfully. Use downloadUrl to fetch the CSV file.

_id
string
required

MongoDB ObjectId of the report

Example:

"65a1b2c3d4e5f6789012345"

reportId
string
required

Same as _id; convenience for API consumers

downloadUrl
string<uri>
required

Use this URL to download the CSV. No separate download endpoint.

recordCount
integer
required

Number of message rows in the report

dateRange
object
required
expiresAt
string<date-time>
required

Reports valid for 30 days

status
enum<string>
required
Available options:
available,
expired,
deleted
message
string
required

Success message

Example:

"Delivery report generated successfully"

project
string

Project ObjectId

filename
string

Storage filename

fileId
string

Storage provider file identifier

filters
object
createdAt
string<date-time>
updatedAt
string<date-time>