# Coupons

## All Coupons

<mark style="color:blue;">`GET`</mark> `https://yoursite.mavenseed.com/api/v1/coupons`

Retrieve all coupons.

#### Path Parameters

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| page | integer | Results are paginated. |

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

{% tabs %}
{% tab title="200 Returns an array of members. Only the first 20 are returned. Passing the page param will paginate the results.
" %}

```javascript
[
    {
        "id": 33,
        "internal_coupon_id": "englishtea",
        "coupon_type": "coupon",
        "currency": "USD",
        "duration": "once",
        "duration_in_months": null,
        "max_redemptions": null,
        "amount_off": 6000,
        "percent_off": null,
        "redeem_by": null,
        "eligible_types": [
            "orders"
        ],
        "created_at": "2020-05-14T13:47:54.567-04:00",
        "updated_at": "2020-09-08T12:28:49.246-04:00",
        "supported_countries": [],
        "metadata": "{}",
        "coupons_orders_count": 0
    },
    {
        "id": 14,
        "internal_coupon_id": "blueberrymuffin",
        "coupon_type": "coupon",
        "currency": "USD",
        "duration": "once",
        "duration_in_months": null,
        "max_redemptions": null,
        "amount_off": 6000,
        "percent_off": null,
        "redeem_by": null,
        "eligible_types": [
            "orders"
        ],
        "created_at": "2020-04-09T11:54:36.083-04:00",
        "updated_at": "2020-08-03T13:03:11.995-04:00",
        "supported_countries": [
            "IN"
        ],
        "metadata": "{}",
        "coupons_orders_count": 4
    }
]
```

{% endtab %}
{% endtabs %}

## Show Coupon

<mark style="color:blue;">`GET`</mark> `https://yoursite.mavenseed.com/api/v1/coupons/:id`

Retrieve a single coupon.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

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

```javascript
{
    "id": 33,
    "internal_coupon_id": "englishtea",
    "coupon_type": "coupon",
    "currency": "USD",
    "duration": "once",
    "duration_in_months": null,
    "max_redemptions": null,
    "amount_off": 6000,
    "percent_off": null,
    "redeem_by": null,
    "eligible_types": [
        "orders"
    ],
    "created_at": "2020-05-14T13:47:54.567-04:00",
    "updated_at": "2020-09-08T12:28:49.246-04:00",
    "supported_countries": [],
    "metadata": "{}",
    "coupons_orders_count": 0
}
```

{% endtab %}

{% tab title="404 " %}

```ruby
null
```

{% endtab %}
{% endtabs %}

## Create Coupon

<mark style="color:green;">`POST`</mark> `https://yoursite.mavenseed.com/api/v1/coupons`

Create a coupon.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth Token  |

#### Request Body

| Name                 | Type    | Description                                                           |
| -------------------- | ------- | --------------------------------------------------------------------- |
| internal\_coupon\_id | string  | The actual coupon code itself.                                        |
| coupon\_type         | string  | `coupon` or `gift_card`                                               |
| currency             | string  | Currently only supporting `USD`                                       |
| duration             | string  | `once`, `repeating`, or `forever`                                     |
| duration\_in\_moths  | integer | **Required** only if duration is `repeating`                          |
| max\_redemptions     | integer | Max times coupon can be claimed                                       |
| amount\_off          | integer | Amount in cents , required if percent off is blank.                   |
| percent\_off         | integer | Percent off as an integer, required only if amount off is blank.      |
| redeem\_by           | object  | When the coupon should expire in datetime format.                     |
| eligible\_types      | array   | Can include `orders` and/or `subscriptions`                           |
| supported\_countries | array   | Array of 2 letter iso codes that the coupon can only be claimed from. |

{% tabs %}
{% tab title="201 " %}

```
{
    "id": 33,
    "internal_coupon_id": "englishtea",
    "coupon_type": "coupon",
    "currency": "USD",
    "duration": "once",
    "duration_in_months": null,
    "max_redemptions": null,
    "amount_off": 6000,
    "percent_off": null,
    "redeem_by": null,
    "eligible_types": [
        "orders"
    ],
    "created_at": "2020-05-14T13:47:54.567-04:00",
    "updated_at": "2020-09-08T12:28:49.246-04:00",
    "supported_countries": [],
    "metadata": "{}",
    "coupons_orders_count": 0
}
```

{% endtab %}
{% endtabs %}

## Update Coupon

<mark style="color:purple;">`PATCH`</mark> `https://yoursite.mavenseed.com/api/v1/coupons/:id`

Update a single coupon. All of the above properties in create coupon are valid.

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | Auth token  |

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

```ruby
{
    "id": 33,
    "internal_coupon_id": "englishtea",
    "coupon_type": "coupon",
    "currency": "USD",
    "duration": "once",
    "duration_in_months": null,
    "max_redemptions": null,
    "amount_off": 6000,
    "percent_off": null,
    "redeem_by": null,
    "eligible_types": [
        "orders"
    ],
    "created_at": "2020-05-14T13:47:54.567-04:00",
    "updated_at": "2020-09-08T12:28:49.246-04:00",
    "supported_countries": [],
    "metadata": "{}",
    "coupons_orders_count": 0
}
```

{% endtab %}
{% endtabs %}

## Delete Coupon

<mark style="color:red;">`DELETE`</mark> `https://yoursite.mavenseed.com/api/v1/coupons/:id`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

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

```
```

{% 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://docs.mavenseed.com/developers/api/coupons.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.
