---
title: "Edit unused discount code terms (site admin)"
method: PATCH
path: "/discount-codes/{code}"
tags: ["Discount codes"]
---

# Edit unused discount code terms (site admin)

`PATCH /discount-codes/{code}`

## Request

- Base URL: `https://app.pencil.ink/api/v1`
- URL: `https://app.pencil.ink/api/v1/discount-codes/{code}`
- Auth: HTTP bearer

Requires a write discount-management key and current site-admin creator. Updates supplied fields only. Set duration=repeating and months=12 for twelve months. redeemBy=null clears the deadline. Code and recipient cannot change. Any redemption history locks terms; no Stripe changes are made. Identical updates are no-ops.

## Request body

- object
  - `label` string
  - `percentOff` integer
  - `duration` 'once' | 'repeating' | 'forever'
  - `months` integer: Required for repeating duration.
  - `planKey` 'pro' | 'team': USD monthly base subscription only; excludes AI usage.
  - `maxRedemptions` integer, nullable: Maximum distinct organization redemptions. Null means unlimited. Defaults to 1 and must be 1 for recipient-targeted codes.
  - `redeemFrom` number, nullable: Optional redemption start, Unix milliseconds.
  - `redeemBy` number, nullable: Optional future redemption deadline, Unix milliseconds.

## Response `200`

The resource.

- object
  - `data` DiscountCode
    - `code` string: Unique code, 6–64 letters, digits, dashes or underscores; normalized to uppercase.
    - `label` string
    - `percentOff` integer
    - `duration` 'once' | 'repeating' | 'forever'
    - `months` integer: Required for repeating duration.
    - `planKey` 'pro' | 'team': USD monthly base subscription only; excludes AI usage.
    - `targetOrgId` string: Optional recipient organization. Recipient-targeted codes are single-use.
    - `targetUserId` string: Optional recipient user; mutually exclusive with targetOrgId.
    - `maxRedemptions` integer, nullable: Maximum distinct organization redemptions. Null means unlimited. Defaults to 1 and must be 1 for recipient-targeted codes.
    - `redeemFrom` number: Optional redemption start, Unix milliseconds.
    - `redeemBy` number: Optional future redemption deadline, Unix milliseconds.
    - `_id` string
    - `_creationTime` number
    - `active` boolean
    - `createdBy` string
    - `createdAt` number

## Other responses

- `400`: Malformed request or invalid field (`validation_error`).
- `401`: Missing or invalid API key (`unauthorized`).
- `403`: The key is read-only and may not write (`forbidden`).
- `404`: Resource not found in this org (`not_found`).
- `409`: Terms are locked because redemption has started.
- `429`: Rate limit exceeded (`rate_limited`).

---

[API](https://skmtc.dev/pencil/apis/pencil-public-api.md) · [All operations](https://skmtc.dev/pencil/apis/pencil-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pencil/apis/pencil-public-api/revisions/2b842698b76d?raw)
