Returning.AIDocs
v1

API reference / Gamification / Loyalty Points

.md

Get loyalty points export download link

Get a temporary download URL for a completed export.

Last updated 12 Oct 2026API v1

Method
GET
Path
https://api.returning.ai/v1/loyalty-exports/{exportId}/download
Permission
customerSuccess
Retries
Safe to repeat while the file remains available; links do not extend file retention.

When to use this

  • Download a completed CSV or JSON report into your reporting system.
  • Replace an expired download link while the file remains available.

Authentication#

Header
Authorization: Bearer <API_KEY>
Permission
customerSuccessShown in the dashboard as Customer Success.

Use a Community API key with customerSuccess, shown as Customer Success in the dashboard. Keep the key on your backend and send Authorization: Bearer <API_KEY>. The key selects the community; do not send a community ID. Personal API keys are not supported.

All three calls use https://api.returning.ai and return Cache-Control: no-store. They accept no query parameters. A valid community key with the required permission can read that community's export jobs, including jobs created by another key in the same community.

Successful responses contain meta, message and data. Read job state from data.status. An HTTP 200 means the status request succeeded, even when the job is failed. Errors put their machine-readable code in meta.code; do not branch on message.

Behaviour#

Download the returned URL without forwarding your API key:

BASH
curl --fail --output points.csv '<TEMPORARY_DOWNLOAD_URL>'

The URL is sensitive: anyone holding it may download the file while it remains valid. Do not put it in logs, support tickets or client-side source. The response contains only filename, url and url_expires_at; no checksum or file size is returned here.

Links are generated with an expiry of at most five minutes, bounded by the file's availability. Files have an API availability window of 24 hours after completion. Request a new link if the old one expires while the file remains available. Repeated link requests do not extend the file's availability.

CSV filenames use the export creation time in Unix milliseconds: points-<timestamp>.csv. JSON downloads use points.json.

An unfinished, failed or cancelled job returns 409 EXPORT_NOT_READY. Check status; wait only for queued or processing jobs. An expired file returns 410 EXPORT_EXPIRED.

Request#

Path parameters#

exportId#stringREQUIRED
Export ID returned by Create loyalty points export.

Rule24 hex characters

Eg66f000000000000000000701

Headers#

Authorization#stringREQUIRED
Community API key with Customer Success permission. The key selects the community.

RuleBearer <API_KEY>

curl --request GET \
  --url https://api.returning.ai/v1/loyalty-exports/66f000000000000000000701/download \
  --header 'Authorization: Bearer <API_KEY>'

Response#

Download the file with a plain HTTPS GET. Check Create loyalty points export for CSV columns, JSON fields and daily-load guidance.

Verify and store the file

Compare the downloaded byte length with file_size_bytes from the completed status. For CSV, parse it with a CSV library and count data records, excluding the header; fields can be quoted, so counting newline characters is not a reliable row count. For JSON, count objects in the array. Compare that count with total_rows.

Store the file only after the transfer and parsing checks succeed. Keep customer data private and apply your own retention policy. The API's 24-hour availability is a download window, not a retention policy for files you have saved yourself.

Two different expiry times

What expiresWindowRecovery
A download URLAt most five minutes, shown by url_expires_atRequest another link for the same completed export.
The export file24 hours after completionCreate a deliberately new export. Replaying the original create does not extend availability.

A file-host HTTP 403 may mean the temporary URL expired or was copied incompletely. Get a fresh link and copy it exactly. If a fresh link also fails, stop retrying it repeatedly and contact support with the export ID and API request ID. Do not send support the API key, signed URL or raw customer file.

The file host's errors are not the API's JSON error envelope. Use the status and download-link endpoints to distinguish an unfinished job, an expired artifact and a temporary download failure.

meta#objectALWAYS
Request result and support reference.

Eg{ ... }

status#stringALWAYS
Result of the request.

Rulesuccess

statusCode#integerALWAYS
HTTP status of the request.

Eg200

requestId#stringALWAYS
Support reference for this request.

Eg"example-request"

message#stringALWAYS
Human-readable summary. Do not branch on it.

Eg"Loyalty export download success."

data#objectALWAYS
Temporary download details.

Eg{ ... }

filename#stringALWAYS
Suggested filename for saving the download.

Eg"points-1788397200000.csv"

url#stringALWAYS
Sensitive temporary HTTPS URL. Download without forwarding the API key.

Eg"https://download.example.com/temporary-file"

url_expires_at#stringALWAYS
UTC link expiry, at most five minutes after generation and bounded by file availability.

Eg"2026-09-03T01:07:00.000Z"

{
  "meta": {
    "status": "success",
    "statusCode": 200,
    "requestId": "example-request"
  },
  "message": "Loyalty export download success.",
  "data": {
    "filename": "points-1788397200000.csv",
    "url": "https://download.example.com/temporary-file",
    "url_expires_at": "2026-09-03T01:07:00.000Z"
  }
}

Errors#

Fix the request08

400VALIDATION_ERRORFix the request
Remove unsupported query parameters and correct the request fields.
401AUTHENTICATION_REQUIREDFix the request
Send a valid Community API key in Authorization: Bearer <API_KEY>.
403API_KEY_PERMISSION_DENIEDFix the request
Use a Community API key with Customer Success permission.
403COMMUNITY_ACCESS_DENIEDFix the request
Use a Community API key, not a personal API key.
400Fix the request
Invalid request or unsupported query parameters.
401Fix the request
Missing or invalid API key.
403Fix the request
A Community API key with the required permission is needed.
410Fix the request
The export artifact has expired.

Fix the data05

404COMMUNITY_NOT_FOUNDFix the data
Contact support about the community selected by your API key.
404EXPORT_NOT_FOUNDFix the data
Check the export ID and the community selected by your API key.
410EXPORT_EXPIREDFix the data
Create a new export with a new idempotency key if you still need the file.
404Fix the data
The export was not found.
409Fix the data
The export is not ready.

Retry with backoff07

503EXPORTS_UNAVAILABLERetry with backoff
Retry with backoff. For create, preserve the original body and idempotency key.
500AUTHENTICATION_FAILEDRetry with backoff
Retry with backoff; contact support if authentication checks keep failing.
409EXPORT_NOT_READYRetry with backoff
Read status. Wait only for queued or processing jobs; do not keep polling failed or cancelled jobs.
503EXPORT_ARTIFACT_UNAVAILABLERetry with backoff
Retry with backoff; contact support if the file remains unavailable.
503EXPORT_STORAGE_UNAVAILABLERetry with backoff
Retry with backoff; contact support if the file remains unavailable.
503EXPORT_SIGNING_UNAVAILABLERetry with backoff
Retry with backoff; contact support if no download link becomes available.
503Retry with backoff
Exports disabled or unavailable. Retry creation with the same idempotency key.
{
  "meta": {
    "status": "error",
    "statusCode": 400,
    "code": "VALIDATION_ERROR",
    "requestId": "req_example"
  },
  "message": "Loyalty export request error.",
  "detail": "Invalid request or unsupported query parameters."
}

Next step#

Create loyalty points exportPOST/v1/loyalty-exportsRead the file format and daily-load guidance, or request another report.