Skip to content
Developer docs
⌘ K
Dashboard ↗

HTTP endpoints

attachReferralCode

POST /api/v1/referrals/code

Requires partners:write. Keep the Bearer key on your server.

SDK

ts
grizzlee.attachReferralCode(input: { referralCode: string; customerId: string; programId?: string | undefined; customerDisplayName?: string | undefined; orderId?: string | undefined; signals?: { email?: string | undefined; phone?: string | undefined; phoneHash?: string | undefined; paymentFingerprint?: string | undefined; deviceId?: string | undefined; ipAddress?: string | undefined; } | undefined; channel?: "link" | "qr" | "coupon" | "in_app" | undefined; }): Promise<AttachReferralCodeResponse>

HTTP

Use your backend's HTTP client. The cURL request shows the wire format. Replace path parameters and example values.

sh
curl --fail-with-body --request POST \
  'https://app.grizzlee.ca/api/v1/referrals/code' \
  -H "Authorization: Bearer $GRIZZLEE_SERVER_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"customerId":"customer-example","orderId":"order-example","referralCode":"EXAMPLE"}'

Request body

FieldTypeRequiredDetails
programIdstringNo
customerIdstringYes
customerDisplayNamestringNo
orderIdstringNo
referralCodestringYes
channel"link", "qr", "coupon", "in_app"Nodefault "coupon"
signalsobjectNo

signals

FieldTypeRequiredDetails
signals.emailstringNo
signals.phonestringNo
signals.phoneHashstringNo
signals.paymentFingerprintstringNo
signals.deviceIdstringNo
signals.ipAddressstringNo

Request schema

json
{
  "type": "object",
  "properties": {
    "programId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "customerId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "customerDisplayName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "orderId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "referralCode": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "channel": {
      "type": "string",
      "enum": [
        "link",
        "qr",
        "coupon",
        "in_app"
      ],
      "default": "coupon"
    },
    "signals": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "maxLength": 254
        },
        "phone": {
          "type": "string",
          "maxLength": 40
        },
        "phoneHash": {
          "type": "string",
          "pattern": "^[0-9a-fA-F]{64}$"
        },
        "paymentFingerprint": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "deviceId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "ipAddress": {
          "type": "string",
          "maxLength": 64
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "customerId",
    "referralCode"
  ],
  "additionalProperties": false
}

Response

HTTP responses wrap this value in data. The SDK returns the value directly unless the note above describes a wrapper.

FieldTypeRequiredDetails
receiptstringYes
programIdstringYes
placementsarrayYes
partnerIdstringYes
partnerExternalIdstringYes
expiresAtstringYes
durationunionYes
incentiveunionYesThe program's current friend incentive, or null when it has none. Says nothing about eligibility.
displayunionYesThe program's public name, headline and milestone label. Null when the program is gone.
attributionobjectNoPresent for customer programs. It may retain a previously qualified partner.
selfReferralobjectNoPresent when customer links or identity signals match the partner: review or flagged. A blocked match throws self_referral.

duration

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

Variant 4

Type: string.

Variant 5

Type: string.

Variant 6

Type: string.

incentive

Variant 1

Type: null.

Variant 2

FieldTypeRequiredDetails
incentive.type"percent"Yes
incentive.rateBpsnumberYes
incentive.ordersnumberYesHow many of the friend's orders get the incentive.
incentive.newCustomersOnlybooleanYestrue: use the merchant's newCustomer answer, or recorded purchases when omitted. false: returning customers qualify too. A supplied answer uses the order limit after the referral.
incentive.expiresAfterDaysunionYesDays after the referral was captured, claimed or entered. null means it never expires.
incentive.returnOnFullRefundbooleanYestrue: a full refund gives the use back, so the customer can get the offer again.
incentive.maxDiscountCentsnumberNoLargest discount for one order.
incentive.minOrderCentsnumberNoThe friend's order total before the discount must reach this amount. Checked by the merchant's checkout.
incentive.orderCategoriesobjectNoOrder categories that get the discount. Checked apart from the program's own orderCategories, which decide rewards. Absent means every order qualifies.
incentive.currencyunionYes

incentive.expiresAfterDays

Variant 1

Type: null.

Variant 2

Type: number.

incentive.orderCategories

