---
title: Coupon Model
description: Coupon represents a code that can be redeemed for a discount.
---

## Properties
:field-schema{schema="/types/coupon/coupon.type"}


## Code Example
::code-group
```typescript [Typescript (SDK)]
import { Integrator } from '@churnkey/sdk'

export class Coupon extends Integrator.Coupon {
    constructor(coupon: YourCoupon) {
        super({
            id: coupon.id,
            ... // map other properties
        })
    }
}
```
```typescript [Typescript]
interface Coupon {
    id: string
    duration: Duration
    value: Value
    name?: string
    code?: string
    redemptions?: Redemptions
    expiresAt?: Date
}

export function Coupon(coupon: YourCoupon): Coupon {
    return {
        id: coupon.id,
        ... // map other properties
    }
}

export type Duration = Duration.Once | Duration.Recurring | Duration.Forever | Duration.CycleAmount

namespace Duration {
    export enum Type {
        Once = "once",
        Recurring = "recurring"
        Forever = "forever"
        CycleAmount = "cycle-amount"
    }

    interface Base {
        type: Type
    }

    export interface Once extends Base {
        type: Type.Once
    }

    export interface Recurring extends Base {
        type: Type.Recurring
        amount: number
        unit: Duration.Unit
    }

    export interface Forever extends Base {
        type: Type.Forever
    }

    export interface CycleAmount extends Base {
        type: Type.CycleAmount
        cycles: number
    }

    export enum Unit {
        Month = "month",
        Year = "year"
    }
}


export type Value = Value.Fixed | Value.Percentage

export namespace Value {
    export enum Type {
        Fixed = "fixed",
        Percentage = "percentage"
    }

    interface Base {
        type: Type
    }

    export interface Fixed extends Base {
        type: Type.Fixed
        currency: string
        unit?: number
        flat?: number
    }

    export interface Percentage extends Base {
        type: Type.Percentage
        percent: number
        currency?: string
    }
}

export interface Redemptions {
    max?: number
    current?: number
}
```
::