> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cabrapi.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Coupon

> Learn how to update coupons using the endpoint PUT /stores/{storeId}/coupons/{couponId}.

## 📌 Endpoint

`PUT /stores/{storeId}/coupons/{couponId}`

Partially updates an existing coupon.

***

## 🔐 Authentication

* **Private route**.
* Requires header `Authorization` with your API key and active plan.

```json theme={null}
{
	"Authorization": "YOUR_API_KEY_HERE"
}
```

***

## 🧾 Route parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `storeId` | string | Yes | Store ID |
| `couponId` | string | Yes | Coupon ID |

***

## 🧍 Body (JSON)

Send at least one field:

* `code` (3-32)
* `discount` (1-100)
* `position` (integer greater than or equal to 1)
* `useLimit` (integer -1 to 9999; sending `null` resets to `-1`)
* `rules` (array of usage rules, e.g. `[{"type": "SINGLE_USE_PER_CUSTOMER"}]`; sending `null` or `[]` clears rules)
* `expiredAt` (future date in `RFC3339` / `date-time` format, or `null`)
* `productIds` (array of IDs; sending `null` clears associations)
* `categoryIds` (array of IDs; sending `null` clears associations)

***

## ✅ Example request

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/STORE_ID/coupons/COUPON_ID" \
	-H "Authorization: YOUR_API_KEY_HERE" \
	-H "Content-Type: application/json" \
	-d '{
		"discount": 15,
		"useLimit": 200
	}'
```

***

## Standard snippet (cURL)

Use the cURL example from the Request example section above as the official snippet.

***

## 📦 Success response (200)

```json theme={null}
{
	"code": "COUPON_UPDATED",
	"coupon": {
		"id": "COUPON_ID",
		"code": "bemvindo10",
		"discount": 15,
		"position": 2,
		"useLimit": 200,
		"rules": [],
		"expiredAt": null,
		"storeId": "STORE_ID",
		"createdAt": "2026-09-08T19:30:00Z",
		"updatedAt": "2026-09-08T19:30:00Z",
		"products": [],
		"categories": []
	}
}
```

***

## ⚠️ Possible errors

* `400 INVALID_DATA` → invalid body
* `400 INVALID_DATA_CODE` → `code` outside 3 to 32 characters
* `400 INVALID_DATA_DISCOUNT` → `discount` outside 1 to 100
* `400 INVALID_DATA_POSITION` → `position` less than 1
* `400 INVALID_DATA_USE_LIMIT` → `useLimit` outside -1 to 9999
* `400 INVALID_DATA_RULES` → invalid or malformed `rules`
* `400 INVALID_DATA_EXPIRED_AT` → invalid `expiredAt` or not in the future
* `400 RELATION_NOT_FOUND` → invalid product/category
* `401 API_KEY_NOT_PROVIDED` → `Authorization` header not provided
* `401 INVALID_API_KEY` → invalid API key
* `401 UNAUTHENTICATED` → unauthenticated user
* `403 USER_DISABLED` → user disabled
* `403 NO_ACTIVE_SUBSCRIPTION` → no active plan
* `404 STORE_NOT_FOUND` → store not found
* `404 COUPON_NOT_FOUND` → coupon not found
* `409 COUPON_ALREADY_EXISTS` → duplicated code
* `429 RATE_LIMIT_EXCEEDED` → per-minute rate limit exceeded
* `500 INTERNAL_SERVER_ERROR` → internal error
* `503 SERVICE_UNAVAILABLE` → service unavailable


## OpenAPI

````yaml PUT /stores/{storeId}/coupons/{couponId}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/coupons/{couponId}:
    put:
      tags:
        - Coupons
      summary: Update coupon
      operationId: updateCoupon
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - $ref: '#/components/parameters/CouponId'
      requestBody:
        required: true
        description: Coupon fields to update.
        content:
          application/json:
            schema:
              type: object
              properties:
                code:
                  type: string
                  minLength: 3
                  maxLength: 32
                discount:
                  type: integer
                  minimum: 1
                  maximum: 100
                position:
                  minimum: 1
                  type: integer
                useLimit:
                  type: integer
                  minimum: -1
                  maximum: 9999
                  nullable: true
                rules:
                  type: array
                  nullable: true
                  maxItems: 32
                  items:
                    properties:
                      type:
                        enum:
                          - SINGLE_USE_PER_CUSTOMER
                          - MIN_ORDER_AMOUNT
                          - AFFILIATE_ONLY
                          - MIN_ITEMS_QUANTITY
                          - PAYMENT_METHOD
                        type: string
                      value: {}
                    required:
                      - type
                    type: object
                expiredAt:
                  format: date-time
                  nullable: true
                  type: string
                productIds:
                  type: array
                  items:
                    type: string
                    minLength: 1
                    maxLength: 50
                  nullable: true
                categoryIds:
                  type: array
                  items:
                    type: string
                    minLength: 1
                    maxLength: 50
                  nullable: true
              minProperties: 1
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: COUPON_UPDATED
                    type: string
                  coupon:
                    $ref: '#/components/schemas/Coupon'
                required:
                  - code
                  - coupon
                type: object
          description: Update coupon.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid API key.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource already exists.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
    CouponId:
      in: path
      name: couponId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Coupon:
      description: Store discount coupon.
      properties:
        categories:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        code:
          type: string
        createdAt:
          format: date-time
          type: string
        discount:
          type: integer
        expiredAt:
          format: date-time
          nullable: true
          type: string
        id:
          format: uuid
          type: string
        position:
          type: integer
        products:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        rules:
          items:
            properties:
              type:
                enum:
                  - SINGLE_USE_PER_CUSTOMER
                  - MIN_ORDER_AMOUNT
                  - AFFILIATE_ONLY
                  - MIN_ITEMS_QUANTITY
                  - PAYMENT_METHOD
                type: string
              value: {}
            required:
              - type
            type: object
          nullable: false
          type: array
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
        useLimit:
          type: integer
      required:
        - id
        - code
        - discount
        - position
        - useLimit
        - storeId
        - createdAt
        - updatedAt
        - products
        - categories
        - rules
        - expiredAt
      type: object
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
  securitySchemes:
    ApiKey:
      in: header
      name: Authorization
      type: apiKey
      x-default: YOUR_API_KEY_HERE

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.