# Deal Codes

Deal codes allow Stampede users to uniquely send a code for each marketing email that gets sent out from Stampede. Customers can send a birthday campaign from Stampede which includes a 10%\_OFF deal within this deal, a code will be sent within each email to prevent customers from using the same code multiple times. An example of how the deal structure works below:

```
10%_OFF:
    ABC1
    ABC2
    ABC3

BOGOF:
    DEF1
    DEF2
    DEF3
    
2FOR1: 
    GHI1
    GHI2
    GHI3
```

## Get a paginated response of all deals

<mark style="color:blue;">`GET`</mark> `/v1/deal`

{% tabs %}
{% tab title="200: OK " %}

```typescript
{
    data: {
        id: string;
        active: boolean;
        name: string;
        description: string | null;
        expires_at: string | null;
        created_at: string;
        updated_at: string;
        cash_value_amount: number | null;
        cash_value_currency: string | null;
        days_code_valid_for: number | null;
        voucher_codes_count: number;
    }[];
    links: {
        first: string;
        last: string;
        prev: string | null;
        next: string | null;
    };
    meta: {
        current_page: number;
        from: number;
        last_page: number;
        links: {
            url: string | null;
            label: string;
            active: boolean;
        }[];
        path: string;
        per_page: number;
        to: number;
        total: number;
    };
}
```

{% endtab %}
{% endtabs %}

## Create a new deal

<mark style="color:green;">`POST`</mark> `/v1/deal`

#### Request Body

| Name                                   | Type     | Description                                            |
| -------------------------------------- | -------- | ------------------------------------------------------ |
| name<mark style="color:red;">\*</mark> | String   | The name of the voucher                                |
| cash\_value\_amount                    | Number   | Cash value amount in pennies                           |
| expires\_at                            | ISO 8601 | The expiry date of the voucher                         |
| active                                 | Boolean  | If the voucher is active or inactive                   |
| description                            | String   | The description of the voucher                         |
| days\_code\_valid\_for                 | Number   | How long is this code valid for from date of issue     |
| cash\_value\_currency                  | ISO 4217 | The currency code of the cash value (for example, GBP) |

{% tabs %}
{% tab title="200: OK " %}

```typescript
{
    message: string;
    voucher: {
        id: string;
        active: boolean;
        name: string | null;
        description: string;
        expires_at: string | null;
        created_at: string;
        updated_at: string;
        cash_value_amount: number | null;
        cash_value_currency: string | null;
        days_code_valid_for: number | null;
        voucher_codes_count: number | null;
    };
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity " %}

```typescript
{
    message: string;
    errors: {
        name: string[];
    };
}
```

{% endtab %}
{% endtabs %}

## Search for a code

<mark style="color:blue;">`GET`</mark> `/v1/code/search`

#### Query Parameters

| Name                                   | Type   | Description                       |
| -------------------------------------- | ------ | --------------------------------- |
| code<mark style="color:red;">\*</mark> | String | The code you're looking to search |

{% tabs %}
{% tab title="200: OK " %}

```typescript
{
    data: {
        id: string;
        voucher_id?: string;
        voucher?: {
            id: string;
            active: boolean;
            name: string;
            description: string;
            expires_at: string | null;
            created_at: string;
            updated_at: string;
            cash_value_amount: number | null;
            cash_value_currency: string | null;
            days_code_valid_for: number | null;
            voucher_codes_count: number;
        };
        code?: string;
        sent_to_profile_id?: number;
        redeemed_by_profile_id?: number | null;
        redeemed_by_user_id?: number | null;
        redeemed_at?: string | null;
        is_redeemed?: boolean;
        revoked_at?: string | null;
        is_revoked?: boolean;
        is_revokable?: boolean;
        expires_at?: string | null;
        created_at?: string;
        updated_at?: string;
        sent_to_profile_data?: any;
    }[];
    links: {
        first: string;
        last: string;
        prev: string | null;
        next: string | null;
    };
    meta: {
        current_page: number;
        from: number | null;
        last_page: number;
        links: {
            url: string | null;
            label: string;
            active: boolean;
        }[];
        path: string;
        per_page: number;
        to: number | null;
        total: number;
    };
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity " %}

```typescript
{
    message: string;
    errors: {
        name: string[];
    };
}
```

{% endtab %}
{% endtabs %}

## Revoke a code

<mark style="color:green;">`POST`</mark> `/v1/code/revoke`

#### Query Parameters

| Name | Type   | Description                               |
| ---- | ------ | ----------------------------------------- |
| code | String | The voucher code you're looking to revoke |

{% tabs %}
{% tab title="200: OK " %}

```typescript
{
    message: string;
    voucher_code: {
        id: string;
        voucher_id: string;
        code: string;
        sent_to_profile_id: string | null;
        redeemed_by_profile_id: string | null;
        redeemed_by_user_id: string | null;
        redeemed_at: string | null;
        is_redeemed: boolean;
        revoked_at: string;
        is_revoked: boolean;
        is_revokable: boolean;
        expires_at: string | null;
        created_at: string;
        updated_at: string;
    };
}
```

{% endtab %}

{% tab title="422: Unprocessable Entity " %}

```typescript
{
    message: string;
    errors: {
        name: string[];
    };
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.stampede.ai/marketing/deal-codes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
