Referrals

GET /referrals

List the referrals customers have made through the loyalty programs, newest first by default. Supports search, filtering and cursor pagination.

Requires the loyalty:read permission.

Query Parameters

limitnumber

The number of records to return.

cursorstring

A pagination cursor. Fetch the next page by passing the nextCursor value from the previous response.

sortcreatedAt | -createdAt

The sort order. Prefix a field with - to sort descending. Defaults to -createdAt.

searchstring

A free-text search term, matched case-insensitively against the record's most identifying fields. Combined with filter using AND.

filterstring

A JSON-encoded filter document, for example {"createdAt":{"$gte":"2025-01-01T00:00:00Z"}}. Filterable fields: id, code, status, loyaltyProgramId, metadata, createdAt, referringCustomer.id, referringCustomer.email, referringCustomer.firstName, referringCustomer.lastName, referringCustomer.metadata, referringCustomer.emailOptOut, referringCustomer.emailOptOutSource, referringCustomer.createdAt, referredCustomer.id, referredCustomer.email, referredCustomer.firstName, referredCustomer.lastName, referredCustomer.metadata, referredCustomer.emailOptOut, referredCustomer.emailOptOutSource, referredCustomer.createdAt. See Filtering for the syntax.

includestring

A comma-separated list of extra fields to compute and return. Each one costs an additional query, so ask only for what you need. Available: referringCustomer, referredCustomer, loyaltyProgram.

Request
curl \
  "https://api.cascade.dev/referrals" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
Response
{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "loyaltyProgramId": "550e8400-e29b-41d4-a716-446655440000",
      "referringCustomerId": "550e8400-e29b-41d4-a716-446655440000",
      "referredCustomerId": "550e8400-e29b-41d4-a716-446655440000",
      "code": "string",
      "status": "pending",
      "completedAt": "2025-01-15T09:30:00Z",
      "metadata": "...",
      "createdAt": "2025-01-15T09:30:00Z",
      "updatedAt": "2025-01-15T09:30:00Z",
      "referringCustomer": {
        "id": "...",
        "email": "...",
        "phone": "...",
        "firstName": "...",
        "lastName": "...",
        "country": "...",
        "birthday": "...",
        "metadata": "...",
        "notes": "...",
        "emailOptOut": "...",
        "emailOptOutAt": "...",
        "emailOptOutSource": "...",
        "createdAt": "...",
        "updatedAt": "..."
      },
      "referredCustomer": {
        "id": "...",
        "email": "...",
        "phone": "...",
        "firstName": "...",
        "lastName": "...",
        "country": "...",
        "birthday": "...",
        "metadata": "...",
        "notes": "...",
        "emailOptOut": "...",
        "emailOptOutAt": "...",
        "emailOptOutSource": "...",
        "createdAt": "...",
        "updatedAt": "..."
      },
      "loyaltyProgram": {
        "id": "...",
        "name": "..."
      }
    }
  ],
  "nextCursor": "string"
}

GET /referrals/{id}

Get a single referral by ID.

Requires the loyalty:read permission.

Path Parameters

idstring (uuid)required

The ID of the referral.

Query Parameters

includestring

A comma-separated list of extra fields to compute and return. Each one costs an additional query, so ask only for what you need. Available: referringCustomer, referredCustomer, loyaltyProgram.

Request
curl \
  "https://api.cascade.dev/referrals/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
Response
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "loyaltyProgramId": "550e8400-e29b-41d4-a716-446655440000",
  "referringCustomerId": "550e8400-e29b-41d4-a716-446655440000",
  "referredCustomerId": "550e8400-e29b-41d4-a716-446655440000",
  "code": "string",
  "status": "pending",
  "completedAt": "2025-01-15T09:30:00Z",
  "metadata": "...",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z",
  "referringCustomer": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "phone": "string",
    "firstName": "string",
    "lastName": "string",
    "country": "string",
    "birthday": "string",
    "metadata": "...",
    "notes": "string",
    "emailOptOut": true,
    "emailOptOutAt": "2025-01-15T09:30:00Z",
    "emailOptOutSource": "customer",
    "createdAt": "2025-01-15T09:30:00Z",
    "updatedAt": "2025-01-15T09:30:00Z"
  },
  "referredCustomer": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "phone": "string",
    "firstName": "string",
    "lastName": "string",
    "country": "string",
    "birthday": "string",
    "metadata": "...",
    "notes": "string",
    "emailOptOut": true,
    "emailOptOutAt": "2025-01-15T09:30:00Z",
    "emailOptOutSource": "customer",
    "createdAt": "2025-01-15T09:30:00Z",
    "updatedAt": "2025-01-15T09:30:00Z"
  },
  "loyaltyProgram": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "string"
  }
}

PATCH /referrals/{id}

Update a referral's status or metadata. Use this to approve or reject a referral by hand. Triggers the referral.updated webhook.

Requires the loyalty:write permission.

Path Parameters

idstring (uuid)required

The ID of the referral to update.

Body Parameters

statuspending | completed | revoked

The referral's new status. Marking it complete is what triggers the referrer's reward.

metadataobject

Replaces the referral's metadata wholesale. Omit to leave it alone.

Request
curl \
  -X PATCH \
  "https://api.cascade.dev/referrals/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer sk_YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "status": "pending",
  "metadata": "..."
}'
Response
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "loyaltyProgramId": "550e8400-e29b-41d4-a716-446655440000",
  "referringCustomerId": "550e8400-e29b-41d4-a716-446655440000",
  "referredCustomerId": "550e8400-e29b-41d4-a716-446655440000",
  "code": "string",
  "status": "pending",
  "completedAt": "2025-01-15T09:30:00Z",
  "metadata": "...",
  "createdAt": "2025-01-15T09:30:00Z",
  "updatedAt": "2025-01-15T09:30:00Z",
  "referringCustomer": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "phone": "string",
    "firstName": "string",
    "lastName": "string",
    "country": "string",
    "birthday": "string",
    "metadata": "...",
    "notes": "string",
    "emailOptOut": true,
    "emailOptOutAt": "2025-01-15T09:30:00Z",
    "emailOptOutSource": "customer",
    "createdAt": "2025-01-15T09:30:00Z",
    "updatedAt": "2025-01-15T09:30:00Z"
  },
  "referredCustomer": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "phone": "string",
    "firstName": "string",
    "lastName": "string",
    "country": "string",
    "birthday": "string",
    "metadata": "...",
    "notes": "string",
    "emailOptOut": true,
    "emailOptOutAt": "2025-01-15T09:30:00Z",
    "emailOptOutSource": "customer",
    "createdAt": "2025-01-15T09:30:00Z",
    "updatedAt": "2025-01-15T09:30:00Z"
  },
  "loyaltyProgram": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "string"
  }
}