---
search:
  tags:
    - Coupons
    - POST
seo:
  description: >-
    Admin or branch manager only. Registers a coupon the register can apply at
    checkout.… Reference for the POST /api/v1/coupons endpoint in the PharmaFlow
    API.
sidebar:
  label: Create a coupon
  badge: POST
title: Create a coupon
type: openapi-operation
---
Admin or branch manager only. Registers a coupon the register can apply at checkout. Codes are uppercased; duplicates 409, and a percentage over 100 or non-positive value 400.

`POST /api/v1/coupons`

**Request body** (`application/json`, required)

- `code` (string, required)
- `type` (string)
- `discount_type` (string, required)
- `discount_value` (number, required)
- `description` (string)
- `valid_from` (string | null)
- `valid_until` (string | null)
- `max_uses` (integer | null)

Request body example:

```json
{
  "code": "string",
  "type": "promotional",
  "discount_type": "string",
  "discount_value": 0,
  "description": "",
  "valid_from": "string",
  "valid_until": "string",
  "max_uses": -9007199254740991
}
```

**Responses**

- `201` — Coupon registered
- `400` — The code is empty, discount\_type is neither percentage nor fixed, the value is not positive, or a percentage is above 100
- `401` — Not authenticated
- `403` — Caller is not an admin or branch manager
- `409` — A coupon with that code already exists

Response example, 201:

```json
{
  "id": "string",
  "code": "string",
  "type": "string",
  "discount_type": "string",
  "discount_value": 0,
  "is_active": true,
  "usage_count": -9007199254740991
}
```
