Catalog

Change a discount code

PATCH
/api/v1/discount-codes/{id}

Changes the listed fields of a code (never the code itself). An absent key stays as it is; an explicit null clears value, the dates or the limits. Changing type without a value clears the value, and the usual rules then say what is missing. Live at once. Requires the catalog:write scope, the PRO plan and an Idempotency-Key header.

Authorization

ApiKeyAuth catalog:write
headerAuthorizationBearer <shyni_sk_live_*>

An API key, issued once and never retrievable again: an organization key in the developer portal, or a studio key in the studio's admin (Moje studio → API). Send as Authorization: Bearer shyni_sk_live_....

Scope: catalog:write

Path Parameters

id*string

Header Parameters

Idempotency-Key*string

Caller-chosen idempotency token for this write. A retry under the SAME key with the SAME body replays the first response; the SAME key with a DIFFERENT body is 422 IDEMPOTENCY_KEY_MISMATCH. See Idempotency above.

Lengthlength <= 64

Request Body

application/json
  1. body

An absent key stays as it is; an explicit null clears value, the dates or the limits.

type?string
Value in"PERCENT""FIXED""DEPOSIT_EXEMPT"
value?|
Formatint64
validFrom?|
Formatdate
validUntil?|
Formatdate
maxUses?integer|null
maxUsesPerCustomer?integer|null

Response Body

The changed discount code.

application/json
  1. response
id*string
code*string
type*string
Value in"PERCENT""FIXED""DEPOSIT_EXEMPT"
value*|

Whole percent (PERCENT), minor units of the studio currency (FIXED) or null.

Formatint64
validFrom*|
Formatdate
validUntil*|
Formatdate
maxUses*integer|null
maxUsesPerCustomer*integer|null
active*boolean
usedCount*integer

Non-cancelled orders that used the code.

createdAt*string
Formatdate-time
Example Request
curl -X PATCH 'https://api.shyni.io/api/v1/discount-codes/string' \  -H 'Authorization: Bearer shyni_sk_test_YOUR_KEY' \  -H 'Idempotency-Key: 7f3c9a52-1d4e-4b86-a0c7-5e2b9d8f6a13' \  -H 'Content-Type: application/json' \  -d '{}'

Response 200

The changed discount code.

{  "id": "string",  "code": "string",  "type": "PERCENT",  "value": 0,  "validFrom": "2019-08-24",  "validUntil": "2019-08-24",  "maxUses": 0,  "maxUsesPerCustomer": 0,  "active": true,  "usedCount": 0,  "createdAt": "2019-08-24T14:15:22Z"}

Response 400

A parameter, header or request body is missing, malformed, or out of range. A request body property the endpoint does not define answers UNKNOWN_FIELD instead, with field naming it.

{  "code": "INVALID_INPUT",  "message": "Parameter perPage must be between 1 and 100."}

Response 401

Missing, malformed, unknown, or revoked API key (INVALID_API_KEY).

{  "code": "INVALID_API_KEY",  "message": "Missing or invalid API key."}

Response 403

The key is valid but the request is refused. Branch on code: INSUFFICIENT_SCOPE (the key lacks the permission this endpoint requires), PLAN_REQUIRED (the studio is not on a plan that includes API keys, Pro and above), ORIGIN_NOT_ALLOWED, SECRET_KEY_IN_BROWSER, or DEMO_STUDIO on a write to the demo studio. See Authentication and Scopes above.

{  "code": "INSUFFICIENT_SCOPE",  "message": "This API key does not have the permission this endpoint requires."}

Response 404

The resource does not exist, or belongs to a different studio.

{  "code": "NOT_FOUND",  "message": "Order not found."}

Response 422

The same Idempotency-Key was already used for a request with a different body, use a new key (see Idempotency above).

{  "code": "IDEMPOTENCY_KEY_MISMATCH",  "message": "This Idempotency-Key was already used for a different request. Use a new key."}

Response 429

Burst rate limit exceeded.

{  "code": "RATE_LIMITED",  "message": "Too many requests. Retry after the time given in the Retry-After header."}