FieldTypeRequiredDetails
incentive.orderCategories.includearrayNo
incentive.orderCategories.excludearrayNo

incentive.currency

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

Variant 4

Type: string.

Variant 3

FieldTypeRequiredDetails
incentive.type"fixed"Yes
incentive.ordersnumberYesHow many of the friend's orders get the incentive.
incentive.newCustomersOnlybooleanYestrue: use the merchant's newCustomer answer, or recorded purchases when omitted. false: returning customers qualify too. A supplied answer uses the order limit after the referral.
incentive.expiresAfterDaysunionYesDays after the referral was captured, claimed or entered. null means it never expires.
incentive.returnOnFullRefundbooleanYestrue: a full refund gives the use back, so the customer can get the offer again.
incentive.amountCentsnumberYes
incentive.minOrderCentsnumberNoThe friend's order total before the discount must reach this amount. Checked by the merchant's checkout.
incentive.orderCategoriesobjectNoOrder categories that get the discount. Checked apart from the program's own orderCategories, which decide rewards. Absent means every order qualifies.
incentive.currencyunionYes

incentive.expiresAfterDays

Variant 1

Type: null.

Variant 2

Type: number.

incentive.orderCategories

FieldTypeRequiredDetails
incentive.orderCategories.includearrayNo
incentive.orderCategories.excludearrayNo

incentive.currency

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

Variant 4

Type: string.

display

Variant 1

Type: null.

Variant 2

FieldTypeRequiredDetails
display.publicNameobjectYes
display.headlineobjectYes
display.milestoneLabelunionYesNull for order programs. Forms by plural category, picked with Intl.PluralRules. few and many matter in Russian. A merchant's label sets one and other, and few and many reuse other.

display.publicName

FieldTypeRequiredDetails
display.publicName.enstringYes
display.publicName.fr-CAstringYes
display.publicName.hystringYes
display.publicName.rustringYes

display.headline

FieldTypeRequiredDetails
display.headline.enstringYes
display.headline.fr-CAstringYes
display.headline.hystringYes
display.headline.rustringYes

display.milestoneLabel

Variant 1

Type: null.

Variant 2

FieldTypeRequiredDetails
display.milestoneLabel.oneobjectYes
display.milestoneLabel.fewobjectYes
display.milestoneLabel.manyobjectYes
display.milestoneLabel.otherobjectYes

display.milestoneLabel.one

FieldTypeRequiredDetails
display.milestoneLabel.one.enstringYes
display.milestoneLabel.one.fr-CAstringYes
display.milestoneLabel.one.hystringYes
display.milestoneLabel.one.rustringYes

display.milestoneLabel.few

FieldTypeRequiredDetails
display.milestoneLabel.few.enstringYes
display.milestoneLabel.few.fr-CAstringYes
display.milestoneLabel.few.hystringYes
display.milestoneLabel.few.rustringYes

display.milestoneLabel.many

FieldTypeRequiredDetails
display.milestoneLabel.many.enstringYes
display.milestoneLabel.many.fr-CAstringYes
display.milestoneLabel.many.hystringYes
display.milestoneLabel.many.rustringYes

display.milestoneLabel.other

FieldTypeRequiredDetails
display.milestoneLabel.other.enstringYes
display.milestoneLabel.other.fr-CAstringYes
display.milestoneLabel.other.hystringYes
display.milestoneLabel.other.rustringYes

attribution

FieldTypeRequiredDetails
attribution.idstringYes
attribution.companyIdstringYes
attribution.partnerIdstringYes
attribution.qualifiedAtstringNo
attribution.qualifiedOrderNumbernumberNo
attribution.programIdstringYes
attribution.referralCodestringYes
attribution.customerIdstringYes
attribution.occurredAtstringYes
attribution.channelunionYes
attribution.providerPromoCodeIdstringNo
attribution.customerDisplayNamestringNo
attribution.orderIdstringNo

attribution.channel

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

Variant 4

Type: string.

selfReferral

FieldTypeRequiredDetails
selfReferral.actionunionYes
selfReferral.signalsarrayYes

selfReferral.action

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

selfReferral.signals[]

Variant 1

Type: string.

Variant 2

Type: string.

Variant 3

Type: string.

Variant 4

Type: string.

Variant 5

Type: string.

Variant 6

Type: string.

Response schema

json
{
  "type": "object",
  "properties": {
    "receipt": {
      "type": "string"
    },
    "programId": {
      "type": "string"
    },
    "placements": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "partnerId": {
      "type": "string"
    },
    "partnerExternalId": {
      "type": "string"
    },
    "expiresAt": {
      "type": "string"
    },
    "duration": {
      "anyOf": [
        {
          "type": "string",
          "const": "only_order"
        },
        {
          "type": "string",
          "const": "first_order"
        },
        {
          "type": "string",
          "const": "first_n_orders"
        },
        {
          "type": "string",
          "const": "days"
        },
        {
          "type": "string",
          "const": "months"
        },
        {
          "type": "string",
          "const": "lifetime"
        }
      ]
    },
    "incentive": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "percent"
            },
            "rateBps": {
              "type": "number"
            },
            "orders": {
              "type": "number",
              "description": "How many of the friend's orders get the incentive."
            },
            "newCustomersOnly": {
              "type": "boolean",
              "description": "true: use the merchant's newCustomer answer, or recorded purchases when omitted. false:\nreturning customers qualify too. A supplied answer uses the order limit after the referral."
            },
            "expiresAfterDays": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "number"
                }
              ],
              "description": "Days after the referral was captured, claimed or entered. null means it never expires."
            },
            "returnOnFullRefund": {
              "type": "boolean",
              "description": "true: a full refund gives the use back, so the customer can get the offer again."
            },
            "maxDiscountCents": {
              "type": "number",
              "description": "Largest discount for one order."
            },
            "minOrderCents": {
              "type": "number",
              "description": "The friend's order total before the discount must reach this amount. Checked by the merchant's checkout."
            },
            "orderCategories": {
              "type": "object",
              "properties": {
                "include": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "exclude": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "description": "Order categories that get the discount. Checked apart from the program's own orderCategories,\nwhich decide rewards. Absent means every order qualifies."
            },
            "currency": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "CAD"
                },
                {
                  "type": "string",
                  "const": "USD"
                },
                {
                  "type": "string",
                  "const": "EUR"
                },
                {
                  "type": "string",
                  "const": "GBP"
                }
              ]
            }
          },
          "required": [
            "type",
            "rateBps",
            "orders",
            "newCustomersOnly",
            "expiresAfterDays",
            "returnOnFullRefund",
            "currency"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "fixed"
            },
            "orders": {
              "type": "number",
              "description": "How many of the friend's orders get the incentive."
            },
            "newCustomersOnly": {
              "type": "boolean",
              "description": "true: use the merchant's newCustomer answer, or recorded purchases when omitted. false:\nreturning customers qualify too. A supplied answer uses the order limit after the referral."
            },
            "expiresAfterDays": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "number"
                }
              ],
              "description": "Days after the referral was captured, claimed or entered. null means it never expires."
            },
            "returnOnFullRefund": {
              "type": "boolean",
              "description": "true: a full refund gives the use back, so the customer can get the offer again."
            },
            "amountCents": {
              "type": "number"
            },
            "minOrderCents": {
              "type": "number",
              "description": "The friend's order total before the discount must reach this amount. Checked by the merchant's checkout."
            },
            "orderCategories": {
              "type": "object",
              "properties": {
                "include": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "exclude": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "description": "Order categories that get the discount. Checked apart from the program's own orderCategories,\nwhich decide rewards. Absent means every order qualifies."
            },
            "currency": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "CAD"
                },
                {
                  "type": "string",
                  "const": "USD"
                },
                {
                  "type": "string",
                  "const": "EUR"
                },
                {
                  "type": "string",
                  "const": "GBP"
                }
              ]
            }
          },
          "required": [
            "type",
            "orders",
            "newCustomersOnly",
            "expiresAfterDays",
            "returnOnFullRefund",
            "amountCents",
            "currency"
          ]
        }
      ],
      "description": "The program's current friend incentive, or null when it has none. Says nothing about eligibility."
    },
    "display": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "publicName": {
              "type": "object",
              "properties": {
                "en": {
                  "type": "string"
                },
                "fr-CA": {
                  "type": "string"
                },
                "hy": {
                  "type": "string"
                },
                "ru": {
                  "type": "string"
                }
              },
              "required": [
                "en",
                "fr-CA",
                "hy",
                "ru"
              ]
            },
            "headline": {
              "type": "object",
              "properties": {
                "en": {
                  "type": "string"
                },
                "fr-CA": {
                  "type": "string"
                },
                "hy": {
                  "type": "string"
                },
                "ru": {
                  "type": "string"
                }
              },
              "required": [
                "en",
                "fr-CA",
                "hy",
                "ru"
              ]
            },
            "milestoneLabel": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "properties": {
                    "one": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string"
                        },
                        "fr-CA": {
                          "type": "string"
                        },
                        "hy": {
                          "type": "string"
                        },
                        "ru": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "en",
                        "fr-CA",
                        "hy",
                        "ru"
                      ]
                    },
                    "few": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string"
                        },
                        "fr-CA": {
                          "type": "string"
                        },
                        "hy": {
                          "type": "string"
                        },
                        "ru": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "en",
                        "fr-CA",
                        "hy",
                        "ru"
                      ]
                    },
                    "many": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string"
                        },
                        "fr-CA": {
                          "type": "string"
                        },
                        "hy": {
                          "type": "string"
                        },
                        "ru": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "en",
                        "fr-CA",
                        "hy",
                        "ru"
                      ]
                    },
                    "other": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string"
                        },
                        "fr-CA": {
                          "type": "string"
                        },
                        "hy": {
                          "type": "string"
                        },
                        "ru": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "en",
                        "fr-CA",
                        "hy",
                        "ru"
                      ]
                    }
                  },
                  "required": [
                    "one",
                    "few",
                    "many",
                    "other"
                  ]
                }
              ],
              "description": "Null for order programs. Forms by plural category, picked with Intl.PluralRules. few and\nmany matter in Russian. A merchant's label sets one and other, and few and many reuse other."
            }
          },
          "required": [
            "publicName",
            "headline",
            "milestoneLabel"
          ]
        }
      ],
      "description": "The program's public name, headline and milestone label. Null when the program is gone."
    },
    "attribution": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "companyId": {
          "type": "string"
        },
        "partnerId": {
          "type": "string"
        },
        "qualifiedAt": {
          "type": "string"
        },
        "qualifiedOrderNumber": {
          "type": "number"
        },
        "programId": {
          "type": "string"
        },
        "referralCode": {
          "type": "string"
        },
        "customerId": {
          "type": "string"
        },
        "occurredAt": {
          "type": "string"
        },
        "channel": {
          "anyOf": [
            {
              "type": "string",
              "const": "link"
            },
            {
              "type": "string",
              "const": "qr"
            },
            {
              "type": "string",
              "const": "coupon"
            },
            {
              "type": "string",
              "const": "in_app"
            }
          ]
        },
        "providerPromoCodeId": {
          "type": "string"
        },
        "customerDisplayName": {
          "type": "string"
        },
        "orderId": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "companyId",
        "partnerId",
        "programId",
        "referralCode",
        "customerId",
        "occurredAt",
        "channel"
      ],
      "description": "Present for customer programs. It may retain a previously qualified partner."
    },
    "selfReferral": {
      "type": "object",
      "properties": {
        "action": {
          "anyOf": [
            {
              "type": "string",
              "const": "blocked"
            },
            {
              "type": "string",
              "const": "review"
            },
            {
              "type": "string",
              "const": "flagged"
            }
          ]
        },
        "signals": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "const": "email"
              },
              {
                "type": "string",
                "const": "phone"
              },
              {
                "type": "string",
                "const": "card"
              },
              {
                "type": "string",
                "const": "device"
              },
              {
                "type": "string",
                "const": "ip"
              },
              {
                "type": "string",
                "const": "customer_id"
              }
            ]
          }
        }
      },
      "required": [
        "action",
        "signals"
      ],
      "description": "Present when customer links or identity signals match the partner: review or flagged. A blocked match throws self_referral."
    }
  },
  "required": [
    "receipt",
    "programId",
    "placements",
    "partnerId",
    "partnerExternalId",
    "expiresAt",
    "duration",
    "incentive",
    "display"
  ]
}

Errors

Failures return { "error": { "code": "...", "message": "...", "details": {} } }. Details are optional. See error statuses. Reuse an unchanged event payload when retrying.